repo_id
stringlengths 5
115
| size
int64 590
5.01M
| file_path
stringlengths 4
212
| content
stringlengths 590
5.01M
|
|---|---|---|---|
6043/milk_lang
| 5,043
|
examples/prime-valid.s
|
.section .data
.section .text
.globl _start
_start:
mov %rsp, %rbp
sub $56, %rsp
sub $128, %rsp
mov %rbp, %rsi
addq $56, %rsi
movq $0, %rax
movq $0, %rdi
movq $64, %rdx
syscall
mov %rax, %rcx
subq $1, %rcx
mov %rsi, %r9
addq %rcx, %r9
subq $1, %r9
movq $1, %rbx
xor %r8, %r8
call ascii_to_int
movq %rax, -8(%rbp)
movq $0, %rax
movq %rax, -16(%rbp)
.STARTLOOP0:
movq -16(%rbp), %rax
mov %rax, %rcx
movq -8(%rbp), %rax
cmpq %rax, %rcx
setl %al
movzbq %al, %rax
test %rax, %rax
jz .ENDLOOP0
movq $2, %rax
movq %rax, -24(%rbp)
push %rcx
movq -24(%rbp), %rax
mov %rax, %rcx
movq $2, %rax
mov %rax, %rbx
movq $1, %rax
call exp
pop %rcx
movq %rax, -32(%rbp)
.STARTLOOP1:
movq -32(%rbp), %rax
mov %rax, %rcx
movq -16(%rbp), %rax
cmpq %rax, %rcx
setl %al
movzbq %al, %rax
test %rax, %rax
jz .ENDLOOP1
push %rcx
movq -24(%rbp), %rax
mov %rax, %rcx
movq $1, %rax
addq %rcx, %rax
pop %rcx
movq %rax, -24(%rbp)
push %rcx
movq -24(%rbp), %rax
mov %rax, %rcx
movq $2, %rax
mov %rax, %rbx
movq $1, %rax
call exp
pop %rcx
movq %rax, -32(%rbp)
jmp .STARTLOOP1
.ENDLOOP1:
movq $2, %rax
movq %rax, -40(%rbp)
movq $1, %rax
movq %rax, -48(%rbp)
.STARTLOOP2:
movq -40(%rbp), %rax
mov %rax, %rcx
movq -24(%rbp), %rax
cmpq %rax, %rcx
setl %al
movzbq %al, %rax
test %rax, %rax
jz .ENDLOOP2
push %rcx
movq -40(%rbp), %rax
mov %rax, %rcx
movq -16(%rbp), %rax
xor %rdx, %rdx
div %rcx
mov %rdx, %rax
pop %rcx
movq %rax, -56(%rbp)
movq -56(%rbp), %rax
mov %rax, %rcx
movq $0, %rax
cmpq %rcx, %rax
sete %al
movzbq %al, %rax
test %rax, %rax
jz .ENDIF0
movq $0, %rax
movq %rax, -48(%rbp)
jmp .ENDLOOP2
.ENDIF0:
push %rcx
movq -40(%rbp), %rax
mov %rax, %rcx
movq $1, %rax
addq %rcx, %rax
pop %rcx
movq %rax, -40(%rbp)
jmp .STARTLOOP2
.ENDLOOP2:
movq -48(%rbp), %rax
mov %rax, %rcx
movq $1, %rax
cmpq %rcx, %rax
sete %al
movzbq %al, %rax
test %rax, %rax
jz .ENDIF1
movq -16(%rbp), %rax
movq $1, %rsi
mov %rbp, %rcx
addq $119, %rcx
movq $0x0A, (%rcx)
dec %rcx
call int_to_ascii
movq $1, %rax
movq $1, %rdi
syscall
.ENDIF1:
push %rcx
movq -16(%rbp), %rax
mov %rax, %rcx
movq $1, %rax
addq %rcx, %rax
pop %rcx
movq %rax, -16(%rbp)
jmp .STARTLOOP0
.ENDLOOP0:
.exit:
movq $60, %rax
xor %rdi, %rdi
syscall
int_to_ascii:
xor %r10, %r10
test %rax, %rax
jns .convert_positive
movq $1, %r10
neg %rax
.convert_positive:
movq $10, %rbx
xor %rdx, %rdx
div %rbx
add $48, %dl
movb %dl, (%rcx)
inc %rsi
dec %rcx
test %rax, %rax
jnz .convert_positive
test %r10, %r10
jz .end_itoa
movb $'-', (%rcx)
dec %rcx
inc %rsi
.end_itoa:
inc %rcx
mov %rsi, %rdx
mov %rcx, %rsi
ret
ascii_to_int:
movb (%r9), %al
movzbq %al, %rax
sub $48, %rax
mul %rbx
add %rax, %r8
mov %rbx, %rax
mov $10, %rbx
mul %rbx
mov %rax, %rbx
dec %rcx
dec %r9
test %rcx, %rcx
jnz ascii_to_int
inc %r9
mov %r8, %rax
ret
exp:
test %rbx, %rbx
jz .endexp
mul %rcx
dec %rbx
jmp exp
.endexp:
ret
double_to_ascii:
xor %r12, %r12
cvttsd2si %xmm0, %r9
test %r9, %r9
jns .convert_positive_dta
movq $1, %r12
movabs $0x8000000000000000, %rax
movq %rax, %xmm2
xorpd %xmm2, %xmm0
cvttsd2si %xmm0, %r9
.convert_positive_dta:
movq $10000000000, %rax
cvtsi2sd %rax, %xmm1
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %rax
movq $10000000000, %r8
xor %rdx, %rdx
div %r8
mov %rdx, %rax
.double_to_ascii_loop:
mov %rax, %rbx
test %rax, %rax
jz .double_to_ascii_loop_end
xor %rdx, %rdx
movq $10, %r8
div %r8
test %rdx, %rdx
jz .double_to_ascii_loop
.double_to_ascii_loop_end:
mov %rbx, %rax
call int_to_ascii
mov %rsi, %rcx
mov %rdx, %rsi
dec %rcx
movb $46, (%rcx)
inc %rsi
dec %rcx
mov %r9, %rax
call int_to_ascii
test %r12, %r12
jz .end_dtoa
dec %rsi
movb $'-', (%rsi)
inc %rdx
.end_dtoa:
ret
heapalloc:
mov %rdi, %rsi
movq $0, %rdi
movq $0x3, %rdx
movq $0x22, %r10
movq $-1, %r8
xor %r9, %r9
movq $9, %rax
syscall
ret
strcpy:
test %rdx, %rdx
jz .end_strcpy
movb (%rdi), %al
movb %al, (%rsi)
dec %rdx
inc %rdi
inc %rsi
jmp strcpy
.end_strcpy:
movb $0, (%rsi)
ret
strlen:
xor %r9, %r9
.strlen_loop:
movb (%rdi), %al
test %al, %al
jz .end_strlen
inc %r9
inc %rdi
jmp .strlen_loop
.end_strlen:
mov %r9, %rax
ret
get_rand:
movq $318, %rax
movq $8, %rsi
movq $0, %rdx
syscall
movq (%rdi), %rax
ret
print_str:
mov %rdi, %rsi
call strlen
mov %rax, %rdx
mov %rsi, %r8
addq %rdx, %r8
movb $0x0A, (%r8)
inc %rdx
movq $1, %rax
movq $1, %rdi
syscall
movb $0, (%r8)
ret
|
6043/milk_lang
| 7,409
|
examples/rps-valid.s
|
.section .data
str0:
.string "Hello. Welcome to Rock, Paper, Scissors!"
str1:
.string " - 1 for Rock"
str2:
.string " - 2 for Paper"
str3:
.string " - 3 for Scissors"
str4:
.string " - 4 to exit"
str5:
.string "The computer chooses Rock"
str6:
.string "The computer chooses Paper"
str7:
.string "The computer chooses Scissors"
str8:
.string "You tie."
str9:
.string "You lose!"
str10:
.string "You win!"
.section .text
.globl _start
_start:
mov %rsp, %rbp
sub $16, %rsp
sub $128, %rsp
lea str0(%rip), %rax
mov %rax, %rdi
call print_str
movq $0, %rax
movq %rax, -8(%rbp)
movq $0, %rax
movq %rax, -16(%rbp)
.STARTLOOP0:
movq -8(%rbp), %rax
mov %rax, %rcx
movq $4, %rax
cmpq %rcx, %rax
setne %al
movzbq %al, %rax
test %rax, %rax
jz .ENDLOOP0
lea str1(%rip), %rax
mov %rax, %rdi
call print_str
lea str2(%rip), %rax
mov %rax, %rdi
call print_str
lea str3(%rip), %rax
mov %rax, %rdi
call print_str
lea str4(%rip), %rax
mov %rax, %rdi
call print_str
mov %rbp, %rsi
addq $16, %rsi
movq $0, %rax
movq $0, %rdi
movq $64, %rdx
syscall
mov %rax, %rcx
subq $1, %rcx
mov %rsi, %r9
addq %rcx, %r9
subq $1, %r9
movq $1, %rbx
xor %r8, %r8
call ascii_to_int
movq %rax, -8(%rbp)
movq -8(%rbp), %rax
mov %rax, %rcx
movq $4, %rax
cmpq %rcx, %rax
sete %al
movzbq %al, %rax
test %rax, %rax
jz .ENDIF0
jmp .ENDLOOP0
.ENDIF0:
push %rcx
movq $3, %rax
mov %rax, %rcx
mov %rbp, %rdi
addq $16, %rdi
push %rcx
call get_rand
pop %rcx
xor %rdx, %rdx
div %rcx
mov %rdx, %rax
pop %rcx
movq %rax, -16(%rbp)
push %rcx
movq -16(%rbp), %rax
mov %rax, %rcx
movq $1, %rax
addq %rcx, %rax
pop %rcx
movq %rax, -16(%rbp)
movq -16(%rbp), %rax
mov %rax, %rcx
movq $1, %rax
cmpq %rcx, %rax
sete %al
movzbq %al, %rax
test %rax, %rax
jz .ENDIF1
lea str5(%rip), %rax
mov %rax, %rdi
call print_str
.ENDIF1:
movq -16(%rbp), %rax
mov %rax, %rcx
movq $2, %rax
cmpq %rcx, %rax
sete %al
movzbq %al, %rax
test %rax, %rax
jz .ENDIF2
lea str6(%rip), %rax
mov %rax, %rdi
call print_str
.ENDIF2:
movq -16(%rbp), %rax
mov %rax, %rcx
movq $3, %rax
cmpq %rcx, %rax
sete %al
movzbq %al, %rax
test %rax, %rax
jz .ENDIF3
lea str7(%rip), %rax
mov %rax, %rdi
call print_str
.ENDIF3:
movq -8(%rbp), %rax
mov %rax, %rcx
movq $1, %rax
cmpq %rcx, %rax
sete %al
movzbq %al, %rax
test %rax, %rax
jz .ENDIF4
movq -16(%rbp), %rax
mov %rax, %rcx
movq $1, %rax
cmpq %rcx, %rax
sete %al
movzbq %al, %rax
test %rax, %rax
jz .ENDIF5
lea str8(%rip), %rax
mov %rax, %rdi
call print_str
.ENDIF5:
movq -16(%rbp), %rax
mov %rax, %rcx
movq $2, %rax
cmpq %rcx, %rax
sete %al
movzbq %al, %rax
test %rax, %rax
jz .ENDIF6
lea str9(%rip), %rax
mov %rax, %rdi
call print_str
.ENDIF6:
movq -16(%rbp), %rax
mov %rax, %rcx
movq $3, %rax
cmpq %rcx, %rax
sete %al
movzbq %al, %rax
test %rax, %rax
jz .ENDIF7
lea str10(%rip), %rax
mov %rax, %rdi
call print_str
.ENDIF7:
.ENDIF4:
movq -8(%rbp), %rax
mov %rax, %rcx
movq $2, %rax
cmpq %rcx, %rax
sete %al
movzbq %al, %rax
test %rax, %rax
jz .ENDIF8
movq -16(%rbp), %rax
mov %rax, %rcx
movq $1, %rax
cmpq %rcx, %rax
sete %al
movzbq %al, %rax
test %rax, %rax
jz .ENDIF9
lea str10(%rip), %rax
mov %rax, %rdi
call print_str
.ENDIF9:
movq -16(%rbp), %rax
mov %rax, %rcx
movq $2, %rax
cmpq %rcx, %rax
sete %al
movzbq %al, %rax
test %rax, %rax
jz .ENDIF10
lea str8(%rip), %rax
mov %rax, %rdi
call print_str
.ENDIF10:
movq -16(%rbp), %rax
mov %rax, %rcx
movq $3, %rax
cmpq %rcx, %rax
sete %al
movzbq %al, %rax
test %rax, %rax
jz .ENDIF11
lea str9(%rip), %rax
mov %rax, %rdi
call print_str
.ENDIF11:
.ENDIF8:
movq -8(%rbp), %rax
mov %rax, %rcx
movq $3, %rax
cmpq %rcx, %rax
sete %al
movzbq %al, %rax
test %rax, %rax
jz .ENDIF12
movq -16(%rbp), %rax
mov %rax, %rcx
movq $1, %rax
cmpq %rcx, %rax
sete %al
movzbq %al, %rax
test %rax, %rax
jz .ENDIF13
lea str9(%rip), %rax
mov %rax, %rdi
call print_str
.ENDIF13:
movq -16(%rbp), %rax
mov %rax, %rcx
movq $2, %rax
cmpq %rcx, %rax
sete %al
movzbq %al, %rax
test %rax, %rax
jz .ENDIF14
lea str10(%rip), %rax
mov %rax, %rdi
call print_str
.ENDIF14:
movq -16(%rbp), %rax
mov %rax, %rcx
movq $3, %rax
cmpq %rcx, %rax
sete %al
movzbq %al, %rax
test %rax, %rax
jz .ENDIF15
lea str8(%rip), %rax
mov %rax, %rdi
call print_str
.ENDIF15:
.ENDIF12:
jmp .STARTLOOP0
.ENDLOOP0:
.exit:
movq $60, %rax
xor %rdi, %rdi
syscall
int_to_ascii:
xor %r10, %r10
test %rax, %rax
jns .convert_positive
movq $1, %r10
neg %rax
.convert_positive:
movq $10, %rbx
xor %rdx, %rdx
div %rbx
add $48, %dl
movb %dl, (%rcx)
inc %rsi
dec %rcx
test %rax, %rax
jnz .convert_positive
test %r10, %r10
jz .end_itoa
movb $'-', (%rcx)
dec %rcx
inc %rsi
.end_itoa:
inc %rcx
mov %rsi, %rdx
mov %rcx, %rsi
ret
ascii_to_int:
movb (%r9), %al
movzbq %al, %rax
sub $48, %rax
mul %rbx
add %rax, %r8
mov %rbx, %rax
mov $10, %rbx
mul %rbx
mov %rax, %rbx
dec %rcx
dec %r9
test %rcx, %rcx
jnz ascii_to_int
inc %r9
mov %r8, %rax
ret
exp:
test %rbx, %rbx
jz .endexp
mul %rcx
dec %rbx
jmp exp
.endexp:
ret
double_to_ascii:
xor %r12, %r12
cvttsd2si %xmm0, %r9
test %r9, %r9
jns .convert_positive_dta
movq $1, %r12
movabs $0x8000000000000000, %rax
movq %rax, %xmm2
xorpd %xmm2, %xmm0
cvttsd2si %xmm0, %r9
.convert_positive_dta:
movq $10000000000, %rax
cvtsi2sd %rax, %xmm1
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %rax
movq $10000000000, %r8
xor %rdx, %rdx
div %r8
mov %rdx, %rax
.double_to_ascii_loop:
mov %rax, %rbx
test %rax, %rax
jz .double_to_ascii_loop_end
xor %rdx, %rdx
movq $10, %r8
div %r8
test %rdx, %rdx
jz .double_to_ascii_loop
.double_to_ascii_loop_end:
mov %rbx, %rax
call int_to_ascii
mov %rsi, %rcx
mov %rdx, %rsi
dec %rcx
movb $46, (%rcx)
inc %rsi
dec %rcx
mov %r9, %rax
call int_to_ascii
test %r12, %r12
jz .end_dtoa
dec %rsi
movb $'-', (%rsi)
inc %rdx
.end_dtoa:
ret
heapalloc:
mov %rdi, %rsi
movq $0, %rdi
movq $0x3, %rdx
movq $0x22, %r10
movq $-1, %r8
xor %r9, %r9
movq $9, %rax
syscall
ret
strcpy:
test %rdx, %rdx
jz .end_strcpy
movb (%rdi), %al
movb %al, (%rsi)
dec %rdx
inc %rdi
inc %rsi
jmp strcpy
.end_strcpy:
movb $0, (%rsi)
ret
strlen:
xor %r9, %r9
.strlen_loop:
movb (%rdi), %al
test %al, %al
jz .end_strlen
inc %r9
inc %rdi
jmp .strlen_loop
.end_strlen:
mov %r9, %rax
ret
get_rand:
movq $318, %rax
movq $8, %rsi
movq $0, %rdx
syscall
movq (%rdi), %rax
ret
print_str:
mov %rdi, %rsi
call strlen
mov %rax, %rdx
mov %rsi, %r8
addq %rdx, %r8
movb $0x0A, (%r8)
inc %rdx
movq $1, %rax
movq $1, %rdi
syscall
movb $0, (%r8)
ret
|
6043/milk_lang
| 4,794
|
examples/fib.s
|
.section .data
.section .text
.globl _start
_start:
mov %rsp, %rbp
sub $32, %rsp
sub $128, %rsp
mov %rbp, %rsi
addq $32, %rsi
movq $0, %rax
movq $0, %rdi
movq $64, %rdx
syscall
mov %rax, %rcx
subq $1, %rcx
mov %rsi, %r9
addq %rcx, %r9
subq $1, %r9
movq $1, %rbx
xor %r8, %r8
call ascii_to_int
movq %rax, -8(%rbp)
movq $10, %rax
mov %rax, %rdi
xor %r12, %r12
lea (%r12, %rdi, 8), %rdi
call heapalloc
movq %rax, -16(%rbp)
movq $1, %rax
push %rax
movq -16(%rbp), %rdx
movq $0, %rax
mov %rax, %rbx
pop %rax
movq %rax, (%rdx, %rbx, 8)
movq $1, %rax
push %rax
movq -16(%rbp), %rdx
movq $1, %rax
mov %rax, %rbx
pop %rax
movq %rax, (%rdx, %rbx, 8)
movq $2, %rax
movq %rax, -24(%rbp)
.STARTLOOP0:
movq -24(%rbp), %rax
mov %rax, %rcx
movq -8(%rbp), %rax
cmpq %rax, %rcx
setl %al
movzbq %al, %rax
test %rax, %rax
jz .ENDLOOP0
push %rcx
movq -16(%rbp), %rdx
push %rcx
movq $1, %rax
mov %rax, %rcx
movq -24(%rbp), %rax
subq %rcx, %rax
pop %rcx
mov %rax, %rbx
movq (%rdx, %rbx, 8), %rax
mov %rax, %rcx
movq -16(%rbp), %rdx
push %rcx
movq $2, %rax
mov %rax, %rcx
movq -24(%rbp), %rax
subq %rcx, %rax
pop %rcx
mov %rax, %rbx
movq (%rdx, %rbx, 8), %rax
addq %rcx, %rax
pop %rcx
push %rax
movq -16(%rbp), %rdx
movq -24(%rbp), %rax
mov %rax, %rbx
pop %rax
movq %rax, (%rdx, %rbx, 8)
push %rcx
movq -24(%rbp), %rax
mov %rax, %rcx
movq $1, %rax
addq %rcx, %rax
pop %rcx
movq %rax, -24(%rbp)
jmp .STARTLOOP0
.ENDLOOP0:
movq $0, %rax
movq %rax, -32(%rbp)
.STARTLOOP1:
movq -32(%rbp), %rax
mov %rax, %rcx
movq -8(%rbp), %rax
cmpq %rax, %rcx
setl %al
movzbq %al, %rax
test %rax, %rax
jz .ENDLOOP1
movq -16(%rbp), %rdx
movq -32(%rbp), %rax
mov %rax, %rbx
movq (%rdx, %rbx, 8), %rax
movq $1, %rsi
mov %rbp, %rcx
addq $95, %rcx
movq $0x0A, (%rcx)
dec %rcx
call int_to_ascii
movq $1, %rax
movq $1, %rdi
syscall
push %rcx
movq -32(%rbp), %rax
mov %rax, %rcx
movq $1, %rax
addq %rcx, %rax
pop %rcx
movq %rax, -32(%rbp)
jmp .STARTLOOP1
.ENDLOOP1:
.exit:
movq $60, %rax
xor %rdi, %rdi
syscall
int_to_ascii:
xor %r10, %r10
test %rax, %rax
jns .convert_positive
movq $1, %r10
neg %rax
.convert_positive:
movq $10, %rbx
xor %rdx, %rdx
div %rbx
add $48, %dl
movb %dl, (%rcx)
inc %rsi
dec %rcx
test %rax, %rax
jnz .convert_positive
test %r10, %r10
jz .end_itoa
movb $'-', (%rcx)
dec %rcx
inc %rsi
.end_itoa:
inc %rcx
mov %rsi, %rdx
mov %rcx, %rsi
ret
ascii_to_int:
movb (%r9), %al
movzbq %al, %rax
sub $48, %rax
mul %rbx
add %rax, %r8
mov %rbx, %rax
mov $10, %rbx
mul %rbx
mov %rax, %rbx
dec %rcx
dec %r9
test %rcx, %rcx
jnz ascii_to_int
inc %r9
mov %r8, %rax
ret
exp:
test %rbx, %rbx
jz .endexp
mul %rcx
dec %rbx
jmp exp
.endexp:
ret
double_to_ascii:
xor %r12, %r12
cvttsd2si %xmm0, %r9
test %r9, %r9
jns .convert_positive_dta
movq $1, %r12
movabs $0x8000000000000000, %rax
movq %rax, %xmm2
xorpd %xmm2, %xmm0
cvttsd2si %xmm0, %r9
.convert_positive_dta:
movq $10000000000, %rax
cvtsi2sd %rax, %xmm1
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %rax
movq $10000000000, %r8
xor %rdx, %rdx
div %r8
mov %rdx, %rax
.double_to_ascii_loop:
mov %rax, %rbx
test %rax, %rax
jz .double_to_ascii_loop_end
xor %rdx, %rdx
movq $10, %r8
div %r8
test %rdx, %rdx
jz .double_to_ascii_loop
.double_to_ascii_loop_end:
mov %rbx, %rax
call int_to_ascii
mov %rsi, %rcx
mov %rdx, %rsi
dec %rcx
movb $46, (%rcx)
inc %rsi
dec %rcx
mov %r9, %rax
call int_to_ascii
test %r12, %r12
jz .end_dtoa
dec %rsi
movb $'-', (%rsi)
inc %rdx
.end_dtoa:
ret
heapalloc:
mov %rdi, %rsi
movq $0, %rdi
movq $0x3, %rdx
movq $0x22, %r10
movq $-1, %r8
xor %r9, %r9
movq $9, %rax
syscall
ret
strcpy:
test %rdx, %rdx
jz .end_strcpy
movb (%rdi), %al
movb %al, (%rsi)
dec %rdx
inc %rdi
inc %rsi
jmp strcpy
.end_strcpy:
movb $0, (%rsi)
ret
strlen:
xor %r9, %r9
.strlen_loop:
movb (%rdi), %al
test %al, %al
jz .end_strlen
inc %r9
inc %rdi
jmp .strlen_loop
.end_strlen:
mov %r9, %rax
ret
get_rand:
movq $318, %rax
movq $8, %rsi
movq $0, %rdx
syscall
movq (%rdi), %rax
ret
print_str:
mov %rdi, %rsi
call strlen
mov %rax, %rdx
mov %rsi, %r8
addq %rdx, %r8
movb $0x0A, (%r8)
inc %rdx
movq $1, %rax
movq $1, %rdi
syscall
movb $0, (%r8)
ret
|
6043/milk_lang
| 1,182
|
assembly/double_to_ascii.s
|
# assume HEX representation is in %xmm0.
# also assume that the char ptr at the LAST char is in %rcx.
.double_to_ascii:
xor %r12, %r12
# save whole number part in r9.
cvttsd2si %xmm0, %r9
test %r9, %r9
jns .convert_positive_dta:
movq $1, %r12
movabs $0x8000000000000000, %rax
movq %rax, %xmm2
xorpd %xmm2, %xmm0
cvttsd2si %xmm0, %r9
.convert_positive_dta:
# get fractional part
movq $10000000000, %rax
cvtsi2sd %rax, %xmm1
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %rax
movq $10000000000, %r8
xor %rdx, %rdx
div %r8
mov %rdx, %rax
# remove extra zeros
.double_to_ascii_loop:
mov %rax, %rbx
test %rax, %rax
jz .double_to_ascii_loop_end
xor %rdx, %rdx
movq $10, %r8
div %r8
test %rdx, %rdx
jz .double_to_ascii_loop # we had no remainder
.double_to_ascii_loop_end:
mov %rbx, %rax # get good fraction back
call int_to_ascii
mov %rsi, %rcx
mov %rdx, %rsi
dec %rcx
movb $46, (%rcx)
inc %rsi
dec %rcx
mov %r9, %rax
call int_to_ascii
test %r12, %r12
jz .end_dtoa
dec %rsi
movb $'-', (%rsi)
inc %rdx
.end_dtoa:
ret
|
6502-retro/6502-retro-os
| 1,195
|
bios/acia.s
|
; vim: ft=asm_ca65
.include "io.inc"
.include "bios.inc"
.autoimport
.globalzp ptr1
.export acia_init, acia_getc, acia_getc_nw, acia_putc
; vim: set ft=asm_ca65 sw=4 ts=4 et:
ACIA_PARITY_DISABLE = %00000000
ACIA_ECHO_DISABLE = %00000000
ACIA_TX_INT_DISABLE_RTS_LOW = %00001000
ACIA_RX_INT_ENABLE = %00000000
ACIA_RX_INT_DISABLE = %00000010
ACIA_DTR_LOW = %00000001
.zeropage
.code
acia_init:
lda #$00
sta acia_status
lda #(ACIA_PARITY_DISABLE | ACIA_ECHO_DISABLE | ACIA_TX_INT_DISABLE_RTS_LOW | ACIA_RX_INT_DISABLE | ACIA_DTR_LOW)
sta acia_command
lda #$10
sta acia_control
rts
; changed this to use bios_const so that the emulator
; doesn't hang while waiting for user input.
acia_getc:
jsr bios_const
beq acia_getc
rts
acia_getc_nw:
lda acia_status
and #$08
beq @done
lda acia_data
;cmp #$7F
;bne :+
;lda #$08
sec
rts
@done:
clc
rts
acia_putc:
pha ; save char
@wait_txd_empty:
lda acia_status
and #$10
beq @wait_txd_empty
pla ; restore char
sta acia_data
rts
.bss
.rodata
|
6502-retro/6502-retro-os
| 4,267
|
bios/bios.s
|
; vim: ft=asm_ca65
.include "io.inc"
.include "bios.inc"
.autoimport
.globalzp ptr1, bdma_ptr
.export cboot
.export _vdp_sync, _vdp_status, _notectr
.export error_code, rega, regx, regy
.export user_nmi_vector, user_irq_vector
.if DEBUG=1
.export bios_printlba
.endif
.zeropage
ptr1: .word 0
bdma_ptr: .word 0
blba_ptr: .word 0
.code
cboot:
ldx #$ff
txs
cld
sei
;jsr via_init
jsr acia_init
jsr sn_start
lda #%11010111
sta via_ddra
cboot_emu:
; copy SYSTEM code into RUN area
ldx #<__SYSTEM_SIZE__
@L2:
lda __SYSTEM_LOAD__ - 1,x
sta __SYSTEM_RUN__ -1,x
dex
bne @L2
jsr zerobss
jsr zero_lba
jsr sn_beep
; enable VDP interrupts (gives us a 60hz clock)
lda #$F0 ; r1 16kb ram + M1, interrupts enabled, text mode
sta vdp_reg
lda #$81
sta vdp_reg
cli
jmp sfos_s_reset
;
wboot:
; usually this is where we need to check if the SFCP needs to be
; reloaded.
jmp prompt
conin:
jmp acia_getc
conout:
jmp acia_putc
const:
jmp acia_getc_nw
setdma:
sta bdma_ptr + 0
sta bdma + 0
stx bdma_ptr + 1
stx bdma + 1
clc
rts
setlba:
sta blba_ptr + 0
stx blba_ptr + 1
ldy #3
@L1:
lda (blba_ptr),y
sta sector_lba,y
dey
bpl @L1
clc
rts
sdread:
jsr set_sdbuf_ptr
jmp sdcard_read_sector
sdwrite:
jsr set_sdbuf_ptr
jmp sdcard_write_sector
puts:
sta ptr1 + 0
stx ptr1 + 1
ldy #0
: lda (ptr1),y
beq @done
jsr bios_conout
iny
beq @done
bra :-
@done:
rts
prbyte:
pha ;Save A for LSD.
lsr
lsr
lsr ;MSD to LSD position.
lsr
jsr prhex ;Output hex digit.
pla ;Restore A.
prhex:
and #$0F ;Mask LSD for hex print.
ora #$B0 ;Add "0".
cmp #$BA ;Digit?
bcc echo ;Yes, output it.
adc #$06 ;Add offset for letter.
echo:
pha ;*Save A
and #$7F ;*Change to "standard ASCII"
jsr bios_conout
pla ;*Restore A
rts ;*Done, over and out...
; a is number of ms to delay
delay_ms:
phx
phy
sta ptr1
@l1:
ldy #16
@l2:
ldx #250 ; 16 * 250 = 4000 = 1ms give or take
@l3:
dex
bne @l3
dey
bne @l2
dec ptr1
lda ptr1
bne @l1
@done:
ply
plx
rts
;---- Helper functions -------------------------------------------------------
set_sdbuf_ptr:
lda bdma + 1
sta bdma_ptr + 1
lda bdma + 0
sta bdma_ptr + 0
rts
zero_lba:
stz sector_lba + 0 ; sector inside file
stz sector_lba + 1 ; file number
stz sector_lba + 2 ; drive number
stz sector_lba + 3 ; always zero
rts
;---- STUB IRQ / NMI Handlers ------------------------------------------------
stub_user_irq_handler:
rts
stub_user_nmi_handler:
jmp bios_wboot
.segment "SYSTEM"
; dispatch function, will be relocated on boot into SYSRAM
jmptable:
jmp dispatch ; 200
jmp cboot ; 203
jmp wboot ; 206
jmp conout ; 209
jmp conin ; 20c
jmp const ; 20f
jmp puts ; 212
jmp prbyte ; 215
jmp setdma ; 218
jmp setlba ; 21b
jmp sdread ; 21e
jmp sdwrite ; 221
jmp sn_beep ; 224
jmp sn_start ; 227
jmp sn_silence ; 22a
jmp sn_stop ; 22d
jmp sn_send ; 230
jmp led_on ; 233
jmp led_off ; 236
jmp get_button ; 239
error_code: .byte 0 ; 23c
.assert * = $23d, error, "rstfar should be at $23d"
rstfar:
pha
lda via_ddra
and #%10111111
sta via_ddra
pla
sta rombankreg
jmp ($FFFC)
.assert * = $24d, error, "REG A should be at $24d"
rega: .res 1
regx: .res 1
regy: .res 1
.assert * = $250, error, "end of system should be at $250"
user_irq_vector:
.lobytes stub_user_irq_handler
.hibytes stub_user_irq_handler
user_nmi_vector:
.lobytes stub_user_nmi_handler
.hibytes stub_user_nmi_handler
jmp delay_ms ; 254
_notectr: .res 1 ; 257
.assert * = $258, error, "end of bios jumps should be at $258"
.bss
bdma: .word 0
_vdp_status:.res 1
_vdp_sync: .res 1
.segment "SYSTEM"
.rodata
|
6502-retro/6502-retro-os
| 1,594
|
bios/sn76489.s
|
; vim: ft=asm_ca65 ts=4 sw=4 :
; Library functions for basic control of the SN76489 attached to the VIA
.include "io.inc"
.export sn_start, sn_stop, sn_silence, sn_beep, sn_play_note, sn_send
.export sn_irq_handler
.import _notectr
FIRST = %10000000
SECOND = %00000000
CHAN_1 = %00000000
CHAN_2 = %00100000
CHAN_3 = %01000000
CHAN_N = %01100000
TONE = %00000000
VOL = %00010000
VOL_OFF = %00001111
VOL_MAX = %00000000
.zeropage
.code
sn_start:
;lda #(SD_SCK | SD_CS | SD_MOSI | SN_WE)
;sta via_ddra
lda #$ff
sta via_ddrb
jsr sn_silence
rts
sn_stop:
jsr sn_silence
rts
sn_silence:
lda #(FIRST|CHAN_1|VOL|VOL_OFF)
jsr sn_send
lda #(FIRST|CHAN_2|VOL|VOL_OFF)
jsr sn_send
lda #(FIRST|CHAN_3|VOL|VOL_OFF)
jsr sn_send
lda #(FIRST|CHAN_N|VOL|VOL_OFF)
jsr sn_send
rts
sn_beep:
lda #$07
ldy #$04
jsr sn_play_note
ldy #$40
@d1:
ldx #$00
@d2:
dex
bne @d2
dey
bne @d1
jsr sn_silence
rts
sn_play_note:
ora #(FIRST|CHAN_1|TONE)
jsr sn_send
tya
ora #(SECOND|CHAN_1|TONE)
jsr sn_send
lda #(FIRST|CHAN_1|VOL|$04)
jsr sn_send
rts
; Byte to send in A
sn_send:
sta via_portb
ldx #(SD_SCK|SD_CS|SD_MOSI|SN_WE)
stx via_porta
ldx #(SD_SCK|SD_CS|SD_MOSI)
stx via_porta
jsr sn_wait
ldx #(SD_SCK|SD_CS|SD_MOSI|SN_WE)
stx via_porta
rts
sn_wait:
lda via_porta
and #SN_READY
bne sn_wait
rts
sn_irq_handler:
dec _notectr
bne @exit
lda #(FIRST|CHAN_1|VOL|15)
jsr sn_send
@exit:
rts
|
6502-retro/6502-retro-os
| 6,868
|
bios/sdcard.s
|
; vim: ft=asm_ca65
;-----------------------------------------------------------------------------
; SDCARD Routines adapted from:
; https://github.com/X16Community/x16-rom/blob/master/fat32/sdcard.s
; Copyright (C) 2020 Frank van den Hoef
;
; SPI Routines from:
; https://github.com/Steckschwein/code/blob/master/steckos/libsrc/spi/spi_rw_byte.s
; Copyright (c) 2018 Thomas Woinke, Marko Lauke, www.steckschwein.de
;-----------------------------------------------------------------------------
.include "io.inc"
.autoimport
.globalzp bdma_ptr
.export sector_lba, sdcard_read_sector, sdcard_write_sector
.macro deselect
lda #(SD_CS|SD_MOSI|SN_WE) ; deselect sdcard
sta via_porta
.endmacro
.macro select
lda #(SD_MOSI|SN_WE)
sta via_porta
.endmacro
cmd_idx = sdcard_param
cmd_arg = sdcard_param + 1
cmd_crc = sdcard_param + 5
.bss
sdcard_param:
.res 1
sector_lba:
.res 4 ; dword (part of sdcard_param) - LBA of sector to read/write
.res 1
timeout_cnt: .byte 0
spi_sr: .byte 0
.code
;-----------------------------------------------------------------------------
; wait ready
;
; clobbers: A,X,Y
;-----------------------------------------------------------------------------
wait_ready:
lda #$F0
sta timeout_cnt
@1: ldx #0 ; 2
@2: ldy #0 ; 2
@3: jsr spi_read ; 22
cmp #$FF ; 2
beq @done ; 2 + 1
dey ; 2
bne @3 ; 2 + 1
dex ; 2
bne @2 ; 2 + 1
dec timeout_cnt
bne @1
; Total timeout: ~508 ms @ 8MHz
; Timeout error
sec
rts
@done: clc
rts
; waits for sdcard to return anything other than FF
wait_result:
jsr spi_read
cmp #$FF
beq wait_result
rts
; read a byte over SPI - result in A
spi_read:
pha
select
pla
lda #$ff
phx
phy
jsr spi_rw_byte
ply
plx
pha
deselect
pla
rts
; write a byte (A) via SPI
spi_write:
pha
select
pla
phx
phy
jsr spi_rw_byte
ply
plx
pha
deselect
pla
rts
spi_rw_byte:
sta spi_sr
ldx #$08
lda via_porta
and #$fe
asl
tay
@l: rol spi_sr
tya
ror
sta via_porta
inc via_porta
sta via_porta
dex
bne @l
lda via_sr
rts
;-----------------------------------------------------------------------------
; send_cmd - Send cmdbuf
;
; first byte of result in A, clobbers: Y
;-----------------------------------------------------------------------------
send_cmd:
jsr sdcmd_start
; Send the 6 cmdbuf bytes
lda cmd_idx
jsr spi_write
lda cmd_arg + 3
jsr spi_write
lda cmd_arg + 2
jsr spi_write
lda cmd_arg + 1
jsr spi_write
lda cmd_arg + 0
jsr spi_write
lda cmd_crc
jsr spi_write
; Wait for response
ldy #(10 + 1)
@1: dey
beq @error ; Out of retries
jsr spi_read
cmp #$ff
beq @1
; Success
jsr sdcmd_end
clc
rts
@error: ; Error
jsr sdcmd_end
sec
rts
sdcmd_start:
php
pha
phx
jsr sdcmd_nothingbyte
jsr sdcmd_nothingbyte
lda #$ff
jsr spi_write
plx
pla
plp
rts
sdcmd_nothingbyte:
ldx #8
@loop:
lda #(SD_MOSI|SD_CS|SN_WE)
sta via_porta
lda #(SD_SCK|SD_MOSI|SD_CS|SN_WE)
sta via_porta
dex
bne @loop
rts
sdcmd_end:
php
pha
phx
lda #$ff
jsr spi_write
jsr sdcmd_nothingbyte
jsr sdcmd_nothingbyte
lda #(SD_CS|SD_MOSI|SN_WE)
sta via_porta
plx
pla
plp
rts
;-----------------------------------------------------------------------------
; sdcard_read_sector
; Set sector_lba prior to calling this function.
; result: C=0 -> error, C=1 -> success
;-----------------------------------------------------------------------------
sdcard_read_sector:
jsr sdcmd_start
; Send READ_SINGLE_BLOCK command
lda #($40 | 17)
sta cmd_idx
lda #1
sta cmd_crc
jsr sdcmd_start
jsr send_cmd
; Wait for start of data packet
ldx #0
@1: ldy #0
@2: jsr spi_read
cmp #$FE
beq @start
dey
bne @2
dex
bne @1
; Timeout error
jsr sdcmd_end
deselect
sec
rts
@start: ; Read 512 bytes of sector data
ldx #$FF
ldy #0
@3: jsr spi_read
sta (bdma_ptr), y
iny
bne @3
inc bdma_ptr + 1
; Y already 0 at this point
@5: jsr spi_read
sta (bdma_ptr), y
iny
bne @5
dec bdma_ptr + 1
; Read CRC bytes
jsr spi_read
jsr spi_read
jsr sdcmd_end
; Success
deselect
clc
rts
;-----------------------------------------------------------------------------
; sdcard_write_sector
; Set sector_lba prior to calling this function.
; result: C=0 -> error, C=1 -> success
;-----------------------------------------------------------------------------
sdcard_write_sector:
jsr sdcmd_start
; Send WRITE_BLOCK command
lda #($40 | 24)
sta cmd_idx
lda #1
sta cmd_crc
jsr send_cmd
cmp #00
bne @error
; Wait for card to be ready
jsr wait_ready
bcs @error
; Send start of data token
lda #$FE
jsr spi_write
; Send 512 bytes of sector data
ldy #0
@1: lda (bdma_ptr), y ; 4
jsr spi_write
iny ; 2
bne @1 ; 2 + 1
inc bdma_ptr + 1
; Y already 0 at this point
@2: lda (bdma_ptr), y ; 4
jsr spi_write
iny ; 2
bne @2 ; 2 + 1
dec bdma_ptr + 1
; Dummy CRC
lda #0
jsr spi_write
jsr spi_write
; wait for data response
jsr wait_result
and #$1f
cmp #$05
bne @error
; wait for it to be idle
jsr wait_ready
bcs @error
; Success
jsr sdcmd_end
deselect
clc
rts
@error: ; Error
jsr sdcmd_end
deselect
sec
rts
|
6502-retro/6502-retro-os
| 20,378
|
sfcp/sfcp.s
|
; vim: ft=asm_ca65 ts=4 sw=4 et
.include "sfos.inc"
.include "fcb.inc"
.include "errors.inc"
.include "bios.inc"
.export main, prompt
.autoimport
.globalzp ptr1
.zeropage
debug_ptr: .word 0
sfcpcmd: .word 0
.code
; main user interface - First show a prompt.
main:
lda #<str_banner
ldx #>str_banner
jsr c_printstr
lda #1
sta active_drive
sta saved_active_drive
prompt:
jsr newline
jsr process_submit
bcc process_command ; Skip reading userinput if $$$.sub processed.
prompt_no_newline:
jsr show_prompt
jsr clear_commandline
lda #128
sta commandline
lda #<commandline
ldx #>commandline
jsr c_readstr
process_command:
jsr clear_fcb
jsr clear_fcb2
lda #<fcb
ldx #>fcb
jsr d_setdma
ldx #>commandline ; set XA to the second byte of the commandline
lda #<commandline ; the first contains the length from readstr
inc ; if the incrementing the low byte of the address
bne :+ ; results in zero then increment the high byte
inx
: jsr d_parsefcb ; XA -> param is the start of the filename.
; XA -> Points to new command offset
bcc :+
jsr printi
.byte 10,13,"parse error: fcb1",10,13,0
jmp prompt
:
; parse any parameters
; XA points to start of rest of command line.
sta debug_ptr + 0
stx debug_ptr + 1
ldy #0
lda (debug_ptr),y
beq @check_drive ; no parameters go on to checkdrive
; else setup and parse the parameter
lda #<fcb2
ldx #>fcb2
jsr d_setdma
ldx debug_ptr + 1
lda debug_ptr + 0
inc ; skip over space
bne :+
inx
: jsr d_parsefcb
; XA points to command tail
bcc @check_drive
jsr printi
.byte 10,13,"parse error: fcb2",10,13,0
jmp prompt
@check_drive:
inc ; skip over space
bne :+
inx
: sta cmdoffset+0
stx cmdoffset+1
; check if we are dealing with a change drive command
; byte N1 of the fcb will be a space
lda fcb+sfcb::N1
cmp #' '
beq @changedrive
bra @decode_command
@changedrive:
lda fcb + sfcb::DD
ldx #0
sta active_drive
jsr d_getsetdrive
jmp prompt
@decode_command:
jsr decode_command
bcs @load_transient
cmp #1
bne :+
jsr printi
.byte 10,13,"SYNTAX ERROR",10,13,0
: jmp prompt
@load_transient:
jsr load_transient
jmp prompt
decode_command:
ldx #0
ldy #0
stx temp + 0 ; temp + 0 holds the start position of words in the commands table.
@L1:
lda commands_tbl,y
bmi @found_match ; if we get to the $80 marker, without dropping, we found a match
beq @no_match ; if we get to the end of the table we did not match at all
cmp fcb + sfcb::N1,x
bne @next_word
inx ; prepare to check next letter
iny
bra @L1
@next_word:
ldx #0 ; reset fcb index to 0
inc temp + 0 ; next word
lda temp + 0 ; times temp + 0 by 7
asl ; x2
asl ; x4
asl ; x8
sec
sbc temp + 0 ; subtract value to make it x 7
tay ; update pointer
bra @L1
@found_match:
; reached the end of work marker.
; grab the function pointer, return in XA
iny
lda commands_tbl,y
sta sfcpcmd + 0
iny
lda commands_tbl,y
sta sfcpcmd + 1
clc
jmp (sfcpcmd) ; return from command
@no_match:
sec
rts
process_submit:
; safe to use fcb here.
ldx #31 ; set up fcb for open
: lda str_submit_fcb,x
sta submit_fcb,x
dex
bpl :-
lda #<submit_fcb
ldx #>submit_fcb
jsr d_open
bcc @read_file ; file was opened so read it.
rts
@read_file:
; copy sector count into CR
lda submit_fcb + sfcb::SC
dec
bpl :+ ; if SC-1 < 0 then delete file
jmp @delete_file
: sta temp+0
stz temp+3 ; set up LBA to read last block of the file
lda submit_fcb + sfcb::DD
sta temp+2
lda submit_fcb + sfcb::FN
sta temp+1
lda #<temp
ldx #>temp
jsr d_setlba
lda #<sfos_buf
ldx #>sfos_buf
jsr d_setdma
lda #<submit_fcb ; read the block, do not adjust CR
ldx #>submit_fcb
jsr d_readrawblock
bcc @find_record
rts
@find_record:
lda submit_fcb + sfcb::Z1
dec
bpl :+
jmp @delete_file
: sta submit_fcb + sfcb::Z1 ; save updated Z1
and #$03 ; mod 4
pha
; decide to decrement SC
bne :+
dec submit_fcb + sfcb::SC
: pla
sta ptr1 + 0
stz ptr1 + 1
ldx #7
: asl ptr1
rol ptr1+1
dex
bne :-
clc
lda ptr1+0
adc #0
sta ptr1+0
lda ptr1+1
adc #>sfos_buf
sta ptr1+1
; ptr1 now points to start of command in buffer
; copy it to the commanline
ldy #0
: lda (ptr1),y
sta commandline,y
phy
jsr c_write
ply
iny
bpl :-
; save fcb back to disk
lda submit_fcb + sfcb::Z1
bne @save
@delete_file:
lda #$E5
sta submit_fcb + sfcb::FA
@save:
lda #<submit_fcb
ldx #>submit_fcb
jsr d_close
clc
rts
load_transient:
jsr set_user_drive
; check if FCB has extension. if not, then add .COM
lda fcb+sfcb::T1
cmp #' '
bne :++
ldx #2
: lda str_COM,x
sta fcb+sfcb::T1,x
dex
bpl :-
: lda #<fcb
ldx #>fcb
jsr d_open
bcc :+
jsr newline
lda #'?'
jsr c_write
jsr restore_active_drive
lda #0
jmp prompt
; now dma is set.
; get the sector count from the fcb
: lda fcb + sfcb::SC
sta sfcpcmd ; using cmd temporarily here.
lda fcb + sfcb::L1
sta temp+0
lda fcb + sfcb::L2
sta temp+1
@sector_loop:
lda #<fcb
ldx #>fcb
jsr d_readseqblock ; calculates DMA from FCB
clc
lda temp+1
adc #2
sta temp+1
lda temp+1
cmp #>TPA_END ; leaves 256 bytes unused.
bne :+
lda #ERROR::OUT_OF_MEMORY
sec
rts
: lda temp+0
ldx temp+1
jsr d_setdma
dec sfcpcmd
bne @sector_loop
; now set up the command pointer
lda fcb + sfcb::E1
sta sfcpcmd+0
lda fcb + sfcb::E2
sta sfcpcmd+1
; Set TPA
lda temp+1
jsr s_settpa
call:
jsr restore_active_drive
jmp (sfcpcmd)
bank:
lda commandline + 5
beq @parse_error
lda commandline + 6
cmp #' '
beq @parse_error
cmp #'0'
bcc @parse_error
cmp #'3'+1
bcs @parse_error
sec
sbc #'0'
jmp bios_rstfar
@parse_error:
jsr printi
.byte 10,13,"INVALID BANK",0
lda #0
jmp prompt
dir:
jsr newline
lda #5
sta temp ; number of records per line
jsr set_user_drive
jsr print_drive_colon
jsr clear_fcb
jsr make_dir_fcb
lda #<fcb
ldx #>fcb
jsr d_findfirst
bcc @skip_first
; Error on find first can be DRIVE_ERROR or END_OF_DIR
cmp #ERROR::FILE_NOT_FOUND ; it's okay to have end of directory
beq @exit ; on find first. (empty drive)
sec
rts
@next:
bcs @exit
lda temp
cmp #1
beq @skip_first
lda #<str_sep
ldx #>str_sep
jsr c_printstr
@skip_first:
jsr print_fcb
jsr clear_fcb
jsr make_dir_fcb
lda #<fcb
ldx #>fcb
jsr d_findnext
bra @next
@exit: ; this exit is normal, end of drive.
jsr restore_active_drive
lda #0
clc
jmp prompt
era:
jsr set_user_drive
lda #<fcb2
ldx #>fcb2
jsr d_findfirst
bcc :+
jsr printi
.byte 10,13,"FILE NOT FOUND",10,13,0
sec
rts
:
lda #$E5
sta fcb2 + sfcb::FA
lda #<fcb2
ldx #>fcb2
jsr d_close
jsr restore_active_drive
lda #0
clc
rts
free:
jsr printi
.byte 10,13,"\r\nTYPE: START-END SIZE"
.byte 10,13,"\r\nZEROPAGE: ",0
lda #<__ZEROPAGE_LOAD__
jsr bios_prbyte
lda #'-'
jsr c_write
lda #<__ZEROPAGE_SIZE__
clc
adc #<__ZEROPAGE_LOAD__
jsr bios_prbyte
lda #' '
jsr c_write
lda #<__ZEROPAGE_SIZE__
ldx #>__ZEROPAGE_SIZE__
jsr print_word
jsr printi
.byte 10,13,"SYSTEM: ",0
lda #<__SYSTEM_RUN__
ldx #>__SYSTEM_RUN__
jsr print_word
lda #'-'
jsr c_write
lda #<__SYSTEM_SIZE__
sta temp+0
lda #>__SYSTEM_SIZE__
sta temp+1
clc
lda temp+0
adc #<__SYSTEM_RUN__
sta temp+0
lda temp+1
adc #>__SYSTEM_RUN__
sta temp+1
lda temp+0
ldx temp+1
jsr print_word
lda #' '
jsr c_write
lda #<__SYSTEM_SIZE__
ldx #>__SYSTEM_SIZE__
jsr print_word
jsr printi
.byte 10,13,"BSS: ",0
lda #<__BSS_LOAD__
ldx #>__BSS_LOAD__
jsr print_word
lda #'-'
jsr c_write
lda #<__BSS_SIZE__
sta temp+0
lda #>__BSS_SIZE__
sta temp+1
clc
lda temp+0
adc #<__BSS_LOAD__
sta temp+0
lda temp+1
adc #>__BSS_LOAD__
sta temp+1
lda temp+0
ldx temp+1
jsr print_word
lda #' '
jsr c_write
lda #<__BSS_SIZE__
ldx #>__BSS_SIZE__
jsr print_word
jsr printi
.byte 10,13,"TPA: ",0
lda #<TPA
ldx #>TPA
jsr print_word
lda #'-'
jsr c_write
lda #<TPA_END
ldx #>TPA_END
jsr print_word
lda #' '
jsr c_write
sec
lda #<TPA_END
sbc #<TPA
sta temp+0
lda #>TPA_END
sbc #>TPA
sta temp+1
lda temp+0
ldx temp+1
jsr print_word
jsr printi
.byte 10,13,"SFM ",0
lda #<__CODE_LOAD__
ldx #>__CODE_LOAD__
jsr print_word
lda #'-'
jsr c_write
lda #<__CODE_SIZE__
sta temp+0
lda #>__CODE_SIZE__
sta temp+1
clc
lda temp+0
adc #<__CODE_LOAD__
adc #<__RODATA_SIZE__
sta temp+0
lda temp+1
adc #>__CODE_LOAD__
adc #>__RODATA_SIZE__
sta temp+1
lda temp+0
ldx temp+1
jsr print_word
lda #' '
jsr c_write
lda #<__CODE_SIZE__
sta temp+0
lda #>__CODE_SIZE__
sta temp+1
clc
lda temp+0
adc #<__RODATA_SIZE__
sta temp+0
lda temp+1
adc #>__RODATA_SIZE__
sta temp+1
lda temp+0
ldx temp+1
jsr print_word
jmp prompt
help:
lda #<str_help
ldx #>str_help
jsr c_printstr
jmp prompt
ren:
ldx #0
lda #0
: sta fcb,x
inx
cpx #32
bne :-
; parse fcb
lda #<fcb
ldx #>fcb
jsr d_setdma
lda cmdoffset+0
ldx cmdoffset+1
jsr d_parsefcb
jsr newline
; FCB contains the destination copy:
; open the source
lda #<fcb
ldx #>fcb
jsr d_findfirst
bcs :+
lda #'?'
jsr c_write
jmp @exit
: lda #<fcb2
ldx #>fcb2
jsr d_findfirst
bcc :+
lda #'?'
jsr c_write
jmp @exit
: ldy #sfcb::N1
: lda fcb,y
sta fcb2,y
iny
cpy #sfcb::T3 + 1
bne :-
@close:
stz fcb2 + sfcb::DS
lda #<fcb2
ldx #>fcb2
jsr d_close
@exit:
jsr restore_active_drive
lda #0 ; make sure that we don't trigger a syntax error.
clc
rts
type:
jsr set_user_drive
jsr newline
lda fcb2+sfcb::DD
beq @error
lda #<fcb2
ldx #>fcb2
jsr d_open
bcs @notopen
; file is found - set up lba
; rather than assume the dma for a non exec file, we just set our own
; use the sfos_buf here.
@sector_loop:
lda #<sfos_buf
ldx #>sfos_buf
jsr d_setdma
lda #<fcb2
ldx #>fcb2
jsr d_readseqblock
lda #<sfos_buf
sta debug_ptr + 0
lda #>sfos_buf
sta debug_ptr + 1
@byte_loop:
lda (debug_ptr)
pha
jsr c_write
pla
cmp #$0a
bne :+
lda #$0d
jsr c_write
:
; decrement the remaining size
lda fcb2 + sfcb::S0
bne @dec_ones
lda fcb2 + sfcb::S1
bne @dec_tens
lda fcb2 + sfcb::S2
beq @exit
@dec_hundreds:
dec fcb2 + sfcb::S2
@dec_tens:
dec fcb2 + sfcb::S1
@dec_ones:
dec fcb2 + sfcb::S0
;
; move pointer along
clc
lda debug_ptr+0
adc #1
sta debug_ptr+0
lda debug_ptr+1
adc #0
sta debug_ptr+1
cmp #>sfos_buf + 2
bne @byte_loop
bra @sector_loop
@notfound:
lda #'/'
bra @error
@notopen:
lda #'?'
@error:
jsr c_write
jsr restore_active_drive
sec
rts
@exit:
jsr restore_active_drive
lda #0 ; make sure that we don't trigger a syntax error.
clc
rts
save:
; copy fcb2 filename into fcb
jsr clear_fcb
ldx #sfcb::N1
: lda fcb2,x
sta fcb,x
inx
cpx #sfcb::T3+1
bne :-
jsr newline
lda #<fcb
ldx #>fcb
jsr d_make
bcc :+
jsr printi
.byte 10,13,"MAKE FAILED",10,13,0
lda #1
clc
rts
:
; convert command tail which is the number of pages to save to a byte
jsr parse_number
bcc :+
jsr printi
.byte 10,13,"NOT A NUMBER",10,13,0
lda #1
clc
rts ; parse fail
:
; temp+0 has the number of pages to save
lda #<TPA
ldx #>TPA
stx temp+3
jsr d_setdma
stz temp+2 ; number of sectors written
@lp:
lda temp+0
beq @exit ; have we hit zero pages?
lda #'.'
jsr c_write
lda #<fcb
ldx #>fcb
jsr d_writeseqblock
bcs @error
inc temp+2
dec temp+0 ; save two pages per writeblock
lda temp+0
beq :+ ; make sure we don't dec page count below zero
dec temp+0
:
clc ; advance the dma
lda temp+3
adc #2
sta temp+3
tax
lda #0
jsr d_setdma
bra @lp ; write next 2 pages
@error:
jsr printi
.byte 10,13,"ERROR WRITING DATA TO DISK",10,13,0
lda #1
clc
rts
@exit:
; update FCB with number of sectors written
lda temp+2
sta fcb+sfcb::SC
; save the TPA address to LOAD and EXECUTE
lda #<TPA
sta fcb+sfcb::L1
sta fcb+sfcb::E1
lda #>TPA
sta fcb+sfcb::L2
sta fcb+sfcb::E2
; save the size (sector count * 512)
lda temp+2
sta fcb+sfcb::S0
; x 512 This works because S0, S1 and S2 are all initialised to zero by make.
ldx #9
clc
: asl fcb+sfcb::S0 ;x512
rol fcb+sfcb::S1
rol fcb+sfcb::S2
dex
bne :-
; set attribute
lda #<fcb
ldx #>fcb
jsr d_close
bcc :+
jsr printi
.byte 10,13,"ERROR CLOSING FILE",10,13,0
lda #1
clc
rts
: jsr printi
.byte 10,13,"SAVED ",0
lda fcb + sfcb::SC
jsr bios_prbyte
jsr printi
.byte " SECTORS",10,13,0
rts
quit:
jmp $CF4D
;
; ---- Helper functions ------------------------------------------------------
s_reset:
ldy #esfos::sfos_s_reset
jmp sfos_entry
d_getsetdrive:
ldy #esfos::sfos_d_getsetdrive
jmp sfos_entry
c_write:
ldy #esfos::sfos_c_write
jmp sfos_entry
c_read:
ldy #esfos::sfos_c_read
jmp sfos_entry
c_printstr:
ldy #esfos::sfos_c_printstr
jmp sfos_entry
c_readstr:
ldy #esfos::sfos_c_readstr
jmp sfos_entry
d_setdma:
ldy #esfos::sfos_d_setdma
jmp sfos_entry
d_parsefcb:
ldy #esfos::sfos_d_parsefcb
jmp sfos_entry
d_findfirst:
ldy #esfos::sfos_d_findfirst
jmp sfos_entry
d_findnext:
ldy #esfos::sfos_d_findnext
jmp sfos_entry
d_open:
ldy #esfos::sfos_d_open
jmp sfos_entry
d_close:
ldy #esfos::sfos_d_close
jmp sfos_entry
d_readseqblock:
ldy #esfos::sfos_d_readseqblock
jmp sfos_entry
d_writeseqblock:
ldy #esfos::sfos_d_writeseqblock
jmp sfos_entry
d_make:
ldy #esfos::sfos_d_make
jmp sfos_entry
d_setlba:
ldy #esfos::sfos_d_setlba
jmp sfos_entry
d_readrawblock:
ldy #esfos::sfos_d_readrawblock
jmp sfos_entry
d_writerawblock:
ldy #esfos::sfos_d_writerawblock
jmp sfos_entry
s_settpa:
ldy #esfos::sfos_s_settpa
jmp sfos_entry
s_gettpa:
ldy #esfos::sfos_s_gettpa
jmp sfos_entry
; ---- local helper functions ------------------------------------------------
; parse an 8-bit decimal number from the command line. David Given - cpm65
parse_number:
; we use the current commandoffset
stz temp+0
lda cmdoffset+0
sta debug_ptr+0
lda cmdoffset+1
sta debug_ptr+1
ldy #0
@loop:
lda (debug_ptr),y
beq @exit
cmp #' '
beq @exit
cmp #'0'
bcc @parse_error
cmp #'9'+1
bcs @parse_error
sec
sbc #'0'
tax
lda temp+0
asl
sta temp+0
asl
asl
clc
adc temp+0
sta temp+0
txa
clc
adc temp+0
sta temp+0
iny
bra @loop
@parse_error:
sec
rts
@exit:
lda temp+0
clc
rts
; restore old drive after disk activity
restore_active_drive:
lda fcb2
bne :+
rts
: lda saved_active_drive
sta active_drive
ldx #0
jmp d_getsetdrive
set_user_drive:
lda fcb2
bne :+
rts
: pha
lda active_drive
sta saved_active_drive
pla
sta active_drive
ldx #0
jmp d_getsetdrive
jsr printi
.byte 13,10,"FCB2: ",0
lda fcb2
clc
adc #'A'-1
jsr bios_conout
lda #':'
jsr bios_conout
ldx #1
: lda fcb2,x
jsr bios_conout
inx
cpx #sfcb::T3+1
bne :-
rts
clear_commandline:
ldx #0
lda #0
: sta commandline,x
inx
bpl :-
rts
clear_fcb:
ldx #31
lda #0
: sta fcb,x
dex
bpl :-
rts
clear_fcb2:
ldx #31
lda #0
: sta fcb2,x
dex
bpl :-
rts
; Does not let you filter DIRECTORIES.
make_dir_fcb:
ldx #sfcb::N1
lda #'?'
:
sta fcb, x
inx
cpx #(sfcb::T3 + 1)
bne :-
lda fcb2
beq :+
sta fcb
: rts
print_drive_colon:
lda #<str_tab
ldx #>str_tab
jsr c_printstr
lda active_drive
clc
adc #'A'-1
jsr c_write
lda #':'
jsr c_write
lda #' '
jsr c_write
rts
; used by DIR
print_fcb:
lda fcb+sfcb::N1
cmp #' '
bne :+
rts
: dec temp
lda temp
bne :+
jsr newline
lda #4
sta temp
jsr print_drive_colon
: ldx #sfcb::N1
: lda fcb,x
jsr c_write
inx
cpx #(sfcb::N8+1)
bne :-
lda #' '
jsr c_write
: lda fcb,x
jsr c_write
inx
cpx #(sfcb::T3+1)
bne :-
rts
show_prompt:
lda #$ff
jsr d_getsetdrive
clc
adc #'A' - 1
jsr c_write
lda #'>'
jmp c_write
newline:
lda #<str_newline
ldx #>str_newline
jmp c_printstr
; debug helper
printi:
pla
sta debug_ptr
pla
sta debug_ptr+1
bra @primm3
@primm2:
jsr bios_conout
@primm3:
inc debug_ptr
bne @primm4
inc debug_ptr+1
@primm4:
lda (debug_ptr)
bne @primm2
lda debug_ptr+1
pha
lda debug_ptr
pha
rts
print_word:
pha
txa
jsr bios_prbyte
pla
jsr bios_prbyte
rts
.bss
commandline: .res 128
fcb: .res 32
fcb2: .res 32
cmdoffset: .word 0
temp: .res 4,0
active_drive: .byte 0
saved_active_drive: .byte 0
submit_fcb: .res 32,0
.rodata
str_newline: .byte 13, 10, 0
str_banner: .byte 13,10, "6502-Retro! (SFCP)",0
str_COM: .byte "COM"
str_tab: .byte " ",0
str_sep: .byte " : ",0
str_submit_fcb: .byte 0, "$$$ SUB"
.res 20,0
str_help: .byte 10,13
.byte 10,13,"BANK <#> Enter a rom bank number from 1 to 3"
.byte 10,13,"DIR [A:] Enter a drive number to list files"
.byte 10,13,"ERA [A:]FILENAME Delete a file"
.byte 10,13,"FREE Display memory information"
.byte 10,13,"REN SRC DST Rename a file from SRC to DST in current drive"
.byte 10,13,"SAVE FILENAME ## Save ## pages of memory starting at TPA to a file"
.byte 10,13,"TYPE [A:]FILENAME Display ascii contents of a file"
.byte 10,13,0
commands_tbl:
.byte "BANK",$80
.lobytes bank
.hibytes bank
.byte "DIR ",$80
.lobytes dir
.hibytes dir
.byte "ERA ",$80
.lobytes era
.hibytes era
.byte "FREE",$80
.lobytes free
.hibytes free
.byte "HELP",$80
.lobytes help
.hibytes help
.byte "QUIT",$80
.lobytes quit
.hibytes quit
.byte "REN ",$80
.lobytes ren
.hibytes ren
.byte "TYPE",$80
.lobytes type
.hibytes type
.byte "SAVE",$80
.lobytes save
.hibytes save
.byte 0
|
6502-retro/6502-retro-os
| 25,158
|
sfos/sfos.s
|
; vim: ft=asm_ca65 ts=4 sw=4
.include "fcb.inc"
.include "io.inc"
.include "errors.inc"
.include "bios.inc"
.autoimport
.export sfos_buf, sfos_s_reset, dispatch
.zeropage
cmd: .word 0
param: .word 0
user_dma: .word 0
zptemp0: .word 0
zptemp1: .word 0
zptemp2: .word 0
zpbufptr: .word 0
.code
; reset with warm boot and log into drive A
sfos_s_reset:
lda #1
jsr internal_getsetdrive
jmp main
; read a char from the serial console
; echo it too
sfos_c_read:
jsr bios_conin ; read from serial terminal
pha ; stash it
jsr internal_c_write ; echo it to the terminal
pla ; pop it
rts
; send a char to the serial console and check for CTRL + C
sfos_c_write:
lda param + 0
internal_c_write:
;jsr to_upper
jsr bios_conout
jsr bios_const
beq @exit
cmp #$03 ; we do a quick ^C check here and perform a soft
bne @exit ; boot if we find one.
jmp sfos_s_reset
@exit:
rts
; check if there is a character waiting in the bios. If there is return it
; else return 0 in A
sfos_c_status:
jmp bios_const
; print a null terminated string pointed to by XA to the serial console.
sfos_c_printstr:
@L1:
lda (param)
beq @exit ; we use null termination 'round 'ere
jsr internal_c_write
inc param + 0
bne @L1
inc param + 1
bra @L1
@exit:
rts
; reads a line of text from the serial console into the commandline buffer
sfos_c_readstr:
lda (param)
cmp #$80
bcc :+ ; max commandline length is 128
lda #$80
: sta cmdlen
ldy #1
@L1:
jsr bios_conin
cmp #3
beq @done
cmp #10
beq @enter
cmp #13
beq @enter
cmp #$08
beq @backspace
sta (param),y
jsr bios_conout
iny
cpy cmdlen
bne @L1
@done:
iny
lda #0
sta (param),y
tya
sta (param) ; overwrite the commandline length with the
rts ; actual commandline length entered.
@enter:
lda #0
sta (param),y
bra @done
@backspace:
cpy #1
beq @L1
dey
jsr bios_conout
lda #' '
jsr bios_conout
lda #$08
jsr bios_conout
bra @L1
; ----------------------------------------------------------------------------
; ---- DRIVE ACTIVITIES ------------------------------------------------------
; ----------------------------------------------------------------------------
get_drvtbl_idx:
lda drive
dec
asl
rts
get_drvmax:
jsr get_drvtbl_idx
tax
lda drvtbl + drvalloc::maxdrv
rts
; A=0xFF forces new scan of drive, else check if already logged in
; if yes, then return else scan drive.
login_drive:
cmp #$FF
beq :+
jsr get_drvtbl_idx
tax
stx cmd ; using cmd temporarily for this
lda drvtbl + drvalloc::is_logged_in,x
bne @exit
:
;lda #<str_scanning
;ldx #>str_scanning
;jsr bios_puts
jsr compute_drive_index_lba
@sector_lp:
jsr internal_setdma
jsr internal_readblock ; read 1 index block
lda user_dma+0
sta zptemp0+0
lda user_dma+1
sta zptemp0+1
@dirent_loop:
ldy #sfcb::FA
lda (zptemp0),y
cmp #$E5
beq @next_dirent
ldx cmd
inc drvtbl + drvalloc::maxdrv,x
@next_dirent:
clc
lda zptemp0+0
adc #32
sta zptemp0+0
lda zptemp0+1
adc #0
sta zptemp0+1
cmp #>sfos_buf + 2
bne @dirent_loop
lda lba+0
and #$0F
bne @sector_lp
ldx cmd
lda #1
sta drvtbl + drvalloc::is_logged_in,x
@exit:
rts
; Gets or sets the current drive. When the current drive changes, we set LBA
sfos_d_getsetdrive:
lda param + 0
internal_getsetdrive:
cmp #$FF
bne @L1
lda drive ; return the drive
bra @exit
@L1:
cmp #1
bcc @out_of_range
cmp #(8+1)
bcs @out_of_range
cmp drive
beq @exit
; drive is different
sta drive
lda #$00 ; don't force scan
jsr login_drive
@exit:
sta error_code
clc
rts
@out_of_range:
lda #ERROR::DRIVE_ERROR
sta error_code
sec
rts
compute_drive_index_lba:
lda drive ; set the LBA to the begining of the drives indexes
dec
asl
asl
asl
asl
ora #$80
sta lba+0
stz lba+1
stz lba+2
stz lba+3
rts
; Reset the dirpos and ztemp ptr into user_dma
home_drive:
jsr compute_drive_index_lba
lda #0
sta current_filenum
sta current_dirpos
; user_dma is already defined by the caller.
jsr internal_readblock ;read first block
lda user_dma+0
sta zptemp1+0
lda user_dma+1
sta zptemp1+1
rts
; ----------------------------------------------------------------------------
; ---- FCB ACTIVITIES --------------------------------------------------------
; ----------------------------------------------------------------------------
; the user_dma pointer points to the fcb memory
; param points to the commandline
; returns with the fcb filled out and XA pointing at the updated location
; in the commandline.
; BORROWED FROM CPM65 By David Given (https://github.com/davidgiven/cpm65)
sfos_d_parsefcb:
; param -> commandline (filename)
; dma -> FCB
stz zptemp0 ; failure flag
; check the drive
ldy #0
ldx #0
lda (param),y ; drive letter?
beq @nodrive
iny
lda (param),y
dey
cmp #':' ; colon?
bne @nodrive
lda (param),y
jsr to_upper
sec
sbc #'A'-1 ; to 1 based drive
cmp #1
bcs :+
cmp #9
bcc :+
dec zptemp0
:
tax
iny
iny
@nodrive:
txa
bne :+
lda drive ; pop in the current drive if one was not given.
: pha ; drive letter pushed to stack
; Read the filename
ldx #8
@L1:
lda (param),y ; get a character
jsr to_upper
jsr is_terminator_char
bcc :+ ; if carry set
lda #' '
dey
: cmp #'*'
bne :+ ; if a star
lda #'?'
dey
: pha
iny
dex
bne @L1
; skip non-dot fiename characters.
lda (param),y
@L2:
cmp #'.'
beq :++
jsr is_terminator_char
bcc :+ ; if carry set do the below.
lda #' ' ; filename has no extension
pha
pha
pha
bra @parse_filename_exit
: iny
lda (param),y
bra @L2
; read the extension
: iny
ldx #3
@L3:
lda (param),y ; get a character
jsr to_upper
jsr is_terminator_char
bcc :+ ; if carry set do the below
lda #' '
dey
: cmp #'*'
bne :+
lda #'?'
dey
: pha
iny
dex
bne @L3
; discard remaining filename characters
lda (param),y
@L4:
jsr is_terminator_char
bcs @parse_filename_exit
iny
lda (param),y
bne @L4
@parse_filename_exit:
; push the 4 zeros for L1, L2, SC, FN
lda #0
pha
pha
pha
pha
; copy the generated bytes from the stack into the destination
tya
tax
ldy #15
@L5:
pla
sta (user_dma),y ; user_dma -> fcb
dey
bpl @L5
txa
clc
adc param+0 ; param -> commandline
ldx param+1
bcc :+ ; did we rollover on the adc above?
inx ; XA points to first char after space
: clc ;
ldy zptemp0 ; was there a failure?
beq :+
lda #ERROR::PARSE_ERROR ; return parse error or XA.
sta error_code
ldx #0
sec
: rts
is_terminator_char:
stx zptemp2
ldx #(terminators_end - terminators) - 1
: cmp terminators, x ; sets carry if equal
beq :+
dex
bpl :-
clc
: ldx zptemp2
rts
; ----------------------------------------------------------------------------
; ---- DIRECTORY ACTIVITIES --------------------------------------------------
; ----------------------------------------------------------------------------
; searches the currently selelcted drive for a file matching the name in the provided FCB
; if one is found it returns it.
; on entry: Param points to FCB
sfos_d_findfirst:
jsr internal_setdma
jsr home_drive
bcc :+
lda #ERROR::DRIVE_ERROR
sta error_code
sec
rts
: jsr read_directory_entry
; fall through
; On entry, param points to an FCB.
; On entry a directory has been read by a previous call to findnext or findfirst.
; current_dirent contains the current directory entry being checked against the FCB
; pointed to by the param.
; any `?` chars in the filename or the extension will be skipped on char matching.
; keep track of the following details:
; - sector lba
; - current_directory_pos
sfos_d_findnext:
lda drive
cmp current_dirent + sfcb::DD
beq :+
lda #ERROR::FILE_NOT_FOUND
sta error_code
sec
rts
: lda current_dirent + sfcb::FA
cmp #$E5
bne :+
; first, is the caller looking for deleted files?
ldy #sfcb::DD
lda (param),y
cmp #$E5
beq @matched
; next, is the filenum of this deleted file more than maxdrv
jsr get_drvtbl_idx
tax
lda drvtbl + drvalloc::maxdrv,x
cmp current_dirent + sfcb::FN
bcs @nomatch
lda #ERROR::FILE_NOT_FOUND
sta error_code
sec
rts
: ldy #sfcb::N1
: lda (param),y ; load char from record we retreived from user
cmp #'?'
beq :+ ; skip comparing question marks
cmp current_dirent,y ; compare with the record from the sector on disk
bne @nomatch
: iny
cpy #sfcb::T3 + 1
bne :--
@matched:
ldy #31
: lda current_dirent,y
sta (param),y
dey
bpl:-
jsr read_directory_entry ; for next time (if there's a next time)
bcc :+
rts
: lda #$FF
clc
lda #ERROR::OK
sta error_code
rts
@nomatch:
; we have to check the next directory entry.
jsr read_directory_entry
bcc sfos_d_findnext
rts
; reads the directory entry, loads the next sector from disk if needed
read_directory_entry:
lda current_dirpos ; use the current dirpos to calculate the offset
asl ; into the 512byte user_dma.
asl
asl
asl
asl ; x 32
tay
ldx #0 ; index into current_dirent
: lda (zptemp1),y ; copy the directory entry into current_dirent
sta current_dirent,x
iny
inx
cpx #32
bne :-
inc current_dirpos ; increment the current_dirpos and check for end
lda current_dirpos ; the end of the current directory sector
cmp #8
beq @second_half
cmp #16 ; do we need to load a new block into the buffer
beq @next_block
clc
rts
@second_half: ; Once we get to 8 dirents, we need to increment
inc zptemp1+1 ; the high byte of the pointer into the buffer.
clc
rts
@next_block:
jsr internal_readblock ; if it was the end of the sector, load the next
bcc :+
lda #ERROR::DRIVE_ERROR
sta error_code
sec
rts
: stz current_dirpos ; sector and reset current_dirpos.
lda user_dma+0
sta zptemp1+0
lda user_dma+1
sta zptemp1+1
rts
; given an fcb pointed by param, find the file and set the DMA address.
sfos_d_open:
ldy #sfcb::DD
lda (param),y
beq :+ ; if the drive is provided, then switch to that drive
jsr internal_getsetdrive
bcc :+ ; allow for drive error from internal getsetdrive.
rts
:
jsr sfos_d_findfirst ; sets internal dma already
bcc :+
rts
; set the dma address
: ldy #sfcb::L1
lda (param),y
sta user_dma+0
pha
ldy #sfcb::L2
lda (param),y
sta user_dma+1
tax
pla
jsr bios_setdma ; sets the bios dma for sdcard ops.
; initialize the Current Record to 0.
ldy #sfcb::CR
lda #0
sta (param),y
; save the filesize in fsize
ldy #sfcb::S0
lda (param),y
sta fsize+0
ldy #sfcb::S1
lda (param),y
sta fsize+1
ldy #sfcb::S2
lda (param),y
sta fsize+2
lda #ERROR::OK
sta error_code
clc
rts
; param points to FCB that needs to be closed.
sfos_d_close:
; do we have a dirty sector to write before we close?
ldy #sfcb::DS
lda (param),y
beq @close
lda user_dma+0
ldx user_dma+1
jsr bios_setdma
jsr sfos_d_writeseqblock
bcc @update_fcb
rts ; return with error from write sequential block
@update_fcb:
ldy #sfcb::SC
lda (param),y
inc
sta (param),y
ldy #sfcb::S0 ; update the FCB filesize
lda fsize+0
sta (param),y
iny
lda fsize+1
sta (param),y
iny
lda fsize+2
sta (param),y
@close:
jsr compute_drive_index_lba ; lba is set
ldy #sfcb::FN
lda (param),y
lsr ;/2
lsr ;/4
lsr ;/8
lsr ;/16
clc ; add to lba+0 for sector conaining file dirent
adc lba+0
sta lba+0
lda #<lba
ldx #>lba
jsr bios_setlba
; now read the index sector into the sfos_buf
lda #<sfos_buf
ldx #>sfos_buf
jsr bios_setdma
jsr bios_sdread ; not calling internal_readblock because we don't
bcs @error ; want the LBA incremented here.
; now insert the fcb into the sector
ldy #sfcb::FN
lda (param),y
and #$0F ; mod 16
ldx #5 ; x 32
: asl
dex
bne :-
tax ; x holds position in the buffer.
ldy #sfcb::FN
lda (param),y
ldy #0
and #$0F
cmp #$8 ; when the filenum is > 80 we must insert
bcs @upper ; the fcb into thesecond half of the 512byte sector.
: lda (param),y ; copy fcb to lower half of sector
sta sfos_buf,x
inx
iny
cpy #32
bne :-
bra @flush
@upper: ; copy fcb to upper half of sector.
: lda (param),y
sta sfos_buf+256,x
inx
iny
cpy #32
bne :-
@flush:
lda #<sfos_buf ; there is no internal writeblock like there is an
ldx #>sfos_buf ; internal readlbock. Because this is the only time
jsr bios_setdma ; that function is needed. So it's inlined here.
lda #<lba
ldx #>lba
jsr bios_setlba
jsr bios_sdwrite
bcc @exit
@error:
lda #ERROR::DRIVE_ERROR
sta error_code
rts
@exit:
lda #$FF ; force drive scan
jsr login_drive
lda #ERROR::OK
sta error_code
clc
rts
; param points to FCB containing filename to create.
; Returns updated FCB containing Drive, FN and CR
; Reuses current_dirent to stash the incomming fcb so the filename can be
; extracted and restored over the new FCB found.
sfos_d_make:
; stash dirent.
ldy #31
:
lda (param),y
sta temp_fcb,y
dey
bpl :-
jsr sfos_d_findfirst
bcs :+
lda #ERROR::FILE_EXISTS
sta error_code
sec
rts
: ; file does not exist or drive error
cmp #ERROR::DRIVE_ERROR
sta error_code
bne :+
sec
rts
: ldy #sfcb::DD ; tell find first to return an empty slot
lda #$E5
sta (param),y
jsr sfos_d_findfirst
bcc @allocate
cmp #ERROR::END_OF_DIR
; BUG: We do nothing with this comparrison.
sta error_code
bne :+
lda #ERROR::DRIVE_FULL
sta error_code
sec
rts
: lda #ERROR::DRIVE_ERROR
sta error_code
sec
rts
@allocate:
; allocate dirent by setting file attribute to 0x40
lda #$40
ldy #sfcb::FA
sta (param),y
ldy #sfcb::CR
lda #0
sta (param),y
; fill in details from the current dirent.
ldy #sfcb::SC
lda temp_fcb,y
sta (param),y
ldy #sfcb::L1
lda temp_fcb,y
sta (param),y
iny
lda temp_fcb,y
sta (param),y
ldy #sfcb::E1
:
lda temp_fcb,y
sta (param),y
iny
cpy #sfcb::S2 + 1
bne :-
ldy #12
: lda temp_fcb,y
sta (param),y
dey
bne :-
ldy #sfcb::DS
lda #0
sta (param),y
stz fsize+0
stz fsize+1
stz fsize+2
stz fsize+3
lda #ERROR::OK
sta error_code
clc
rts
; ----------------------------------------------------------------------------
; ---- SYSTEM / DISK FUNCTIONS -----------------------------------------------
; ----------------------------------------------------------------------------
; also sets zpbufptr for read and write byte operations
sfos_d_setdma:
lda param + 0
sta user_dma + 0
sta zpbufptr + 0
ldx param + 1
stx user_dma + 1
stx zpbufptr + 1
jmp bios_setdma
; XA is a pointer to the 32bit word containing the LBA address
sfos_d_setlba:
lda param + 0
ldx param + 1
jmp bios_setlba
; These internal read and write block functions assume a previously set LBA and DMA
; and do update the LBA on completion.
internal_readblock:
lda #<lba
ldx #>lba
jsr bios_setlba
jsr bios_sdread
bcc :+
lda #ERROR::DRIVE_ERROR
sta error_code
rts
: inc lba + 0
rts
; Given the FCB passed in param, the LBA is determined from the DRIVE + CR
; fields and the block is read into the current DMA address.
; On completion, the FCB CR field is updated to the next record.
sfos_d_readseqblock:
jsr set_fcb_lba
jsr bios_sdread
bcs sd_op_fail
jmp increment_fcb_cr
sd_op_fail:
lda #ERROR::DRIVE_ERROR
sta error_code
rts
sfos_d_writeseqblock:
jsr set_fcb_lba
jsr bios_sdwrite
bcs sd_op_fail
jmp increment_fcb_cr ; carry is set if rollover
set_fcb_lba:
stz lba + 3
ldy #sfcb::DD
lda (param),y
sta lba + 2
ldy #sfcb::FN
lda (param),y
sta lba + 1
ldy #sfcb::CR
lda (param),y
sta lba + 0
lda #<lba
ldx #>lba
jsr bios_setlba
rts
increment_fcb_cr:
ldy #sfcb::CR
lda (param),y
inc
beq :+ ; have we gone past the end of MAX FILESIZE
sta (param),y
clc
lda #ERROR::OK
sta error_code
rts
: lda #ERROR::FILE_MAX_REACHED
sta error_code
sec
rts
; input param = FCB
; The first block must have already been read in by the caller.
; Returns the next byte from the buffer.
; When the last buffer is read, stash it, load the next sector into the buffer
; and return the stashed byte.
; Buffer is at the current DMA address.
; pointer to current byte is in zpbufptr
; we need to know if we have read the final byte of the file.
; do this by decrementing the size inside the FCB. When that gets to zero we
; are done.
sfos_d_readseqbyte:
lda (zpbufptr) ; get the byte pointed to by zpbufptr
pha ; stash it
inc zpbufptr+0 ; increment buffer pointer
bne :+
inc zpbufptr+1
: ldx user_dma+1
inx
inx
cpx zpbufptr+1
bne @return
lda user_dma+0 ; reset the buffer pointer. Ready for the next
sta zpbufptr+0 ; byte
ldx user_dma+1
stx zpbufptr+1
jsr bios_setdma ; set dma pointer in bios
jsr sfos_d_readseqblock ; read the new sector
bcc @return ; if OKAY carry on, otherwise return with carry set.
; reutrn the error from readseqblock - error_code already populated.
rts
@return:
; decrement the remaining size (24 bit decrement)
lda fsize+0
bne @dec_ones
lda fsize+1
bne @dec_tens
lda fsize+2
@dec_hundreds:
dec fsize+2
@dec_tens:
dec fsize+1
@dec_ones:
dec fsize+0
lda fsize+0 ; 24bit check for zero
ora fsize+1
ora fsize+2
beq @exit
@ok: ; Return the value not the ERROR CODE.
pla ; retreive the stashed byte
clc ; return okay.
rts
@exit: ; we have reached zero bytes in the FCB
sec
lda #ERROR::FILE_EOF ; it's not an error so populate error_code with OK
sta error_code
pla ; We still return the stashed byte.
rts ; caller has to check error_code
; input param = FCB requires buffer DMA to be pre-assigned.
; wirtes to the buffer, fills up and when full, writes the buffer to disk.
; errors out when file max is reached.
sfos_d_writeseqbyte:
lda rega
sta (zpbufptr)
ldy #sfcb::DS
lda #1
sta (param),y
inc zpbufptr + 0
bne @incsize
inc zpbufptr + 1
lda zpbufptr + 1
cmp #>sfos_buf_end ; XXX: this is NOT what was implied by the call to setdma!!!!
bne @incsize
lda user_dma+0 ; reset the buffer pointer. Ready for the next
sta zpbufptr+0 ; byte
ldx user_dma+1
stx zpbufptr+1
jsr bios_setdma ; set dma pointer in bios
jsr sfos_d_writeseqblock
ldy #sfcb::SC
lda (param),y
inc
sta (param),y
ldy #sfcb::DS
lda #0
sta (param),y
jsr clear_internal_buffer ; XXX : also NOT what was implied by the call to setdma!!!
@incsize:
clc
lda fsize + 0
adc #1
sta fsize + 0
lda fsize + 1
adc #0
sta fsize + 1
lda fsize + 2
adc #0
sta fsize + 2
@exit:
lda $FF
clc
rts
; DMA is set already, LBA is set already, do not increment LBA
; Convert carry to clear on success, set on failure
sfos_d_writerawblock:
jmp bios_sdwrite
sfos_d_readrawblock:
jmp bios_sdread
; given the number of pages in A, set tpa to first free block
; of ram. - this will be called by sfcp when it's done loading
; an application into the TPA. It will pass in the pages used.
sfos_s_settpa:
lda param+0
sta tpa
clc
rts
; return the tpa in pages.
sfos_s_gettpa:
lda tpa
ldx #0
clc
rts
; sets the dma to the sfos_buf
internal_setdma:
lda #<sfos_buf
sta user_dma + 0
sta zpbufptr + 0
ldx #>sfos_buf
stx user_dma + 1
stx zpbufptr + 1
jmp bios_setdma
dispatch:
sta param + 0
stx param + 1
lda sfos_jmp_tbl_hi,y
sta cmd + 1
lda sfos_jmp_tbl_lo,y
sta cmd + 0
jmp (cmd)
; ----------------------------------------------------------------------------
; ---- UNIMPLIMENTED FUNCTIONS -----------------------------------------------
; ----------------------------------------------------------------------------
sfos_d_createfcb:
jmp unimplimented
; ----------------------------------------------------------------------------
; ---- HELPER FUNCTIONS ------------------------------------------------------
; ----------------------------------------------------------------------------
clear_internal_buffer:
lda #0
ldy #0
: sta sfos_buf+0,y
iny
bne :-
: sta sfos_buf+256,y
iny
bne :-
rts
unimplimented:
lda #<str_unimplimented
ldx #>str_unimplimented
jsr bios_puts
sec
rts
; converts a characater to upper case
to_upper:
cmp #'a'
bcc @done
cmp #'z' + 1
bcs @done
and #$DF
@done:
rts
.bss
.align $100
sfos_buf: .res 512
sfos_buf_end:
drive: .res 1
current_filenum:.res 1
current_dirent: .res 32
current_dirpos: .res 1
drvtbl: .res 16
lba: .res 4
cmdlen: .res 1
temp_fcb: .res 32
fsize: .res 2
tpa: .res 1
.rodata
sfos_jmp_tbl_lo:
.lobytes sfos_s_reset
.lobytes sfos_c_read
.lobytes sfos_c_write
.lobytes sfos_c_printstr
.lobytes sfos_c_readstr
.lobytes sfos_c_status
.lobytes sfos_d_getsetdrive
.lobytes sfos_d_createfcb
.lobytes sfos_d_parsefcb
.lobytes sfos_d_findfirst
.lobytes sfos_d_findnext
.lobytes sfos_d_make
.lobytes sfos_d_open
.lobytes sfos_d_close
.lobytes sfos_d_setdma
.lobytes sfos_d_readseqblock
.lobytes sfos_d_writeseqblock
.lobytes sfos_d_readseqbyte
.lobytes sfos_d_writeseqbyte
.lobytes sfos_d_setlba
.lobytes sfos_d_readrawblock
.lobytes sfos_d_writerawblock
.lobytes sfos_s_settpa
.lobytes sfos_s_gettpa
sfos_jmp_tbl_hi:
.hibytes sfos_s_reset
.hibytes sfos_c_read
.hibytes sfos_c_write
.hibytes sfos_c_printstr
.hibytes sfos_c_readstr
.hibytes sfos_c_status
.hibytes sfos_d_getsetdrive
.hibytes sfos_d_createfcb
.hibytes sfos_d_parsefcb
.hibytes sfos_d_findfirst
.hibytes sfos_d_findnext
.hibytes sfos_d_make
.hibytes sfos_d_open
.hibytes sfos_d_close
.hibytes sfos_d_setdma
.hibytes sfos_d_readseqblock
.hibytes sfos_d_writeseqblock
.hibytes sfos_d_readseqbyte
.hibytes sfos_d_writeseqbyte
.hibytes sfos_d_setlba
.hibytes sfos_d_readrawblock
.hibytes sfos_d_writerawblock
.hibytes sfos_s_settpa
.hibytes sfos_s_gettpa
banner: .byte "6502-Retro! (SFOS)", 13, 10, 0
str_unimplimented: .byte 13, 10, "!!! UNIMPLIMENTED !!!", 13, 10, 0
str_badfilename: .byte 13, 10, "BAD FILENAME", 13,10,0
str_COM: .byte "COM"
str_scanning: .byte 10,13,"Scanning drive...",10,13, 0
terminators:
.byte " =><.:,[]/|"
.byte 10,13,127,9,0
terminators_end:
|
6502-retro/6502-retro-os
| 1,459
|
apps/shadowrom/main.s
|
; vim: ft=asm_ca65 ts=4 sw=4 et
.include "io.inc"
.macro pp addr
lda #<addr
ldx #>addr
jsr printl
.endmacro
ROM_BASE = $e000
HIGHRAM = $c000
.zeropage
src: .word 0
dst: .word 0
ptr: .word 0
.code
main:
sei
pp msg1
lda #<ROM_BASE
sta src + 0
lda #>ROM_BASE
sta src + 1
lda #<HIGHRAM
sta dst + 0
lda #>HIGHRAM
sta dst + 1
lp1:
lda (src)
sta (dst)
inc src+0
inc dst+0
bne lp1
pp msg5
inc dst+1
inc src+1
bne lp1
pp msg2
lda via_porta
and #%10111111
sta via_porta
lda via_ddra
ora #%01000000
sta via_ddra
pp msg3
lda #<HIGHRAM
sta src + 0
lda #>HIGHRAM
sta src + 1
lda #<ROM_BASE
sta dst + 0
lda #>ROM_BASE
sta dst + 1
lp2:
lda (src)
sta (dst)
inc src+0
inc dst+0
bne lp2
pp msg5
inc src+1
inc dst+1
bne lp2
cli
pp msg4
rts
printl:
sta ptr+0
stx ptr+1
ldy #0
: lda (ptr),y
beq :+
iny
jsr putc
bra :-
: rts
putc:
pha ; save char
@wait_txd_empty:
lda acia_status
and #$10
beq @wait_txd_empty
pla ; restore char
sta acia_data
rts
msg1: .byte 10,13,"copy rom to lowram ...", 10,13,0
msg2: .byte 10,13,"disable rom...",10,13,0
msg3: .byte 10,10,"copy from lowram to highram...",10,13,0
msg4: .byte 10,13,"done",10,13,0
msg5: .byte ".",0
|
6502-retro/6502-retro-os
| 9,289
|
apps/uart/main.s
|
; vim: ft=asm_ca65 sw=4 ts=4 et
.include "fcb.inc"
.include "io.inc"
acia_tx_irq = 1 ; using R6551 UART. Set to 0 if using WDC65C51
__ACIA_START__ = acia_data
ACIA_DATA = __ACIA_START__ + $00
ACIA_STATUS = __ACIA_START__ + $01
ACIA_COMMAND = __ACIA_START__ + $02
ACIA_CONTROL = __ACIA_START__ + $03
ACIA_STOP_BITS_1 = %00000000
ACIA_STOP_BITS_2 = %10000000
ACIA_DATA_BITS_8 = %00000000
ACIA_DATA_BITS_7 = %00100000
ACIA_DATA_BITS_6 = %01000000
ACIA_DATA_BITS_5 = %01100000
ACIA_CLOCK_EXT = %00000000
ACIA_CLOCK_INT = %00010000
ACIA_BAUD_16XEXT = %00000000
ACIA_BAUD_50 = %00000001
ACIA_BAUD_75 = %00000010
ACIA_BAUD_109 = %00000011
ACIA_BAUD_134 = %00000100
ACIA_BAUD_150 = %00000101
ACIA_BAUD_300 = %00000110
ACIA_BAUD_600 = %00000111
ACIA_BAUD_1200 = %00001000
ACIA_BAUD_1800 = %00001001
ACIA_BAUD_2400 = %00001010
ACIA_BAUD_3600 = %00001011
ACIA_BAUD_4800 = %00001100
ACIA_BAUD_7200 = %00001101
ACIA_BAUD_9600 = %00001110
ACIA_BAUD_19200 = %00001111
;
; ACIA command register bit values
ACIA_PARITY_ODD = %00000000
ACIA_PARITY_EVEN = %01000000
ACIA_PARITY_MARK = %10000000
ACIA_PARITY_SPACE = %11000000
ACIA_PARITY_DISABLE = %00000000
ACIA_PARITY_ENABLE = %00100000
ACIA_ECHO_DISABLE = %00000000
ACIA_ECHO_ENABLE = %00010000
ACIA_TX_INT_DISABLE_RTS_HIGH = %00000000
ACIA_TX_INT_ENABLE_RTS_LOW = %00000100
ACIA_TX_INT_DISABLE_RTS_LOW = %00001000
ACIA_TX_INT_DISABLE_BREAK = %00001100
ACIA_RX_INT_ENABLE = %00000000
ACIA_RX_INT_DISABLE = %00000010
ACIA_DTR_HIGH = %00000000
ACIA_DTR_LOW = %00000001
; ACIA status register bit masks
ACIA_STATUS_IRQ = 1 << 7
ACIA_STATUS_DSR = 1 << 6
ACIA_STATUS_DCD = 1 << 5
ACIA_STATUS_TX_EMPTY = 1 << 4
ACIA_STATUS_RX_FULL = 1 << 3
ACIA_STATUS_OVERRUN = 1 << 2
ACIA_STATUS_FRAME_ERR = 1 << 1
ACIA_STATUS_PARITY_ERR = 1 << 0
ACIA_DATA_AVAILABLE = $01
ACIA_NO_DATA_AVAILABLE = $00
.bss
acia_rx_buffer: .res 256
acia_tx_buffer: .res 256
oldirq: .res 2
.zeropage
ptr1: .res 2
acia_rx_rptr: .res 2
acia_rx_wptr: .res 2
acia_tx_rptr: .res 2
acia_tx_wptr: .res 2
.code
main:
sei
jsr save_old_irq
jsr _acia_init
;
; set up user IRQ
;
lda #<_handle_acia_irq
sta bios_userirq_vec + 0
lda #>_handle_acia_irq
sta bios_userirq_vec + 1
cli
loop:
jsr _acia_read_byte
cmp #$1b
beq end
jsr _acia_write_byte
bra loop
end:
;
; restore old irq vec
;
jsr restore_old_irq
jmp bios_wboot
; POSITIVE C COMPLIANT
_acia_init:
lda #(ACIA_PARITY_DISABLE | ACIA_ECHO_DISABLE | ACIA_TX_INT_DISABLE_RTS_LOW | ACIA_RX_INT_ENABLE | ACIA_DTR_LOW)
sta ACIA_COMMAND
lda #(ACIA_STOP_BITS_1 | ACIA_DATA_BITS_8 | ACIA_CLOCK_INT | ACIA_BAUD_300)
sta ACIA_CONTROL
stz acia_rx_rptr
stz acia_rx_wptr
stz acia_tx_rptr
stz acia_tx_wptr
rts
; TENTATIVE C COMPLIANT
_handle_acia_irq:
; Preserve accumulator and x register
pha
phx
; Load current ACIA status
lda ACIA_STATUS
; Stop processing if only CTS is high
cmp #$80
beq cts_high
; Ignore IRQ bit, we already know
asl
; ignore DSR
asl
; ignore DCD
asl
; Ignore the following code for ACIA chips that don't support TX IRQ (WDC65C51)
.if acia_tx_irq=1
; TX buffer empty
bpl tx_empty_exit
; Preserve accumulator
pha
; Compare TX write and read buffer pointers
ldx acia_tx_rptr
cpx acia_tx_wptr
bne tx_send_character
; Both equal - nothing to send in buffer
lda ACIA_COMMAND
; Disable TX interrupt now until new data sent
and #%11110011
ora #(ACIA_TX_INT_DISABLE_RTS_LOW)
sta ACIA_COMMAND
; Restore value of accumulator (rolled ACIA STATUS)
pla
bra tx_empty_exit
tx_send_character:
; Otherwise, send new character
lda acia_tx_buffer,x
sta ACIA_DATA
; Increase read buffer pointer
inc acia_tx_rptr
; Compare pointers - is there any data
lda acia_tx_rptr
cmp acia_tx_wptr
bne tx_data_left_to_send
; Both equal - nothing to send in buffer
lda ACIA_COMMAND
; Disable TX interrupt now until new data sent
and #%11110011
ora #(ACIA_TX_INT_DISABLE_RTS_LOW)
sta ACIA_COMMAND
; Restore value of accumulator (rolled ACIA STATUS)
tx_data_left_to_send:
pla
tx_empty_exit:
; End of R6551 specific code
.endif
; Test the RX bit now
asl
; Receive buffer full
bpl rx_full_exit
; Preserve accumulator again
pha
; Read byte from RX
lda ACIA_DATA
ldx acia_rx_wptr
; Store in rx buffer
sta acia_rx_buffer,x
; Increase write buffer pointer
inc acia_rx_wptr
; Check for receive buffer overflow condition
lda acia_rx_wptr
sec
sbc acia_rx_rptr
; We have more than 128 characters to service in queue - overflow
cmp #$80
bcc no_rx_overflow
; Raise RTS line to stop inflow
lda ACIA_COMMAND
and #%11110011
; ora #%00000001
sta ACIA_COMMAND
no_rx_overflow:
pla
rx_full_exit:
; Ignore overrun
; Ignore framing error
; Ignore parity error
cts_high:
plx
pla
rts
; POSITIVE C COMPLIANT - return value A
; Check if there is anything to receive and return in A
; 0 - data not available
; 1 - data available
acia_getc_nw:
_acia_is_data_available:
lda acia_rx_wptr
cmp acia_rx_rptr
beq @no_data_found
lda #(ACIA_DATA_AVAILABLE)
sec
rts
@no_data_found:
lda #(ACIA_NO_DATA_AVAILABLE)
clc
rts
; POSITIVE C COMPLIANT
; Return one byte from RX buffer
acia_getc:
_acia_read_byte:
; block until data available
jsr _acia_is_data_available
cmp #(ACIA_NO_DATA_AVAILABLE)
beq _acia_read_byte
; proceed
phx
ldx acia_rx_rptr
lda acia_rx_buffer,x
; Increase read buffer pointer
inc acia_rx_rptr
; Store result in X for a while now
tax
; Check how many characters are to be serviced
lda acia_rx_wptr
sec
sbc acia_rx_rptr
; More than 64 - still overflow
cmp #$40
bcs still_rx_overflow
; Otherwise accept more characters
lda ACIA_COMMAND
and #%11110011
; We might enable the TX empty interrupt without any data to write
; but there is no way of checking it, and the interrupt will
; correct the setting if it should not be enabled
ora #(ACIA_TX_INT_ENABLE_RTS_LOW)
sta ACIA_COMMAND
still_rx_overflow:
; Transfer result back to A
txa
plx
rts
; POSITIVE C COMPLIANT
; Write one byte to TX buffer
; Assume input in accumulator
acia_putc:
_acia_write_byte:
; below code works only for R6551 and compatibles
.if acia_tx_irq=1
; Preserve x register
phx
; Preserve input value
pha
; Check if TX buffer full - if so, keep polling until more space available
@compare_with_read_pointer:
; Load current value of write pointer
lda acia_tx_wptr
sec
sbc acia_tx_rptr
cmp #$ff
beq @compare_with_read_pointer
; Restore input value
pla
; Write data to the TX buffer
ldx acia_tx_wptr
sta acia_tx_buffer,x
; Increase pointer
inc acia_tx_wptr
; Enable interrupt after tx buffer is empty
pha
lda ACIA_COMMAND
and #%11110011
ora #(ACIA_TX_INT_ENABLE_RTS_LOW)
sta ACIA_COMMAND
pla
plx
.else
; code below works for non-IRQ compliant devices, like WDC65C51
; store data in data register
sta ACIA_DATA
pha
; wait 1ms (more than 520us for 19200 baud)
lda #$01
jsr _delay_ms
pla
; done, sent
.endif
rts
; POSITIVE C COMPLIANT
; Write null terminated string to TX buffer
; Assume input pointer in A,X
acia_puts:
_acia_write_string:
sta ptr1
stx ptr1+1
; preserve Y register
phy
; init index
ldy #$00
@string_loop:
; load character
lda (ptr1),y
; stop if null
beq @end_loop
; send char to buffer
jsr _acia_write_byte
; increase index
iny
; prevent infinite loop
beq @end_loop
; repeat
bra @string_loop
@end_loop:
; restore Y register
ply
; return
rts
save_old_irq:
lda bios_userirq_vec + 0
sta oldirq + 0
lda bios_userirq_vec + 1
sta oldirq + 1
rts
restore_old_irq:
lda oldirq + 0
sta bios_userirq_vec + 0
lda oldirq + 1
sta bios_userirq_vec + 1
rts
.include "../app.inc"
.rodata
|
6502-retro/6502-retro-os
| 4,934
|
apps/vgm/main.s
|
; vim: ft=asm_ca65 sw=4 ts=4 et
.include "fcb.inc"
.include "io.inc"
.zeropage
vgmptr: .byte 0
vgmptrh: .byte 0
vgmwaitl: .byte 0
vgmwaith: .byte 0
rambank: .byte 0
page: .byte 0
.code
main:
sei
jsr bios_sn_start
lda #<str_message
ldx #>str_message
jsr c_printstr
lda #<str_loading
ldx #>str_loading
jsr c_printstr
jsr vgm_load
jsr vgm_setup
jsr vgm_play
jmp exit
vgm_setup:
stz vgmptr+0
lda #$C0
sta vgmptr+1
ldy #$34
lda (vgmptr),y
clc
adc #$34
tay
rts
vgm_play:
lda (vgmptr),y
cmp #$50
beq @command
cmp #$66
beq @end
cmp #$61
beq @wait
cmp #$63
beq @fiftieth
cmp #$62
beq @sixtieth
and #$F0
cmp #$70
beq @n1
jsr bios_prbyte
lda #'!'
jsr c_write
jmp exit
@command:
jmp command
@wait:
jmp wait
@n1:
jmp n1
@sixtieth:
jmp sixtieth
@fiftieth:
jmp fiftieth
@end:
jmp exit
vgm_next:
iny ; increment the y index into the data pointed to by
bne :+ ; vgmptr and ensure that ram bank boundaries are managed
jsr incvgmptrh
: jmp vgm_play
incvgmptrh:
lda #'.' ; print a '.' every 256 bytes
phy
jsr c_write
ply
inc vgmptr + 1
lda vgmptr + 1
cmp #$E0 ; have we crossed into ROM?
bne :+ ; no - return
inc rambank ; move to next ram bank.
lda rambank
sta rambankreg
nop ; the 74LS273 registers I am using appear to
nop ; need these extra cycles.
lda rambank ; show the new rambank to the user.
jsr bios_prbyte
lda #<str_newline
ldx #>str_newline
jsr c_printstr
lda #$C0 ; reset the vgmptr to the start of the ram
sta vgmptr + 1 ; bank
ldy #0 ; reset y to 0.
: rts
command:
iny
bne :+
jsr incvgmptrh
: lda (vgmptr),y
jsr bios_sn_send
jmp vgm_next
wait: ; get the next two bytes taking care to account
iny ; for crossing to the next ram bank. These form
bne :+ ; the 16 bit wide number of samples to wait for.
jsr incvgmptrh
: lda (vgmptr),y
sta vgmwaitl
iny
bne :+
jsr incvgmptrh
: lda (vgmptr),y
sta vgmwaith ; once the vgmwait word has the number of samples
jsr vgmwait ; to wait for, go ahead and perform the wait.
jmp vgm_next
n1: ; this special case, meand wait for up to 15 sample
lda (vgmptr),y ; periods
cmp #$70
beq :+
and #$0f
sta vgmwaitl
stz vgmwaith
jsr vgmwait
:
jmp vgm_next
fiftieth:
lda #$72
sta vgmwaitl
lda #$03
sta vgmwaith
jsr vgmwait
jmp vgm_next
sixtieth: ; as given by the datasheet wait for exactly 1/60
lda #$df ; of a second.
sta vgmwaitl
lda #$02
sta vgmwaith
jsr vgmwait
jmp vgm_next
; at 4mhz we want 91 clocks for a single sample.
; this works out to 90 clock cycles. which is ~22uS
vgmwait: ; (6) Cycles to prep and execute the jsr
lda vgmwaitl ; (3)
bne @wait_samples_1 ; (2) (could be 3 if branching across page)
lda vgmwaith ; (3)
beq @return ; (2) (could be 3 if branching across page)
dec vgmwaith ; (5) zeropage decrement
@wait_samples_1:
dec vgmwaitl ; (5) zeropage decrement
; kill some cycles between loops. Adjust as required.
.repeat 30
nop ; (2 * 30 = 60)
.endrepeat
jmp vgmwait ; (3) loop = 29 cycles
@return:
rts ; (6) 6 cycles to return
vgm_load:
; the file to play is in FCB2
; so open it and load it into C000->DFFF incrementing bank as you go.
; Once loaded, reset the bank to bank 1
; and return
lda #1
sta rambankreg
sta rambank
lda #$BE ; $C0 -1 because we pre-increment it
sta page
lda #<FCB2
ldx #>FCB2
jsr d_open
@loop:
inc page
inc page
lda page
cmp #$E0
bne :+
inc rambank
lda rambank
sta rambankreg
lda #$C0
sta page
: lda #0
ldx page
jsr d_setdma
lda #<FCB2
ldx #>FCB2
jsr d_readseqblock
bcc @loop
lda #<str_loaded
ldx #>str_loaded
jsr c_printstr
lda FCB2 + sfcb::SC
jsr bios_prbyte
lda #<str_sectors
ldx #>str_sectors
jsr c_printstr
lda #1
sta rambankreg
sta rambank
rts
exit:
lda #0
sta rambankreg
sta rambank
jsr bios_sn_stop
cli
jmp bios_wboot
.include "../app.inc"
.bss
.rodata
str_message: .byte 10,13,"6502-Retro! VGM Player",0
str_loading: .byte 10,13,"Loading file...",0
str_loaded: .byte 10,13,"Loaded 0x",0
str_sectors: .byte " sectors",10,13,0
str_newline: .byte 10,13,0
|
6502-retro/6502-retro-os
| 3,802
|
apps/dump/dump.s
|
; vim: ft=asm_ca65 sw=4 ts=4 et
.include "fcb.inc"
.zeropage
ptr: .word 0
addr: .word 0
line: .word 0
fileaddr: .word 0
.code
main:
; Print hello, world and exit
lda #<message
ldx #>message
jsr c_printstr
; to dump a file contents, we want to:
; - open the file
; - while read sequential block == TRUE:
; - print the bytes and ascii chars
; - exit
; FCB2 contains the file
jsr set_user_drive
lda #<FCB2
ldx #>FCB2
jsr d_open ; sets DMA, but we need to change the DMA for this.
bcc :+
lda #<str_notfound
ldx #>str_notfound
jsr c_printstr
jmp exit
:
stz addr+0
stz addr+1
stz fileaddr+0
stz fileaddr+1
lda FCB2 + sfcb::SC ; If there is no data then exit immediately.
bne sector_loop
jmp exit
sector_loop:
lda #<SFOS_BUF
ldx #>SFOS_BUF
jsr d_setdma
lda #<FCB2
ldx #>FCB2
jsr d_readseqblock
lda #<SFOS_BUF
sta addr+0
sta line+0 ; so that we can repoint addr at the line for the
lda #>SFOS_BUF
sta addr+1 ; ascii component.
sta line+1
lines_loop:
jsr newline
lda fileaddr+1
jsr prbyte
lda fileaddr+0
jsr prbyte
lda #' '
jsr c_write
lda #<str_sep
ldx #>str_sep
jsr c_printstr
lda line+0
sta addr+0
lda line+1
sta addr+1
ldx #16
line_bytes_loop:
lda (addr)
jsr prbyte
lda #' '
jsr c_write
inc addr+0
bne :+
inc addr+1
: dex
bne line_bytes_loop
lda #<str_sep
ldx #>str_sep
jsr c_printstr
lda line+0
sta addr+0
lda line+1
sta addr+1
ldx #16
line_ascii_loop:
lda (addr)
cmp #' '
bcc :+
cmp #'z' + 1
bcs :+
jsr c_write
bra :++
: lda #'.'
jsr c_write
: inc addr+0
bne :+
inc addr+1
: dex
bne line_ascii_loop
jsr line_add_16
jsr fileaddr_add_16
lda line+1
cmp #>SFOS_BUF + 2
bne lines_loop
dec FCB2 + sfcb::SC
lda FCB2 + sfcb::SC
beq exit
jmp sector_loop
exit:
jsr restore_active_drive
jmp bios_wboot
line_add_16:
clc
lda line+0
adc #16
sta line+0
lda line+1
adc #0
sta line+1
rts
fileaddr_add_16:
clc
lda fileaddr+0
adc #16
sta fileaddr+0
lda fileaddr+1
adc #0
sta fileaddr+1
rts
print_8_bytes:
sta ptr+0
stx ptr+1
rts
print_16_bytes:
jsr print_8_bytes
jsr print_8_bytes
rts
print_16_ascii:
rts
prbyte:
pha ;save a for lsd.
lsr
lsr
lsr ;msd to lsd position.
lsr
jsr @prhex ;output hex digit.
pla ;restore a.
@prhex:
and #$0f ;mask lsd for hex print.
ora #$b0 ;add "0".
cmp #$ba ;digit?
bcc @echo ;yes, output it.
adc #$06 ;add offset for letter.
@echo:
pha ;*save a
and #$7f ;*change to "standard ascii"
jsr c_write
pla ;*restore a
rts ;*done, over and out...
newline:
lda #<str_newline
ldx #>str_newline
jmp c_printstr
restore_active_drive:
lda FCB2
bne :+
rts
: lda saved_active_drive
sta active_drive
ldx #0
jmp d_getsetdrive
set_user_drive:
lda #$FF
ldx #$00
jsr d_getsetdrive
sta active_drive
lda FCB2
bne set_drive
rts
set_drive:
pha
lda active_drive
sta saved_active_drive
pla
sta active_drive
ldx #0
jmp d_getsetdrive
.include "../app.inc"
.bss
_fcb: .res 32,0
used_space: .dword 0
active_drive: .byte 0
saved_active_drive: .byte 0
sector_count: .byte 0
.rodata
message: .byte 10,13,"Dump",10,13,0
str_sep: .byte "| ",0
str_newline: .byte 10,13,0
str_notfound: .byte 10,13,"File not found",0
|
6502-retro/6502-retro-os
| 7,603
|
apps/conway/font.s
|
.byte $00,$00,$00,$00,$00,$00,$00,$00 ; /* - $00 - ALWAYS BLANK */
.byte $18,$3C,$3C,$7E,$7E,$7E,$3C,$3C ; /* - $01 - snake head up */
.byte $3C,$3C,$7E,$7E,$7E,$3C,$3C,$18 ; /* - $02 - snake head down */
.byte $00,$1C,$7F,$FF,$FF,$7F,$1C,$00 ; /* - $03 - snake head left */
.byte $00,$38,$FE,$FF,$FF,$FE,$38,$00 ; /* - $04 - snake head right*/
.byte $04,$68,$37,$7F,$7F,$7F,$7F,$3E ; /* - $05 - apple */
.byte $00,$00,$FF,$FF,$FF,$FF,$3C,$3C ; /* - $06 - top T */
.byte $3C,$3C,$FF,$FF,$FF,$FF,$00,$00 ; /* - $07 - bottom T */
.byte $3C,$3C,$FC,$FC,$FC,$FC,$3C,$3C ; /* - $08 - right T */
.byte $3C,$3C,$3F,$3F,$3F,$3F,$3C,$3C ; /* - $09 - left T */
.byte $00,$00,$FF,$FF,$FF,$FF,$00,$00 ; /* - $0a - horizontal */
.byte $3C,$3C,$3C,$3C,$3C,$3C,$3C,$3C ; /* - $0b - vertical */
.byte $7E,$FF,$C3,$DB,$DB,$C3,$FF,$7E ; /* - $0c - tetris block 1 CYAN I */
.byte $00,$00,$3F,$3F,$3F,$3F,$3C,$3C ; /* - $0d - top left cnr */
.byte $00,$00,$FC,$FC,$FC,$FC,$3C,$3C ; /* - $0e - top right cnr */
.byte $3C,$3C,$3F,$3F,$3F,$3F,$00,$00 ; /* - $0f - bottom left cnr */
.byte $3C,$3C,$FC,$FC,$FC,$FC,$00,$00 ; /* - $10 - bottom right cnr*/
.byte $7E,$FF,$C3,$DB,$DB,$C3,$FF,$7E ; /* - $11 - tetris block 2 DARK BLUE J*/
.byte $7E,$FF,$C3,$DB,$DB,$C3,$FF,$7E ; /* - $12 - tetris block 3 ORANGE L */
.byte $7E,$FF,$C3,$DB,$DB,$C3,$FF,$7E ; /* - $13 - tetris block 4 YELLOW O */
.byte $7E,$FF,$C3,$DB,$DB,$C3,$FF,$7E ; /* - $14 - tetris block 5 GREEN S */
.byte $7E,$FF,$C3,$DB,$DB,$C3,$FF,$7E ; /* - $15 - tetris block 6 RED Z */
.byte $7E,$FF,$C3,$DB,$DB,$C3,$FF,$7E ; /* - $16 - tetris block 7 MAGENTA T */
.byte $00,$00,$00,$00,$0F,$0F,$0F,$0F ; /* DB 017H, */
.byte $00,$00,$00,$00,$0F,$0F,$0F,$0F ; /* DB 018H, */
.byte $00,$00,$00,$00,$0F,$0F,$0F,$0F ; /* DB 019H, */
.byte $00,$00,$00,$00,$0F,$0F,$0F,$0F ; /* DB 01AH, */
.byte $00,$00,$00,$00,$0F,$0F,$0F,$0F ; /* DB 01BH, */
.byte $00,$00,$00,$00,$0F,$0F,$0F,$0F ; /* DB 01CH, */
.byte $00,$00,$00,$00,$0F,$0F,$0F,$0F ; /* DB 01DH, */
.byte $00,$00,$00,$00,$0F,$0F,$0F,$0F ; /* DB 01EH, */
.byte $00,$00,$00,$00,$0F,$0F,$0F,$0F ; /* DB 01FH, */
.byte $00,$00,$00,$00,$00,$00,$00,$00 ; /* DB 020H, */
.byte $18,$18,$18,$18,$18,$00,$18,$00 ; /* DB 021H, */
.byte $6C,$6C,$00,$00,$00,$00,$00,$00 ; /* DB 022H, */
.byte $6C,$6C,$FE,$6C,$FE,$6C,$6C,$00 ; /* DB 023H, */
.byte $7C,$D6,$D0,$7C,$16,$D6,$7C,$00 ; /* DB 024H, */
.byte $C6,$CE,$1C,$38,$70,$E6,$C6,$00 ; /* DB 025H, */
.byte $38,$6C,$6C,$30,$DA,$CC,$76,$00 ; /* DB 026H, */
.byte $38,$38,$18,$70,$00,$00,$00,$00 ; /* DB 027H, */
.byte $18,$30,$60,$60,$60,$30,$18,$00 ; /* DB 028H, */
.byte $60,$30,$18,$18,$18,$30,$60,$00 ; /* DB 029H, */
.byte $92,$54,$38,$FE,$38,$54,$92,$00 ; /* DB 02AH, */
.byte $00,$18,$18,$7E,$7E,$18,$18,$00 ; /* DB 02BH, */
.byte $00,$00,$00,$00,$38,$38,$18,$70 ; /* DB 02CH, */
.byte $00,$00,$00,$3C,$3C,$00,$00,$00 ; /* DB 02DH, */
.byte $00,$00,$00,$00,$1C,$1C,$1C,$00 ; /* DB 02EH, */
.byte $06,$0E,$1C,$38,$70,$E0,$C0,$00 ; /* DB 02FH, */
.byte $7C,$C6,$CE,$FE,$F6,$C6,$7C,$00 ; /* DB 030H, */
.byte $18,$38,$18,$18,$18,$18,$3C,$00 ; /* DB 031H, */
.byte $7C,$CE,$CE,$1C,$38,$70,$FE,$00 ; /* DB 032H, */
.byte $7C,$C6,$06,$1C,$06,$C6,$7C,$00 ; /* DB 033H, */
.byte $0C,$1C,$3C,$6C,$CC,$FE,$0C,$00 ; /* DB 034H, */
.byte $FE,$C0,$FC,$C6,$06,$C6,$7C,$00 ; /* DB 035H, */
.byte $7C,$C6,$C0,$FC,$C6,$C6,$7C,$00 ; /* DB 036H, */
.byte $FE,$CE,$0C,$18,$38,$38,$38,$00 ; /* DB 037H, */
.byte $7C,$C6,$C6,$7C,$C6,$C6,$7C,$00 ; /* DB 038H, */
.byte $7C,$C6,$C6,$7E,$06,$C6,$7C,$00 ; /* DB 039H, */
.byte $38,$38,$38,$00,$38,$38,$38,$00 ; /* DB 03AH, */
.byte $38,$38,$38,$00,$38,$18,$18,$00 ; /* DB 03BH, */
.byte $0C,$18,$30,$60,$30,$18,$0C,$00 ; /* DB 03CH, */
.byte $00,$7C,$7C,$00,$7C,$7C,$00,$00 ; /* DB 03DH, */
.byte $60,$30,$18,$0C,$18,$30,$60,$00 ; /* DB 03EH, */
.byte $7C,$C6,$CC,$18,$18,$00,$18,$00 ; /* DB 03FH, */
.byte $7C,$82,$BA,$8A,$BA,$AA,$94,$00 ; /* DB 040H, */
.byte $38,$6C,$C6,$C6,$FE,$C6,$C6,$00 ; /* DB 041H, */
.byte $FC,$C6,$C6,$FC,$C6,$C6,$FC,$00 ; /* DB 042H, */
.byte $7C,$C6,$C0,$C0,$C0,$C6,$7C,$00 ; /* DB 043H, */
.byte $F8,$CC,$C6,$C6,$C6,$CC,$F8,$00 ; /* DB 044H, */
.byte $FE,$C0,$C0,$F8,$C0,$C0,$FE,$00 ; /* DB 045H, */
.byte $FE,$C0,$C0,$F8,$C0,$C0,$C0,$00 ; /* DB 046H, */
.byte $7C,$C6,$C0,$C0,$CE,$C6,$7E,$00 ; /* DB 047H, */
.byte $C6,$C6,$C6,$FE,$C6,$C6,$C6,$00 ; /* DB 048H, */
.byte $3C,$18,$18,$18,$18,$18,$3C,$00 ; /* DB 049H, */
.byte $1E,$0C,$0C,$0C,$CC,$CC,$78,$00 ; /* DB 04AH, */
.byte $C6,$CC,$D8,$F0,$D8,$CC,$C6,$00 ; /* DB 04BH, */
.byte $C0,$C0,$C0,$C0,$C0,$C0,$FE,$00 ; /* DB 04CH, */
.byte $C6,$FE,$FE,$D6,$C6,$C6,$C6,$00 ; /* DB 04DH, */
.byte $E6,$E6,$F6,$D6,$DE,$CE,$CE,$00 ; /* DB 04EH, */
.byte $7C,$C6,$C6,$C6,$C6,$C6,$7C,$00 ; /* DB 04FH, */
.byte $FC,$C6,$C6,$FC,$C0,$C0,$C0,$00 ; /* DB 050H, */
.byte $7C,$C6,$C6,$C6,$DE,$CC,$7E,$00 ; /* DB 051H, */
.byte $FC,$C6,$C6,$FC,$D8,$CC,$C6,$00 ; /* DB 052H, */
.byte $7C,$C6,$C0,$7C,$06,$C6,$7C,$00 ; /* DB 053H, */
.byte $7E,$18,$18,$18,$18,$18,$18,$00 ; /* DB 054H, */
.byte $C6,$C6,$C6,$C6,$C6,$C6,$7C,$00 ; /* DB 055H, */
.byte $C6,$C6,$C6,$6C,$6C,$38,$38,$00 ; /* DB 056H, */
.byte $C6,$C6,$C6,$D6,$D6,$FE,$6C,$00 ; /* DB 057H, */
.byte $C6,$C6,$6C,$38,$6C,$C6,$C6,$00 ; /* DB 058H, */
.byte $66,$66,$66,$3C,$18,$18,$18,$00 ; /* DB 059H, */
.byte $FE,$0E,$1C,$38,$70,$E0,$FE,$00 ; /* DB 05AH, */
.byte $78,$60,$60,$60,$60,$60,$78,$00 ; /* DB 05BH, */
.byte $3C,$42,$99,$A1,$A1,$99,$42,$3C ; /* DB 05CH, */
.byte $78,$18,$18,$18,$18,$18,$78,$00 ; /* DB 05DH, */
.byte $38,$6C,$C6,$00,$00,$00,$00,$00 ; /* DB 05EH, */
.byte $00,$00,$00,$00,$00,$00,$7E,$7E ; /* DB 05FH, */
.byte $15,$35,$75,$F5,$75,$35,$15,$00 ; /* DB 060H, */
.byte $00,$00,$3C,$06,$3E,$66,$3E,$00 ; /* DB 061H, */
.byte $60,$60,$7C,$66,$66,$66,$7C,$00 ; /* DB 062H, */
.byte $00,$00,$3C,$66,$60,$66,$3C,$00 ; /* DB 063H, */
.byte $06,$06,$3E,$66,$66,$66,$3E,$00 ; /* DB 064H, */
.byte $00,$00,$3C,$66,$7E,$60,$3E,$00 ; /* DB 065H, */
.byte $1C,$36,$30,$78,$30,$30,$30,$00 ; /* DB 066H, */
.byte $00,$00,$3E,$66,$3E,$06,$66,$3C ; /* DB 067H, */
.byte $60,$60,$7C,$66,$66,$66,$66,$00 ; /* DB 068H, */
.byte $18,$00,$18,$18,$18,$18,$18,$00 ; /* DB 069H, */
.byte $06,$00,$06,$06,$06,$06,$66,$3C ; /* DB 06AH, */
.byte $60,$60,$66,$6C,$78,$6C,$66,$00 ; /* DB 06BH, */
.byte $18,$18,$18,$18,$18,$18,$18,$00 ; /* DB 06CH, */
.byte $00,$00,$6C,$FE,$D6,$D6,$D6,$00 ; /* DB 06DH, */
.byte $00,$00,$5C,$7E,$66,$66,$66,$00 ; /* DB 06EH, */
.byte $00,$00,$7C,$C6,$C6,$C6,$7C,$00 ; /* DB 06FH, */
.byte $00,$00,$7C,$66,$66,$7C,$60,$60 ; /* DB 070H, */
.byte $00,$00,$7C,$CC,$CC,$7C,$0C,$0E ; /* DB 071H, */
.byte $00,$00,$6C,$76,$60,$60,$60,$00 ; /* DB 072H, */
.byte $00,$00,$3C,$60,$38,$0C,$78,$00 ; /* DB 073H, */
.byte $18,$18,$3C,$18,$18,$18,$18,$00 ; /* DB 074H, */
.byte $00,$00,$66,$66,$66,$66,$3C,$00 ; /* DB 075H, */
.byte $00,$00,$66,$66,$66,$3C,$18,$00 ; /* DB 076H, */
.byte $00,$00,$C6,$C6,$D6,$FE,$6C,$00 ; /* DB 077H, */
.byte $00,$00,$C6,$6C,$38,$6C,$C6,$00 ; /* DB 078H, */
.byte $00,$00,$66,$66,$66,$3C,$18,$70 ; /* DB 079H, */
.byte $00,$00,$7E,$0C,$18,$30,$7E,$00 ; /* DB 07AH, */
.byte $18,$30,$30,$70,$30,$30,$18,$00 ; /* DB 07BH, */
.byte $18,$18,$18,$18,$18,$18,$18,$00 ; /* DB 07CH, */
.byte $60,$30,$30,$38,$30,$30,$60,$00 ; /* DB 07DH, */
.byte $A8,$AC,$AE,$AF,$AE,$AC,$A8,$00 ; /* DB 07EH, */
.byte $00,$00,$00,$00,$00,$00,$00,$00 ; /* DB 07FH */
|
6502-retro/6502-retro-os
| 8,457
|
apps/conway/vdp.s
|
; vim: set ft=asm_ca65 ts=4 sw=4 :
;extern void vdp_init();
;extern void vdp_init_g2();
;extern void __fastcall__ vdp_set_write_address(unsigned int addr);
;extern void __fastcall__ vdp_set_read_address(unsigned int addr);
;extern void vdp_wait();
;extern void vdp_flush();
;extern void __fastcall__ vdp_write_to_screen_xy(unsigned char x, unsigned char y, unsigned char c);
;extern unsigned char __fastcall__ vdp_read_from_screen_xy(unsigned char x, unsigned char y);
;extern void vdp_clear_screen_buf();
;extern unsigned char screen_buf[0x400];
;
;extern unsigned char vdp_con_mode;
;extern unsigned char vdp_con_width;
.autoimport
; C Level exports
.export _vdp_init
.export _vdp_init_g2
.export _vdp_set_write_address
.export _vdp_set_read_address
.export _vdp_wait
.export _vdp_flush
.export _vdp_write_to_screen_xy
.export _vdp_read_from_screen_xy
.export _vdp_clear_screen_buf
.export _screen_buf
; ASM only exports
.export vdp_write_to_screen_xy
.export vdp_read_from_screen_xy
VDP_RAM = $BF30
VDP_REG = $BF31
VDP_SPRITE_PATTERN_TABLE = 0
VDP_PATTERN_TABLE = $800
VDP_G2_PATTERN_TABLE = 0
VDP_SPRITE_ATTRIBUTE_TABLE = $1000
VDP_NAME_TABLE = $1400
VDP_G2_NAME_TABLE = $3800
VDP_COLOR_TABLE = $2000
_vdp_sync = $65E
.macro vdp_delay_slow
; jsr delay_slow
.endmacro
.macro vdp_delay_fast
; jsr delay_fast
.endmacro
.macro div8
.repeat 3
lsr
.endrepeat
.endmacro
.macro mul8
.repeat 3
asl
.endrepeat
.endmacro
.macro mul32
.repeat 5
asl
.endrepeat
.endmacro
.zeropage
ptr1: .word 0
sp: .byte 0
tmp4: .byte 0
scr_ptr: .word 0
.code
delay_fast:
phy
ldy #16
: dey
bne :-
ply
rts
delay_slow:
phy
ldy #8
: dey
bne :-
ply
rts
_vdp_init:
jsr vdp_clear_vram
lda #<vdp_inits
ldx #>vdp_inits
jsr vdp_init_registers
lda #<VDP_PATTERN_TABLE
ldx #>VDP_PATTERN_TABLE
jsr vdp_load_font
jsr _vdp_clear_screen_buf
stz scrx
stz scry
stz _vdp_con_mode
lda #40
sta _vdp_con_width
rts
_vdp_init_g2:
jsr vdp_clear_vram
lda #<vdp_g2_inits
ldx #>vdp_g2_inits
jsr vdp_init_registers
lda #<VDP_G2_PATTERN_TABLE
ldx #>VDP_G2_PATTERN_TABLE
jsr vdp_load_font
jsr _vdp_clear_screen_buf
stz scrx
stz scry
lda #1
sta _vdp_con_mode
lda #32
sta _vdp_con_width
rts
; Zero out all 16K of the VRAM
vdp_clear_vram:
lda #$00
ldx #$00
jsr _vdp_set_write_address
lda #$FF
sta ptr1
lda #$3F
sta ptr1 + 1
:
lda #$00
sta VDP_RAM
vdp_delay_slow
dec ptr1
lda ptr1
bne :-
dec ptr1 + 1
lda ptr1 + 1
bne :-
rts
; Iniitialise the VDP into textmode with interrupts enabled.
; XA points to registers table
vdp_init_registers:
sta ptr1
stx ptr1+1
ldy #$00
:
lda (ptr1),y
sta VDP_REG
vdp_delay_slow
tya
ora #$80
sta VDP_REG
vdp_delay_slow
iny
cpy #8
bne :-
rts
; XA points to NAME TABLE ADDRESS
vdp_load_font:
jsr _vdp_set_write_address
lda #<font_start
sta ptr1
lda #>font_start
sta ptr1 + 1
ldy #0
:
lda (ptr1),y
sta VDP_RAM
vdp_delay_slow
lda ptr1
clc
adc #1
sta ptr1
lda #0
adc ptr1 + 1
sta ptr1 + 1
cmp #>font_end
bne :-
lda ptr1
cmp #<font_end
bne :-
rts
_vdp_clear_screen_buf:
lda #<_screen_buf
sta ptr1
lda #>_screen_buf
sta ptr1+1
ldx #4
lda #$20
ldy #0
:
sta (ptr1),y
iny
bne :-
inc ptr1+1
dex
bne :-
stz scrx
stz scry
rts
_vdp_set_write_address:
sta VDP_REG
vdp_delay_slow
txa
ora #$40
sta VDP_REG
vdp_delay_slow
rts
_vdp_set_read_address:
sta VDP_REG
vdp_delay_slow
txa
sta VDP_REG
vdp_delay_slow
rts
_vdp_wait:
lda _vdp_sync
cmp #$80
bne _vdp_wait
stz _vdp_sync
rts
_vdp_flush:
lda _vdp_con_mode
bne :+
lda #<VDP_NAME_TABLE
ldx #>VDP_NAME_TABLE
bra :++
:
lda #<VDP_G2_NAME_TABLE
ldx #>VDP_G2_NAME_TABLE
:
jsr _vdp_set_write_address
lda #<_screen_buf
sta ptr1
lda #>_screen_buf
sta ptr1+1
ldx #4
ldy #0
: lda (ptr1),y
sta VDP_RAM
vdp_delay_slow
inc ptr1
bne :-
inc ptr1+1
dex
bne :-
rts
; Assembly version.
; A char to write
; XY location to write to
vdp_xy_to_screen_ptr:
pha
lda #<_screen_buf
sta scr_ptr
lda #>_screen_buf
sta scr_ptr+1
tya
div8
clc
adc scr_ptr+1
sta scr_ptr+1
tya
and #$07
mul32
sta scr_ptr
lda _vdp_con_mode
bne @add_x
tya
mul8
clc
adc scr_ptr
sta scr_ptr
lda #0
adc scr_ptr+1
sta scr_ptr+1
@add_x:
clc
txa
adc scr_ptr
sta scr_ptr
lda #0
adc scr_ptr+1
sta scr_ptr+1
@return:
pla
rts
; XY is location
; A is char to write
vdp_write_to_screen_xy:
jsr vdp_xy_to_screen_ptr
sta (scr_ptr)
rts
; C Wrapper for write to screen buffer at XY
; void vdp_write_to_screen_xy(unsigned char x, unsigned char y, unsigned char c);
_vdp_write_to_screen_xy:
sta tmp4; ; c
ldy #1
lda (sp),y
tax ; ; x
lda (sp)
tay ; ; y
lda tmp4
jmp vdp_write_to_screen_xy
; XY is location
; A contains returned character
vdp_read_from_screen_xy:
jsr vdp_xy_to_screen_ptr
lda (scr_ptr)
rts
; C Wrapper for write to screen buffer at XY
; unsigned char vdp_read_from_screen_xy(unsigned char x, unsigned char y);
_vdp_read_from_screen_xy:
tay
lda (sp)
tax
jmp vdp_read_from_screen_xy
; ==============================================================================
; VDP TERMINAL ROUTINES
; ==============================================================================
.bss
_screen_buf: .res $400
_vdp_con_mode: .res 1
_vdp_con_width: .res 1
scrx: .res 1
scry: .res 1
.rodata
vdp_inits:
.byte $00 ; r0
.byte $F0 ; r1 16kb ram + M1, interrupts enabled, text mode
.byte $05 ; r2 name table at 0x1400
.byte $80 ; r3 color start 0x2000
.byte $01 ; r4 pattern generator start at 0x800
.byte $20 ; r5 Sprite attriutes start at 0x1000
.byte $00 ; r6 Sprite pattern table at 0x0000
.byte $E1 ; r7 Set forground and background color (grey on black)
vdp_g2_inits:
.byte $02 ; Graphics II Mode,No External Video
.byte $e0 ; 16K,Enable Disp.,Enable int., 8x8 Sprites,Mag.Off
.byte $0e ; Address of Name Table in VRAM = Hex 3800
.byte $9f ; Color Table Address = Hex 2000 to Hex 280
.byte $00 ; Pattern Table Address = Hex 0000 to Hex 0800
.byte $76 ; Address of Sprite Attribute Table in VRAM = Hex 3BOO
.byte $03 ; Address of Sprite Pattern Table in VRAM = 1800
.byte $2a ; white on black
font_start:
.include "font.s"
font_end:
|
6502-retro/6502-retro-os
| 4,847
|
apps/ehbasic/6502-retro-basic.s
|
.include "sfos.inc"
.include "bios.inc"
; vim: ft=asm_ca65 ts=4 sw=4 :
; contains additional commands for EH Basic
basptr = $FA
.code
; BYE - Quits EHBASIC
; CLS - CLEAR Screen by issuing Ansi escape sequence "ESC [J2"
; LOAD "FILENAME.BAS" - Loads a FILENAME
; SAVE "FILENAME.BAS" - Saves current program into FILENAME.
retro_cls:
lda #<strAnsiCLSHome
ldy #>strAnsiCLSHome
jmp LAB_18C3 ; print null terminated string
retro_bye:
jmp bios_wboot
retro_beep:
jmp bios_sn_beep
save:
jsr create_fcb
jsr set_drive
lda #<FCB
ldx #>FCB
ldy #esfos::sfos_d_findfirst
jsr sfos_entry
bcs @make
ldx #$1E
jmp LAB_XERR
@make:
lda #<FCB
ldx #>FCB
ldy #esfos::sfos_d_make
jsr sfos_entry
bcc @save
ldx #$26
jmp LAB_XERR
@save:
lda #<SFOS_BUF
ldx #>SFOS_BUF
ldy #esfos::sfos_d_setdma
jsr sfos_entry
jsr clear_buf
; redirect stdout to file
lda #<fwrite
sta VEC_OUT + 0
lda #>fwrite
sta VEC_OUT + 1
sec
jsr LAB_14BD ; LIST
lda #$1A
jsr fwrite
lda #<ACIAout
sta VEC_OUT + 0
lda #>ACIAout
sta VEC_OUT + 1
lda #<FCB
ldx #>FCB
ldy #esfos::sfos_d_close
jmp sfos_entry
fwrite:
phx
phy
sta bios_rega
lda #<FCB
ldx #>FCB
ldy #esfos::sfos_d_writeseqbyte
jsr sfos_entry
ply
plx
rts
clear_buf:
lda #0
ldy #0
: sta SFOS_BUF+0,y
iny
bne :-
: sta SFOS_BUF+256,y
iny
bne :-
lda #<SFOS_BUF
sta basptr+0
lda #>SFOS_BUF
sta basptr+1
rts
load:
; open file
; read file into memory one character at a time
; when read fails, then done.
jsr search_fcb
jsr set_drive
jsr open_file
lda #<SFOS_BUF
ldx #>SFOS_BUF
ldy #esfos::sfos_d_setdma
jsr sfos_entry
lda #<FCB
ldx #>FCB
ldy #esfos::sfos_d_readseqblock
jsr sfos_entry
; redirect STDIN
; save stack as NEW destroys it
tsx
inx
lda $100,x
sta basptr
inx
lda $100,x
sta basptr + 1
jsr LAB_1463 ; NEW
; restore stack
lda basptr+ 1
pha
lda basptr
pha
; redirect input
lda #<fread
sta VEC_IN + 0
lda #>fread
sta VEC_IN + 1
; redirect output to null
lda #<nullout
sta VEC_OUT + 0
lda #>nullout
sta VEC_OUT + 1
jmp LAB_1319
fread:
phx
phy
lda #<FCB
ldx #>FCB
ldy #esfos::sfos_d_readseqbyte
jsr sfos_entry
ply
plx
bcs fread_error
cmp #$0a
bne nullout
lda #$0d
nullout:
sec
rts
fread_error:
lda bios_error_code
cmp #ERROR::FILE_EOF
bne :+
jsr reset_redirects
jmp file_exit
: ldx #$2A
jmp LAB_XERR
clear_fcb:
ldx #0
lda #0
: sta FCB,x
inx
cpx #32
bne :-
rts
create_fcb:
jsr clear_fcb
; parse FCB
lda #<FCB
ldx #>FCB
ldy #esfos::sfos_d_setdma
jsr sfos_entry
lda #4 ; ALL FILES ON D DRIVE ALLWAYS
sta FCB
jsr LAB_EVEX
lda Dtypef
bne :+
ldx #$02
jmp LAB_XERR ; syntax error
:
jsr LAB_22B6
; filename is pointed to by X/Y
stx basptr + 0
sty basptr + 1
tay ; length in A
lda #0
sta (basptr),Y ; zeroterminate the filename string
lda basptr + 0
ldx basptr + 1
ldy #esfos::sfos_d_parsefcb
jmp sfos_entry
open_file:
jsr create_fcb
lda #<FCB
ldx #>FCB
ldy #esfos::sfos_d_open
jmp sfos_entry
reset_redirects:
lda #<ACIAout
sta VEC_OUT + 0
lda #>ACIAout
sta VEC_OUT + 1
lda #<ACIAin
sta VEC_IN + 0
lda #>ACIAin
sta VEC_IN + 1
rts
file_exit:
lda #<strReady
ldy #>strReady
jsr LAB_18C3
jsr LAB_1477
jmp LAB_1319
exit:
jmp bios_wboot
search_fcb:
jsr clear_fcb
ldx #0
: lda strSearch,x
sta FCB,x
inx
cpx #sfcb::L1
bne :-
rts
print_fcb:
stz FCB + sfcb::L1
ldx #1
: lda FCB,x
beq :+
jsr bios_conout
inx
bra :-
: jmp LAB_CRLF
retro_dir:
; search FCB *.bas
; find first
; find next until none found
jsr search_fcb
jsr set_drive
lda #<FCB
ldx #>FCB
ldy #esfos::sfos_d_findfirst
jsr sfos_entry
bcs @exit
jsr print_fcb
@loop:
jsr search_fcb
lda #<FCB
ldx #>FCB
ldy #esfos::sfos_d_findnext
jsr sfos_entry
bcs @exit
jsr print_fcb
bra @loop
@exit:
rts
set_drive:
lda FCB
ldy #esfos::sfos_d_getsetdrive
jmp sfos_entry
.bss
active_drive: .byte 0
saved_active_drive: .byte 0
temp: .word 0
.rodata
strAnsiCLSHome: .byte $0D,$0A, $1b, "[2J", $1b, "[H", $0
strReady: .byte $0D,$0A,"Ready",$0A,$0D,$0
strSearch: .byte 4,"????????BAS"
|
6502-retro/6502-retro-os
| 355,908
|
apps/ehbasic/basic.s
|
; vim: ft=asm_ca65
; Enhanced BASIC to assemble under 6502 simulator, $ver 2.22p5
; $E7E1 $E7CF $E7C6 $E7D3 $E7D1 $E7D5 $E7CF $E81E $E825
; 2.00 new revision numbers start here
; 2.01 fixed LCASE$() and UCASE$()
; 2.02 new get value routine done
; 2.03 changed RND() to galoise method
; 2.04 fixed SPC()
; 2.05 new get value routine fixed
; 2.06 changed USR() code
; 2.07 fixed STR$()
; 2.08 changed INPUT and READ to remove need for $00 start to input buffer
; 2.09 fixed RND()
; 2.10 integrated missed changes from an earlier version
; 2.20 added ELSE to IF .. THEN and fixed IF .. GOTO <statement> to cause error
; 2.21 fixed IF .. THEN RETURN to not cause error
; 2.22 fixed RND() breaking the get byte routine
; 2.22p patched to disable use of decimal mode and fix Ibuff issues
; (bugsnquirks.txt notes 2, 4 and 5)
; tabs converted to spaces, tabwidth=6
; 2.22p2 fixed can't continue error on 1st statement after direct mode
; changed INPUT to throw "break in line ##" on empty line input
; 2.22p3 fixed RAM above code / Ibuff above EhBASIC patch breaks STR$()
; fix provided by github user mgcaret
; 2.22p4 fixed string compare of equal strings in direct mode returns FALSE
; fixed FALSE stored to a variable after a string compare
; is > 0 and < 1E-16
; added additional stack floor protection for background interrupts
; fixed conditional LOOP & NEXT cannot find their data strucure on stack
; 2.22p5 fixes issues reported by users Ruud and dclxvi on the 6502.org forum
; 5.0 http://forum.6502.org/viewtopic.php?f=5&t=5500
; sanity check for RAM top allows values below RAM base
; 5.1-7 http://forum.6502.org/viewtopic.php?f=5&t=5606
; 1-7 coresponds to the bug# in the thread
; 5.1 TO expression with a subtract may evaluate with the sign bit flipped
; 5.3 call to LAB_1B5B may return to an address -$100 (page not incremented)
; 5.4 string concatenate followed by MINUS or NOT() crashes EhBASIC
; 5.5 garbage collection may cause an overlap with temporary strings
; 5.6 floating point multiply rounding bug
; 5.7 VAL() may cause string variables to be trashed
; zero page use ..
.zeropage
; the following locations are bulk initialized from StrTab at LAB_GMEM
LAB_WARM .res 1; = $00 ; BASIC warm start entry point
Wrmjpl .res 1; = LAB_WARM+1; BASIC warm start vector jump low byte
Wrmjph .res 1; = LAB_WARM+2; BASIC warm start vector jump high byte
__unused .res 7; 7 bytes of unused data here.
Usrjmp .res 1; = $0A ; USR function JMP address
Usrjpl .res 1; = Usrjmp+1 ; USR function JMP vector low byte
Usrjph .res 1; = Usrjmp+2 ; USR function JMP vector high byte
Nullct .res 1; = $0D ; nulls output after each line
TPos .res 1; = $0E ; BASIC terminal position byte
TWidth .res 1; = $0F ; BASIC terminal width byte
Iclim .res 1; = $10 ; input column limit
Itempl .res 1; = $11 ; temporary integer low byte
Itemph .res 1; = Itempl+1 ; temporary integer high byte
; end bulk initialize from StrTab at LAB_GMEM
.segment "BASICZP" : zeropage
nums_1 .res 1; = Itempl ; number to bin/hex string convert MSB
nums_2 .res 1; = nums_1+1 ; number to bin/hex string convert
nums_3 .res 1; = nums_1+2 ; number to bin/hex string convert LSB
Srchc .res 1; = $5B ; search character
Temp3 = Srchc ; temp byte used in number routines
Scnquo .res 1; = $5C ; scan-between-quotes flag
Asrch = Scnquo ; alt search character
XOAw_l = Srchc ; eXclusive OR, OR and AND word low byte
XOAw_h = Scnquo ; eXclusive OR, OR and AND word high byte
Ibptr .res 1; = $5D ; input buffer pointer
Dimcnt = Ibptr ; # of dimensions
Tindx = Ibptr ; token index
Defdim .res 1; = $5E ; default DIM flag
Dtypef .res 1; = $5F ; data type flag, $FF=string, $00=numeric
Oquote .res 1; = $60 ; open quote flag (b7) (Flag: DATA scan; LIST quote; memory)
Gclctd .res 1; = $60 ; garbage collected flag
Sufnxf .res 1; = $61 ; subscript/FNX flag, 1xxx xxx = FN(0xxx xxx)
Imode .res 1; = $62 ; input mode flag, $00=INPUT, $80=READ
Cflag .res 1; = $63 ; comparison evaluation flag
TabSiz .res 1; = $64 ; TAB step size (was input flag)
next_s .res 1; = $65 ; next descriptor stack address
; these two bytes form a word pointer to the item
; currently on top of the descriptor stack
last_sl .res 1; = $66 ; last descriptor stack address low byte
last_sh .res 1; = $67 ; last descriptor stack address high byte (always $00)
des_sk .res 8; = $68 ; descriptor stack start address (temp strings)
; = $70 ; End of descriptor stack
ut1_pl .res 1; = $71 ; utility pointer 1 low byte
ut1_ph .res 1; = ut1_pl+1 ; utility pointer 1 high byte
ut2_pl .res 1; = $73 ; utility pointer 2 low byte
ut2_ph .res 1; = ut2_pl+1 ; utility pointer 2 high byte
Temp_2 = ut1_pl ; temp byte for block move
FACt_1 .res 1; = $75 ; FAC temp mantissa1
FACt_2 .res 1; = FACt_1+1 ; FAC temp mantissa2
FACt_3 .res 1; = FACt_2+1 ; FAC temp mantissa3
dims_l = FACt_2 ; array dimension size low byte
dims_h = FACt_3 ; array dimension size high byte
TempB .res 1; = $78 ; temp page 0 byte
Smeml .res 1; = $79 ; start of mem low byte (Start-of-Basic)
Smemh .res 1; = Smeml+1 ; start of mem high byte (Start-of-Basic)
Svarl .res 1; = $7B ; start of vars low byte (Start-of-Variables)
Svarh .res 1; = Svarl+1 ; start of vars high byte (Start-of-Variables)
Sarryl .res 1; = $7D ; var mem end low byte (Start-of-Arrays)
Sarryh .res 1; = Sarryl+1 ; var mem end high byte (Start-of-Arrays)
Earryl .res 1; = $7F ; array mem end low byte (End-of-Arrays)
Earryh .res 1; = Earryl+1 ; array mem end high byte (End-of-Arrays)
Sstorl .res 1; = $81 ; string storage low byte (String storage (moving down))
Sstorh .res 1; = Sstorl+1 ; string storage high byte (String storage (moving down))
Sutill .res 1; = $83 ; string utility ptr low byte
Sutilh .res 1; = Sutill+1 ; string utility ptr high byte
Ememl .res 1; = $85 ; end of mem low byte (Limit-of-memory)
Ememh .res 1; = Ememl+1 ; end of mem high byte (Limit-of-memory)
Clinel .res 1; = $87 ; current line low byte (Basic line number)
Clineh .res 1; = Clinel+1 ; current line high byte (Basic line number)
Blinel .res 1; = $89 ; break line low byte (Previous Basic line number)
Blineh .res 1; = Blinel+1 ; break line high byte (Previous Basic line number)
Cpntrl .res 1; = $8B ; continue pointer low byte
Cpntrh .res 1; = Cpntrl+1 ; continue pointer high byte
Dlinel .res 1; = $8D ; current DATA line low byte
Dlineh .res 1; = Dlinel+1 ; current DATA line high byte
Dptrl .res 1; = $8F ; DATA pointer low byte
Dptrh .res 1; = Dptrl+1 ; DATA pointer high byte
Rdptrl .res 1; = $91 ; read pointer low byte
Rdptrh .res 1; = Rdptrl+1 ; read pointer high byte
Varnm1 .res 1; = $93 ; current var name 1st byte
Varnm2 .res 1; = Varnm1+1 ; current var name 2nd byte
Cvaral .res 1; = $95 ; current var address low byte
Cvarah .res 1; = Cvaral+1 ; current var address high byte
Frnxtl .res 1; = $97 ; var pointer for FOR/NEXT low byte
Frnxth .res 1; = Frnxtl+1 ; var pointer for FOR/NEXT high byte
Tidx1 = Frnxtl ; temp line index
Lvarpl = Frnxtl ; let var pointer low byte
Lvarph = Frnxth ; let var pointer high byte
prstk .res 1; = $99 ; precedence stacked flag
comp_f .res 1; = $9B ; compare function flag, bits 0,1 and 2 used
; bit 2 set if >
; bit 1 set if =
; bit 0 set if <
func_l .res 1; = $9C ; function pointer low byte
func_h .res 1; = func_l+1 ; function pointer high byte
garb_l = func_l ; garbage collection working pointer low byte
garb_h = func_h ; garbage collection working pointer high byte
des_2l .res 1; = $9E ; string descriptor_2 pointer low byte
des_2h .res 1; = des_2l+1 ; string descriptor_2 pointer high byte
g_step .res 1; = $A0 ; garbage collect step size
Fnxjmp .res 1; = $A1 ; jump vector for functions
Fnxjpl .res 1; = Fnxjmp+1 ; functions jump vector low byte
Fnxjph .res 1; = Fnxjmp+2 ; functions jump vector high byte
g_indx = Fnxjpl ; garbage collect temp index
FAC2_r .res 1; = $A3 ; FAC2 rounding byte
Adatal .res 1; = $A4 ; array data pointer low byte
Adatah .res 1; = Adatal+1 ; array data pointer high byte
Nbendl = Adatal ; new block end pointer low byte
Nbendh = Adatah ; new block end pointer high byte
Obendl .res 1; = $A6 ; old block end pointer low byte
Obendh .res 1; = Obendl+1 ; old block end pointer high byte
numexp .res 1; = $A8 ; string to float number exponent count
expcnt .res 1; = $A9 ; string to float exponent count
numbit = numexp ; bit count for array element calculations
numdpf .res 1; = $AA ; string to float decimal point flag
expneg .res 1; = $AB ; string to float eval exponent -ve flag
Astrtl = numdpf ; array start pointer low byte
Astrth = expneg ; array start pointer high byte
Histrl = numdpf ; highest string low byte
Histrh = expneg ; highest string high byte
Baslnl = numdpf ; BASIC search line pointer low byte
Baslnh = expneg ; BASIC search line pointer high byte
Fvar_l = numdpf ; find/found variable pointer low byte
Fvar_h = expneg ; find/found variable pointer high byte
Ostrtl = numdpf ; old block start pointer low byte
Ostrth = expneg ; old block start pointer high byte
Vrschl = numdpf ; variable search pointer low byte
Vrschh = expneg ; variable search pointer high byte
FAC1_e .res 1; = $AC ; FAC1 exponent
FAC1_1 .res 1; = FAC1_e+1 ; FAC1 mantissa1
FAC1_2 .res 1; = FAC1_e+2 ; FAC1 mantissa2
FAC1_3 .res 1; = FAC1_e+3 ; FAC1 mantissa3
FAC1_s .res 1; = FAC1_e+4 ; FAC1 sign (b7)
str_ln = FAC1_e ; string length
str_pl = FAC1_1 ; string pointer low byte
str_ph = FAC1_2 ; string pointer high byte
des_pl = FAC1_2 ; string descriptor pointer low byte
des_ph = FAC1_3 ; string descriptor pointer high byte
mids_l = FAC1_3 ; MID$ string temp length byte
negnum .res 1; = $B1 ; string to float eval -ve flag
numcon = negnum ; series evaluation constant count
FAC1_o .res 1; = $B2 ; FAC1 overflow byte
FAC2_e .res 1; = $B3 ; FAC2 exponent
FAC2_1 .res 1; = FAC2_e+1 ; FAC2 mantissa1
FAC2_2 .res 1; = FAC2_e+2 ; FAC2 mantissa2
FAC2_3 .res 1; = FAC2_e+3 ; FAC2 mantissa3
FAC2_s .res 1; = FAC2_e+4 ; FAC2 sign (b7)
FAC_sc .res 1; = $B8 ; FAC sign comparison, Acc#1 vs #2
FAC1_r .res 1; = $B9 ; FAC1 rounding byte
ssptr_l = FAC_sc ; string start pointer low byte
ssptr_h = FAC1_r ; string start pointer high byte
sdescr = FAC_sc ; string descriptor pointer
csidx .res 1; = $BA ; line crunch save index
Asptl = csidx ; array size/pointer low byte
Aspth .res 1; = $BB ; array size/pointer high byte
Btmpl = Asptl ; BASIC pointer temp low byte
Btmph = Aspth ; BASIC pointer temp low byte
Cptrl = Asptl ; BASIC pointer temp low byte
Cptrh = Aspth ; BASIC pointer temp low byte
Sendl = Asptl ; BASIC pointer temp low byte
Sendh = Aspth ; BASIC pointer temp low byte
; the following locations are bulk initialized from LAB_2CEE at LAB_2D4E
LAB_IGBY .res 6; = $BC ; get next BASIC byte subroutine
LAB_GBYT .res 1; = $C2 ; get current BASIC byte subroutine
Bpntrl .res 1; = $C3 ; BASIC execute (get byte) pointer low byte
Bpntrh .res 1; = Bpntrl+1 ; BASIC execute (get byte) pointer high byte
; reserve bytes for basic char subroutine
__basci_char .res 19; 19 bytes to hold basic char subroutine
; = $D7 ; end of get BASIC char subroutine
; end bulk initialize from LAB_2CEE at LAB_2D4E
Rbyte4 .res 1; = $D8 ; extra PRNG byte
Rbyte1 .res 1; = Rbyte4+1 ; most significant PRNG byte
Rbyte2 .res 1; = Rbyte4+2 ; middle PRNG byte
Rbyte3 .res 1; = Rbyte4+3 ; least significant PRNG byte
NmiBase .res 3; = $DC ; NMI handler enabled/setup/triggered flags
; bit function
; === ========
; 7 interrupt enabled
; 6 interrupt setup
; 5 interrupt happened
; = $DD ; NMI handler addr low byte
; = $DE ; NMI handler addr high byte
IrqBase .res 3; = $DF ; IRQ handler enabled/setup/triggered flags
; = $E0 ; IRQ handler addr low byte
; = $E1 ; IRQ handler addr high byte
; *** removed unused comments for $DE-$E1
; = $E2 ; unused
; = $E3 ; unused
; = $E4 ; unused
; = $E5 ; unused
; = $E6 ; unused
; = $E7 ; unused
; = $E8 ; unused
; = $E9 ; unused
; = $EA ; unused
; = $EB ; unused
; = $EC ; unused
; = $ED ; unused
; = $EE ; unused
Decss .res 1; = $EF ; number to decimal string start
Decssp1 .res 1; = Decss+1 ; number to decimal string start
; = $FF ; decimal string end
; token values needed for BASIC
; primary command tokens (can start a statement)
TK_END = $80 ; END token
TK_FOR = TK_END+1 ; FOR token
TK_NEXT = TK_FOR+1 ; NEXT token
TK_DATA = TK_NEXT+1 ; DATA token
TK_INPUT = TK_DATA+1 ; INPUT token
TK_DIM = TK_INPUT+1 ; DIM token
TK_READ = TK_DIM+1 ; READ token
TK_LET = TK_READ+1 ; LET token
TK_DEC = TK_LET+1 ; DEC token
TK_GOTO = TK_DEC+1 ; GOTO token
TK_RUN = TK_GOTO+1 ; RUN token
TK_IF = TK_RUN+1 ; IF token
TK_RESTORE = TK_IF+1 ; RESTORE token
TK_GOSUB = TK_RESTORE+1 ; GOSUB token
TK_RETIRQ = TK_GOSUB+1 ; RETIRQ token
TK_RETNMI = TK_RETIRQ+1 ; RETNMI token
TK_RETURN = TK_RETNMI+1 ; RETURN token
TK_REM = TK_RETURN+1 ; REM token
TK_STOP = TK_REM+1 ; STOP token
TK_ON = TK_STOP+1 ; ON token
TK_NULL = TK_ON+1 ; NULL token
TK_INC = TK_NULL+1 ; INC token
TK_WAIT = TK_INC+1 ; WAIT token
TK_LOAD = TK_WAIT+1 ; LOAD token
TK_SAVE = TK_LOAD+1 ; SAVE token
TK_DEF = TK_SAVE+1 ; DEF token
TK_POKE = TK_DEF+1 ; POKE token
TK_DOKE = TK_POKE+1 ; DOKE token
TK_CALL = TK_DOKE+1 ; CALL token
TK_DO = TK_CALL+1 ; DO token
TK_LOOP = TK_DO+1 ; LOOP token
TK_PRINT = TK_LOOP+1 ; PRINT token
TK_CONT = TK_PRINT+1 ; CONT token
TK_LIST = TK_CONT+1 ; LIST token
TK_CLEAR = TK_LIST+1 ; CLEAR token
TK_NEW = TK_CLEAR+1 ; NEW token
TK_WIDTH = TK_NEW+1 ; WIDTH token
TK_GET = TK_WIDTH+1 ; GET token
TK_SWAP = TK_GET+1 ; SWAP token
TK_BITSET = TK_SWAP+1 ; BITSET token
TK_BITCLR = TK_BITSET+1 ; BITCLR token
TK_CLS = TK_BITCLR+1 ; CLS token (retro)
TK_BYE = TK_CLS+1 ; BYE token (retro)
TK_BEEP = TK_BYE+1 ; Beep token (retro)
TK_DIR = TK_BEEP+1 ; DIR token (retro)
TK_IRQ = TK_DIR+1 ; IRQ token
TK_NMI = TK_IRQ+1 ; NMI token
; secondary command tokens, can't start a statement
TK_TAB = TK_NMI+1 ; TAB token
TK_ELSE = TK_TAB+1 ; ELSE token
TK_TO = TK_ELSE+1 ; TO token
TK_FN = TK_TO+1 ; FN token
TK_SPC = TK_FN+1 ; SPC token
TK_THEN = TK_SPC+1 ; THEN token
TK_NOT = TK_THEN+1 ; NOT token
TK_STEP = TK_NOT+1 ; STEP token
TK_UNTIL = TK_STEP+1 ; UNTIL token
TK_WHILE = TK_UNTIL+1 ; WHILE token
TK_OFF = TK_WHILE+1 ; OFF token
; opperator tokens
TK_PLUS = TK_OFF+1 ; + token
TK_MINUS = TK_PLUS+1 ; - token
TK_MUL = TK_MINUS+1 ; * token
TK_DIV = TK_MUL+1 ; / token
TK_POWER = TK_DIV+1 ; ^ token
TK_AND = TK_POWER+1 ; AND token
TK_EOR = TK_AND+1 ; EOR token
TK_OR = TK_EOR+1 ; OR token
TK_RSHIFT = TK_OR+1 ; RSHIFT token
TK_LSHIFT = TK_RSHIFT+1 ; LSHIFT token
TK_GT = TK_LSHIFT+1 ; > token
TK_EQUAL = TK_GT+1 ; = token
TK_LT = TK_EQUAL+1 ; < token
; functions tokens
TK_SGN = TK_LT+1 ; SGN token
TK_INT = TK_SGN+1 ; INT token
TK_ABS = TK_INT+1 ; ABS token
TK_USR = TK_ABS+1 ; USR token
TK_FRE = TK_USR+1 ; FRE token
TK_POS = TK_FRE+1 ; POS token
TK_SQR = TK_POS+1 ; SQR token
TK_RND = TK_SQR+1 ; RND token
TK_LOG = TK_RND+1 ; LOG token
TK_EXP = TK_LOG+1 ; EXP token
TK_COS = TK_EXP+1 ; COS token
TK_SIN = TK_COS+1 ; SIN token
TK_TAN = TK_SIN+1 ; TAN token
TK_ATN = TK_TAN+1 ; ATN token
TK_PEEK = TK_ATN+1 ; PEEK token
TK_DEEK = TK_PEEK+1 ; DEEK token
TK_SADD = TK_DEEK+1 ; SADD token
TK_LEN = TK_SADD+1 ; LEN token
TK_STRS = TK_LEN+1 ; STR$ token
TK_VAL = TK_STRS+1 ; VAL token
TK_ASC = TK_VAL+1 ; ASC token
TK_UCASES = TK_ASC+1 ; UCASE$ token
TK_LCASES = TK_UCASES+1 ; LCASE$ token
TK_CHRS = TK_LCASES+1 ; CHR$ token
TK_HEXS = TK_CHRS+1 ; HEX$ token
TK_BINS = TK_HEXS+1 ; BIN$ token
TK_BITTST = TK_BINS+1 ; BITTST token
TK_MAX = TK_BITTST+1 ; MAX token
TK_MIN = TK_MAX+1 ; MIN token
TK_PI = TK_MIN+1 ; PI token
TK_TWOPI = TK_PI+1 ; TWOPI token
TK_VPTR = TK_TWOPI+1 ; VARPTR token
TK_LEFTS = TK_VPTR+1 ; LEFT$ token
TK_RIGHTS = TK_LEFTS+1 ; RIGHT$ token
TK_MIDS = TK_RIGHTS+1 ; MID$ token
; offsets from a base of X or Y
PLUS_0 = $00 ; X or Y plus 0
PLUS_1 = $01 ; X or Y plus 1
PLUS_2 = $02 ; X or Y plus 2
PLUS_3 = $03 ; X or Y plus 3
LAB_STAK = $0100 ; stack bottom, no offset
LAB_SKFE = LAB_STAK+$FE
; flushed stack address
LAB_SKFF = LAB_STAK+$FF
; flushed stack address
; the following locations are bulk initialized from PG2_TABS at LAB_COLD
ccflag = $0700 ; BASIC CTRL-C flag, 00 = enabled, 01 = dis
ccbyte = ccflag+1 ; BASIC CTRL-C byte
ccnull = ccbyte+1 ; BASIC CTRL-C byte timeout
VEC_CC = ccnull+1 ; ctrl c check vector
; end bulk initialize from PG2_TABS at LAB_COLD
; the following locations are bulk initialized by min_mon.asm from LAB_vec at LAB_stlp
VEC_IN = VEC_CC+2 ; input vector
VEC_OUT = VEC_IN+2 ; output vector
VEC_LD = VEC_OUT+2 ; load vector
VEC_SV = VEC_LD+2 ; save vector
; end bulk initialize by min_mon.asm from LAB_vec at LAB_stlp
; Ibuffs can now be anywhere in RAM, ensure that the max length is < $80,
; the input buffer must not cross a page boundary and must not overlap with
; program RAM pages!
;Ibuffs = IRQ_vec+$14
Ibuffs = VEC_SV+$16
; start of input buffer after IRQ/NMI code
Ibuffe = Ibuffs+$80; end of input buffer
Ram_base = $3300 ; start of user RAM (set as needed, should be page aligned)
Ram_top = $BE00 ; end of user RAM+1 (set as needed, should be page aligned)
; need to save a page for extensions here.
Stack_floor = 16 ; bytes left free on stack for background interrupts
; This start can be changed to suit your system
.code
jmp RES_vec
; new page 2 initialisation, copy block to ccflag on
LAB_COLD
LDY #PG2_TABE-PG2_TABS-1
; byte count-1
LAB_2D13
LDA PG2_TABS,Y ; get byte
STA ccflag,Y ; store in page 2
DEY ; decrement count
BPL LAB_2D13 ; loop if not done
LDX #$FF ; set byte
STX Clineh ; set current line high byte (set immediate mode)
TXS ; reset stack pointer
LDA #$4C ; code for JMP
STA Fnxjmp ; save for jump vector for functions
; copy block from LAB_2CEE to $00BC - $00D7
LDX #StrTab-LAB_2CEE ; set byte count
LAB_2D4E
LDA LAB_2CEE-1,X ; get byte from table
STA LAB_IGBY-1,X ; save byte in page zero
DEX ; decrement count
BNE LAB_2D4E ; loop if not all done
; copy block from StrTab to $0000 - $0012
LAB_GMEM
LDX #EndTab-StrTab-1 ; set byte count-1
TabLoop
LDA StrTab,X ; get byte from table
STA PLUS_0,X ; save byte in page zero
DEX ; decrement count
BPL TabLoop ; loop if not all done
; set-up start values
LDA #$00 ; clear A
STA NmiBase ; clear NMI handler enabled flag
STA IrqBase ; clear IRQ handler enabled flag
STA FAC1_o ; clear FAC1 overflow byte
STA last_sh ; clear descriptor stack top item pointer high byte
LDA #$0E ; set default tab size
STA TabSiz ; save it
LDA #$03 ; set garbage collect step size for descriptor stack
STA g_step ; save it
LDX #des_sk ; descriptor stack start
STX next_s ; set descriptor stack pointer
JSR LAB_CRLF ; print CR/LF
LDA #<LAB_MSZM ; point to memory size message (low addr)
LDY #>LAB_MSZM ; point to memory size message (high addr)
JSR LAB_18C3 ; print null terminated string from memory
JSR LAB_INLN ; print "? " and get BASIC input
STX Bpntrl ; set BASIC execute pointer low byte
STY Bpntrh ; set BASIC execute pointer high byte
JSR LAB_GBYT ; get last byte back
BNE LAB_2DAA ; branch if not null (user typed something)
LDY #$00 ; else clear Y
; character was null so get memory size the hard way
; we get here with Y=0 and Itempl/h = Ram_base
LAB_2D93
INC Itempl ; increment temporary integer low byte
BNE LAB_2D99 ; branch if no overflow
INC Itemph ; increment temporary integer high byte
LDA Itemph ; get high byte
CMP #>Ram_top ; compare with top of RAM+1
BEQ LAB_2DB6 ; branch if match (end of user RAM)
LAB_2D99
LDA #$55 ; set test byte
STA (Itempl),Y ; save via temporary integer
CMP (Itempl),Y ; compare via temporary integer
BNE LAB_2DB6 ; branch if fail
ASL ; shift test byte left (now $AA)
STA (Itempl),Y ; save via temporary integer
CMP (Itempl),Y ; compare via temporary integer
BEQ LAB_2D93 ; if ok go do next byte
BNE LAB_2DB6 ; branch if fail
LAB_2DAA
JSR LAB_2887 ; get FAC1 from string
LDA FAC1_e ; get FAC1 exponent
CMP #$98 ; compare with exponent = 2^24
BCS LAB_GMEM ; if too large go try again
JSR LAB_F2FU ; save integer part of FAC1 in temporary integer
; (no range check)
LAB_2DB6
LDA Itempl ; get temporary integer low byte
LDY Itemph ; get temporary integer high byte
; *** begin patch 2.22p5.0 RAM top sanity check ***
; *** replace
; CPY #<Ram_base+1 ; compare with start of RAM+$100 high byte
; +++ with
CPY #>Ram_base+1 ; compare with start of RAM+$100 high byte
; *** end patch 2.22p5.0 ***
BCC LAB_GMEM ; if too small go try again
; uncomment these lines if you want to check on the high limit of memory. Note if
; Ram_top is set too low then this will fail. default is ignore it and assume the
; users know what they're doing!
; CPY #>Ram_top ; compare with top of RAM high byte
; BCC MEM_OK ; branch if < RAM top
; BNE LAB_GMEM ; if too large go try again
; else was = so compare low bytes
; CMP #<Ram_top ; compare with top of RAM low byte
; BEQ MEM_OK ; branch if = RAM top
; BCS LAB_GMEM ; if too large go try again
;MEM_OK
STA Ememl ; set end of mem low byte
STY Ememh ; set end of mem high byte
STA Sstorl ; set bottom of string space low byte
STY Sstorh ; set bottom of string space high byte
LDY #<Ram_base ; set start addr low byte
LDX #>Ram_base ; set start addr high byte
STY Smeml ; save start of mem low byte
STX Smemh ; save start of mem high byte
; this line is only needed if Ram_base is not $xx00
.IF Ram_base&$FF>0
LDY #$00 ; clear Y
.ENDIF
TYA ; clear A
STA (Smeml),Y ; clear first byte
INC Smeml ; increment start of mem low byte
; these two lines are only needed if Ram_base is $xxFF
.IF Ram_base&$FF=$FF
BNE LAB_2E05 ; branch if no rollover
INC Smemh ; increment start of mem high byte
LAB_2E05
.ENDIF
JSR LAB_CRLF ; print CR/LF
JSR LAB_1463 ; do "NEW" and "CLEAR"
LDA Ememl ; get end of mem low byte
SEC ; set carry for subtract
SBC Smeml ; subtract start of mem low byte
TAX ; copy to X
LDA Ememh ; get end of mem high byte
SBC Smemh ; subtract start of mem high byte
JSR LAB_295E ; print XA as unsigned integer (bytes free)
LDA #<LAB_SMSG ; point to sign-on message (low addr)
LDY #>LAB_SMSG ; point to sign-on message (high addr)
JSR LAB_18C3 ; print null terminated string from memory
LDA #<LAB_1274 ; warm start vector low byte
LDY #>LAB_1274 ; warm start vector high byte
STA Wrmjpl ; save warm start vector low byte
STY Wrmjph ; save warm start vector high byte
JMP (Wrmjpl) ; go do warm start
; open up space in memory
; move (Ostrtl)-(Obendl) to new block ending at (Nbendl)
; Nbendl,Nbendh - new block end address (A/Y)
; Obendl,Obendh - old block end address
; Ostrtl,Ostrth - old block start address
; returns with ..
; Nbendl,Nbendh - new block start address (high byte - $100)
; Obendl,Obendh - old block start address (high byte - $100)
; Ostrtl,Ostrth - old block start address (unchanged)
LAB_11CF
JSR LAB_121F ; check available memory, "Out of memory" error if no room
; addr to check is in AY (low/high)
STA Earryl ; save new array mem end low byte
STY Earryh ; save new array mem end high byte
; open up space in memory
; move (Ostrtl)-(Obendl) to new block ending at (Nbendl)
; don't set array end
LAB_11D6
SEC ; set carry for subtract
LDA Obendl ; get block end low byte
SBC Ostrtl ; subtract block start low byte
TAY ; copy MOD(block length/$100) byte to Y
LDA Obendh ; get block end high byte
SBC Ostrth ; subtract block start high byte
TAX ; copy block length high byte to X
INX ; +1 to allow for count=0 exit
TYA ; copy block length low byte to A
BEQ LAB_120A ; branch if length low byte=0
; block is (X-1)*256+Y bytes, do the Y bytes first
SEC ; set carry for add + 1, two's complement
EOR #$FF ; invert low byte for subtract
ADC Obendl ; add block end low byte
STA Obendl ; save corrected old block end low byte
BCS LAB_11F3 ; branch if no underflow
DEC Obendh ; else decrement block end high byte
SEC ; set carry for add + 1, two's complement
LAB_11F3
TYA ; get MOD(block length/$100) byte
EOR #$FF ; invert low byte for subtract
ADC Nbendl ; add destination end low byte
STA Nbendl ; save modified new block end low byte
BCS LAB_1203 ; branch if no underflow
DEC Nbendh ; else decrement block end high byte
BCC LAB_1203 ; branch always
LAB_11FF
LDA (Obendl),Y ; get byte from source
STA (Nbendl),Y ; copy byte to destination
LAB_1203
DEY ; decrement index
BNE LAB_11FF ; loop until Y=0
; now do Y=0 indexed byte
LDA (Obendl),Y ; get byte from source
STA (Nbendl),Y ; save byte to destination
LAB_120A
DEC Obendh ; decrement source pointer high byte
DEC Nbendh ; decrement destination pointer high byte
DEX ; decrement block count
BNE LAB_1203 ; loop until count = $0
RTS
; check room on stack for A bytes
; stack too deep? do OM error
LAB_1212
; *** patch - additional stack floor protection for background interrupts
; *** add
.IF Stack_floor
CLC ; prep ADC
ADC #Stack_floor ; stack pointer lower limit before interrupts
.ENDIF
; *** end patch
STA TempB ; save result in temp byte
TSX ; copy stack
CPX TempB ; compare new "limit" with stack
BCC LAB_OMER ; if stack < limit do "Out of memory" error then warm start
RTS
; check available memory, "Out of memory" error if no room
; addr to check is in AY (low/high)
LAB_121F
CPY Sstorh ; compare bottom of string mem high byte
BCC LAB_124B ; if less then exit (is ok)
BNE LAB_1229 ; skip next test if greater (tested <)
; high byte was =, now do low byte
CMP Sstorl ; compare with bottom of string mem low byte
BCC LAB_124B ; if less then exit (is ok)
; addr is > string storage ptr (oops!)
LAB_1229
PHA ; push addr low byte
LDX #$08 ; set index to save Adatal to expneg inclusive
TYA ; copy addr high byte (to push on stack)
; save misc numeric work area
LAB_122D
PHA ; push byte
LDA Adatal-1,X ; get byte from Adatal to expneg ( ,$00 not pushed)
DEX ; decrement index
BPL LAB_122D ; loop until all done
JSR LAB_GARB ; garbage collection routine
; restore misc numeric work area
LDX #$00 ; clear the index to restore bytes
LAB_1238
PLA ; pop byte
STA Adatal,X ; save byte to Adatal to expneg
INX ; increment index
CPX #$08 ; compare with end + 1
BMI LAB_1238 ; loop if more to do
PLA ; pop addr high byte
TAY ; copy back to Y
PLA ; pop addr low byte
CPY Sstorh ; compare bottom of string mem high byte
BCC LAB_124B ; if less then exit (is ok)
BNE LAB_OMER ; if greater do "Out of memory" error then warm start
; high byte was =, now do low byte
CMP Sstorl ; compare with bottom of string mem low byte
BCS LAB_OMER ; if >= do "Out of memory" error then warm start
; ok exit, carry clear
LAB_124B
RTS
; do "Out of memory" error then warm start
LAB_OMER
LDX #$0C ; error code $0C ("Out of memory" error)
; do error #X, then warm start
LAB_XERR
JSR LAB_CRLF ; print CR/LF
LDA LAB_BAER,X ; get error message pointer low byte
LDY LAB_BAER+1,X ; get error message pointer high byte
JSR LAB_18C3 ; print null terminated string from memory
JSR LAB_1491 ; flush stack and clear continue flag
LDA #<LAB_EMSG ; point to " Error" low addr
LDY #>LAB_EMSG ; point to " Error" high addr
LAB_1269
JSR LAB_18C3 ; print null terminated string from memory
LDY Clineh ; get current line high byte
INY ; increment it
BEQ LAB_1274 ; go do warm start (was immediate mode)
; else print line number
JSR LAB_2953 ; print " in line [LINE #]"
; BASIC warm start entry point
; wait for Basic command
LAB_1274
; clear ON IRQ/NMI bytes
LDA #$00 ; clear A
STA IrqBase ; clear enabled byte
STA NmiBase ; clear enabled byte
LDA #<LAB_RMSG ; point to "Ready" message low byte
LDY #>LAB_RMSG ; point to "Ready" message high byte
JSR LAB_18C3 ; go do print string
; wait for Basic command (no "Ready")
LAB_127D
JSR LAB_1357 ; call for BASIC input
LAB_1280
STX Bpntrl ; set BASIC execute pointer low byte
STY Bpntrh ; set BASIC execute pointer high byte
JSR LAB_GBYT ; scan memory
BEQ LAB_127D ; loop while null
; got to interpret input line now ..
LDX #$FF ; current line to null value
STX Clineh ; set current line high byte
BCC LAB_1295 ; branch if numeric character (handle new BASIC line)
; no line number .. immediate mode
JSR LAB_13A6 ; crunch keywords into Basic tokens
JMP LAB_15F6 ; go scan and interpret code
; handle new BASIC line
LAB_1295
JSR LAB_GFPN ; get fixed-point number into temp integer
JSR LAB_13A6 ; crunch keywords into Basic tokens
STY Ibptr ; save index pointer to end of crunched line
JSR LAB_SSLN ; search BASIC for temp integer line number
BCC LAB_12E6 ; branch if not found
; aroooogah! line # already exists! delete it
LDY #$01 ; set index to next line pointer high byte
LDA (Baslnl),Y ; get next line pointer high byte
STA ut1_ph ; save it
LDA Svarl ; get start of vars low byte
STA ut1_pl ; save it
LDA Baslnh ; get found line pointer high byte
STA ut2_ph ; save it
LDA Baslnl ; get found line pointer low byte
DEY ; decrement index
SBC (Baslnl),Y ; subtract next line pointer low byte
CLC ; clear carry for add
ADC Svarl ; add start of vars low byte
STA Svarl ; save new start of vars low byte
STA ut2_pl ; save destination pointer low byte
LDA Svarh ; get start of vars high byte
ADC #$FF ; -1 + carry
STA Svarh ; save start of vars high byte
SBC Baslnh ; subtract found line pointer high byte
TAX ; copy to block count
SEC ; set carry for subtract
LDA Baslnl ; get found line pointer low byte
SBC Svarl ; subtract start of vars low byte
TAY ; copy to bytes in first block count
BCS LAB_12D0 ; branch if overflow
INX ; increment block count (correct for =0 loop exit)
DEC ut2_ph ; decrement destination high byte
LAB_12D0
CLC ; clear carry for add
ADC ut1_pl ; add source pointer low byte
BCC LAB_12D8 ; branch if no overflow
DEC ut1_ph ; else decrement source pointer high byte
CLC ; clear carry
; close up memory to delete old line
LAB_12D8
LDA (ut1_pl),Y ; get byte from source
STA (ut2_pl),Y ; copy to destination
INY ; increment index
BNE LAB_12D8 ; while <> 0 do this block
INC ut1_ph ; increment source pointer high byte
INC ut2_ph ; increment destination pointer high byte
DEX ; decrement block count
BNE LAB_12D8 ; loop until all done
; got new line in buffer and no existing same #
LAB_12E6
LDA Ibuffs ; get byte from start of input buffer
BEQ LAB_1319 ; if null line just go flush stack/vars and exit
; got new line and it isn't empty line
LDA Ememl ; get end of mem low byte
LDY Ememh ; get end of mem high byte
STA Sstorl ; set bottom of string space low byte
STY Sstorh ; set bottom of string space high byte
LDA Svarl ; get start of vars low byte (end of BASIC)
STA Obendl ; save old block end low byte
LDY Svarh ; get start of vars high byte (end of BASIC)
STY Obendh ; save old block end high byte
ADC Ibptr ; add input buffer pointer (also buffer length)
BCC LAB_1301 ; branch if no overflow from add
INY ; else increment high byte
LAB_1301
STA Nbendl ; save new block end low byte (move to, low byte)
STY Nbendh ; save new block end high byte
JSR LAB_11CF ; open up space in memory
; old start pointer Ostrtl,Ostrth set by the find line call
LDA Earryl ; get array mem end low byte
LDY Earryh ; get array mem end high byte
STA Svarl ; save start of vars low byte
STY Svarh ; save start of vars high byte
LDY Ibptr ; get input buffer pointer (also buffer length)
DEY ; adjust for loop type
LAB_1311
LDA Ibuffs-4,Y ; get byte from crunched line
STA (Baslnl),Y ; save it to program memory
DEY ; decrement count
CPY #$03 ; compare with first byte-1
BNE LAB_1311 ; continue while count <> 3
LDA Itemph ; get line # high byte
STA (Baslnl),Y ; save it to program memory
DEY ; decrement count
LDA Itempl ; get line # low byte
STA (Baslnl),Y ; save it to program memory
DEY ; decrement count
LDA #$FF ; set byte to allow chain rebuild. if you didn't set this
; byte then a zero already here would stop the chain rebuild
; as it would think it was the [EOT] marker.
STA (Baslnl),Y ; save it to program memory
LAB_1319
JSR LAB_1477 ; reset execution to start, clear vars and flush stack
LDX Smeml ; get start of mem low byte
LDA Smemh ; get start of mem high byte
LDY #$01 ; index to high byte of next line pointer
LAB_1325
STX ut1_pl ; set line start pointer low byte
STA ut1_ph ; set line start pointer high byte
LDA (ut1_pl),Y ; get it
BEQ LAB_133E ; exit if end of program
; rebuild chaining of Basic lines
LDY #$04 ; point to first code byte of line
; there is always 1 byte + [EOL] as null entries are deleted
LAB_1330
INY ; next code byte
LDA (ut1_pl),Y ; get byte
BNE LAB_1330 ; loop if not [EOL]
SEC ; set carry for add + 1
TYA ; copy end index
ADC ut1_pl ; add to line start pointer low byte
TAX ; copy to X
LDY #$00 ; clear index, point to this line's next line pointer
STA (ut1_pl),Y ; set next line pointer low byte
TYA ; clear A
ADC ut1_ph ; add line start pointer high byte + carry
INY ; increment index to high byte
STA (ut1_pl),Y ; save next line pointer low byte
BCC LAB_1325 ; go do next line, branch always, carry clear
LAB_133E
JMP LAB_127D ; else we just wait for Basic command, no "Ready"
; print "? " and get BASIC input
LAB_INLN
JSR LAB_18E3 ; print "?" character
JSR LAB_18E0 ; print " "
BNE LAB_1357 ; call for BASIC input and return
; receive line from keyboard
; $08 as delete key (BACKSPACE on standard keyboard)
LAB_134B
JSR LAB_PRNA ; go print the character
DEX ; decrement the buffer counter (delete)
.byte $2C ; make LDX into BIT abs
; call for BASIC input (main entry point)
LAB_1357
LDX #$00 ; clear BASIC line buffer pointer
LAB_1359
JSR V_INPT ; call scan input device
BCC LAB_1359 ; loop if no byte
BEQ LAB_1359 ; loop until valid input (ignore NULLs)
CMP #$07 ; compare with [BELL]
BEQ LAB_1378 ; branch if [BELL]
CMP #$0D ; compare with [CR]
BEQ LAB_1384 ; do CR/LF exit if [CR]
CPX #$00 ; compare pointer with $00
BNE LAB_1374 ; branch if not empty
; next two lines ignore any non print character and [SPACE] if input buffer empty
CMP #$21 ; compare with [SP]+1
BCC LAB_1359 ; if < ignore character
LAB_1374
CMP #$08 ; compare with [BACKSPACE] (delete last character)
BEQ LAB_134B ; go delete last character
LAB_1378
CPX #Ibuffe-Ibuffs ; compare character count with max
BCS LAB_138E ; skip store and do [BELL] if buffer full
STA Ibuffs,X ; else store in buffer
INX ; increment pointer
LAB_137F
JSR LAB_PRNA ; go print the character
BNE LAB_1359 ; always loop for next character
LAB_1384
JMP LAB_1866 ; do CR/LF exit to BASIC
; announce buffer full
LAB_138E
LDA #$07 ; [BELL] character into A
BNE LAB_137F ; go print the [BELL] but ignore input character
; branch always
; crunch keywords into Basic tokens
; position independent buffer version ..
; faster, dictionary search version ....
LAB_13A6
LDY #$FF ; set save index (makes for easy math later)
SEC ; set carry for subtract
LDA Bpntrl ; get basic execute pointer low byte
SBC #<Ibuffs ; subtract input buffer start pointer
TAX ; copy result to X (index past line # if any)
STX Oquote ; clear open quote/DATA flag
LAB_13AC
LDA Ibuffs,X ; get byte from input buffer
BEQ LAB_13EC ; if null save byte then exit
; *** begin patch: lower case token recognition V2 ***
; *** WARNING! changes documented behavior!
; *** add
CMP #'{' ; convert lower to upper case
BCS LAB_13EC ; is above lower case
CMP #'a'
BCC PATCH_LC ; is below lower case
AND #$DF ; mask lower case bit
PATCH_LC
; *** end
CMP #'_' ; compare with "_"
BCS LAB_13EC ; if >= go save byte then continue crunching
CMP #'<' ; compare with "<"
BCS LAB_13CC ; if >= go crunch now
CMP #'0' ; compare with "0"
BCS LAB_13EC ; if >= go save byte then continue crunching
STA Scnquo ; save buffer byte as search character
CMP #$22 ; is it quote character?
BEQ LAB_1410 ; branch if so (copy quoted string)
CMP #'*' ; compare with "*"
BCC LAB_13EC ; if < go save byte then continue crunching
; else crunch now
LAB_13CC
BIT Oquote ; get open quote/DATA token flag
BVS LAB_13EC ; branch if b6 of Oquote set (was DATA)
; go save byte then continue crunching
STX TempB ; save buffer read index
STY csidx ; copy buffer save index
LDY #<TAB_1STC ; get keyword first character table low address
STY ut2_pl ; save pointer low byte
LDY #>TAB_1STC ; get keyword first character table high address
STY ut2_ph ; save pointer high byte
LDY #$00 ; clear table pointer
LAB_13D0
CMP (ut2_pl),Y ; compare with keyword first character table byte
BEQ LAB_13D1 ; go do word_table_chr if match
BCC PATCH_LC2 ; if < keyword first character table byte go restore
; Y and save to crunched
INY ; else increment pointer
BNE LAB_13D0 ; and loop (branch always)
; have matched first character of some keyword
LAB_13D1
TYA ; copy matching index
ASL ; *2 (bytes per pointer)
TAX ; copy to new index
LDA TAB_CHRT,X ; get keyword table pointer low byte
STA ut2_pl ; save pointer low byte
LDA TAB_CHRT+1,X ; get keyword table pointer high byte
STA ut2_ph ; save pointer high byte
LDY #$FF ; clear table pointer (make -1 for start)
LDX TempB ; restore buffer read index
LAB_13D6
INY ; next table byte
LDA (ut2_pl),Y ; get byte from table
LAB_13D8
BMI LAB_13EA ; all bytes matched so go save token
INX ; next buffer byte
EOR Ibuffs,x ; check bits against table
AND #$DF ; DF masks the upper/lower case bit
BEQ LAB_13D6 ; go compare next if match
BNE LAB_1417 ; branch if >< (not found keyword)
LAB_13EA
LDY csidx ; restore save index
; save crunched to output
LAB_13EC
INX ; increment buffer index (to next input byte)
INY ; increment save index (to next output byte)
STA Ibuffs,Y ; save byte to output
CMP #$00 ; set the flags, set carry
BEQ LAB_142A ; do exit if was null [EOL]
; A holds token or byte here
SBC #':' ; subtract ":" (carry set by CMP #00)
BEQ LAB_13FF ; branch if it was ":" (is now $00)
; A now holds token-$3A
CMP #TK_DATA-$3A ; compare with DATA token - $3A
BNE LAB_1401 ; branch if not DATA
; token was : or DATA
LAB_13FF
STA Oquote ; save token-$3A (clear for ":", TK_DATA-$3A for DATA)
LAB_1401
EOR #TK_REM-$3A ; effectively subtract REM token offset
BNE LAB_13AC ; If wasn't REM then go crunch rest of line
STA Asrch ; else was REM so set search for [EOL]
; loop for REM, "..." etc.
LAB_1408
LDA Ibuffs,X ; get byte from input buffer
BEQ LAB_13EC ; branch if null [EOL]
CMP Asrch ; compare with stored character
BEQ LAB_13EC ; branch if match (end quote)
; entry for copy string in quotes, don't crunch
LAB_1410
INY ; increment buffer save index
STA Ibuffs,Y ; save byte to output
INX ; increment buffer read index
BNE LAB_1408 ; loop while <> 0 (should never be 0!)
; not found keyword this go
LAB_1417
LDX TempB ; compare has failed, restore buffer index (start byte!)
; now find the end of this word in the table
LAB_141B
LDA (ut2_pl),Y ; get table byte
PHP ; save status
INY ; increment table index
PLP ; restore byte status
BPL LAB_141B ; if not end of keyword go do next
LDA (ut2_pl),Y ; get byte from keyword table
BNE LAB_13D8 ; go test next word if not zero byte (end of table)
; reached end of table with no match
PATCH_LC2
LDA Ibuffs,X ; restore byte from input buffer
BPL LAB_13EA ; branch always (all bytes in buffer are $00-$7F)
; go save byte in output and continue crunching
; reached [EOL]
LAB_142A
INY ; increment pointer
INY ; increment pointer (makes it next line pointer high byte)
STA Ibuffs,Y ; save [EOL] (marks [EOT] in immediate mode)
INY ; adjust for line copy
INY ; adjust for line copy
INY ; adjust for line copy
; *** begin patch for when Ibuffs is $xx00 - Daryl Rictor ***
; *** insert
.IF Ibuffs&$FF=0
LDA Bpntrl ; test for $00
BNE LAB_142P ; not $00
DEC Bpntrh ; allow for increment when $xx00
LAB_142P
.ENDIF
; *** end patch for when Ibuffs is $xx00 - Daryl Rictor ***
; end of patch
DEC Bpntrl ; allow for increment
RTS
; search Basic for temp integer line number from start of mem
LAB_SSLN
LDA Smeml ; get start of mem low byte
LDX Smemh ; get start of mem high byte
; search Basic for temp integer line number from AX
; returns carry set if found
; returns Baslnl/Baslnh pointer to found or next higher (not found) line
; old 541 new 507
LAB_SHLN
LDY #$01 ; set index
STA Baslnl ; save low byte as current
STX Baslnh ; save high byte as current
LDA (Baslnl),Y ; get pointer high byte from addr
BEQ LAB_145F ; pointer was zero so we're done, do 'not found' exit
LDY #$03 ; set index to line # high byte
LDA (Baslnl),Y ; get line # high byte
DEY ; decrement index (point to low byte)
CMP Itemph ; compare with temporary integer high byte
BNE LAB_1455 ; if <> skip low byte check
LDA (Baslnl),Y ; get line # low byte
CMP Itempl ; compare with temporary integer low byte
LAB_1455
BCS LAB_145E ; else if temp < this line, exit (passed line#)
LAB_1456
DEY ; decrement index to next line ptr high byte
LDA (Baslnl),Y ; get next line pointer high byte
TAX ; copy to X
DEY ; decrement index to next line ptr low byte
LDA (Baslnl),Y ; get next line pointer low byte
BCC LAB_SHLN ; go search for line # in temp (Itempl/Itemph) from AX
; (carry always clear)
LAB_145E
BEQ LAB_1460 ; exit if temp = found line #, carry is set
LAB_145F
CLC ; clear found flag
LAB_1460
RTS
; perform NEW
LAB_NEW
BNE LAB_1460 ; exit if not end of statement (to do syntax error)
LAB_1463
LDA #$00 ; clear A
TAY ; clear Y
STA (Smeml),Y ; clear first line, next line pointer, low byte
INY ; increment index
STA (Smeml),Y ; clear first line, next line pointer, high byte
CLC ; clear carry
LDA Smeml ; get start of mem low byte
ADC #$02 ; calculate end of BASIC low byte
STA Svarl ; save start of vars low byte
LDA Smemh ; get start of mem high byte
ADC #$00 ; add any carry
STA Svarh ; save start of vars high byte
; reset execution to start, clear vars and flush stack
LAB_1477
CLC ; clear carry
LDA Smeml ; get start of mem low byte
ADC #$FF ; -1
STA Bpntrl ; save BASIC execute pointer low byte
LDA Smemh ; get start of mem high byte
ADC #$FF ; -1+carry
STA Bpntrh ; save BASIC execute pointer high byte
; "CLEAR" command gets here
LAB_147A
LDA Ememl ; get end of mem low byte
LDY Ememh ; get end of mem high byte
STA Sstorl ; set bottom of string space low byte
STY Sstorh ; set bottom of string space high byte
LDA Svarl ; get start of vars low byte
LDY Svarh ; get start of vars high byte
STA Sarryl ; save var mem end low byte
STY Sarryh ; save var mem end high byte
STA Earryl ; save array mem end low byte
STY Earryh ; save array mem end high byte
JSR LAB_161A ; perform RESTORE command
; flush stack and clear continue flag
LAB_1491
LDX #des_sk ; set descriptor stack pointer
STX next_s ; save descriptor stack pointer
PLA ; pull return address low byte
TAX ; copy return address low byte
PLA ; pull return address high byte
STX LAB_SKFE ; save to cleared stack
STA LAB_SKFF ; save to cleared stack
LDX #$FD ; new stack pointer
TXS ; reset stack
LDA #$00 ; clear byte
;*** fix p2: no longer necessary as the continue pointer is saved anyway
; STA Cpntrh ; clear continue pointer high byte
STA Sufnxf ; clear subscript/FNX flag
LAB_14A6
RTS
; perform CLEAR
LAB_CLEAR
BEQ LAB_147A ; if no following token go do "CLEAR"
; else there was a following token (go do syntax error)
RTS
; perform LIST [n][-m]
; bigger, faster version (a _lot_ faster)
LAB_LIST
BCC LAB_14BD ; branch if next character numeric (LIST n..)
BEQ LAB_14BD ; branch if next character [NULL] (LIST)
CMP #TK_MINUS ; compare with token for -
BNE LAB_14A6 ; exit if not - (LIST -m)
; LIST [[n][-m]]
; this bit sets the n , if present, as the start and end
LAB_14BD
JSR LAB_GFPN ; get fixed-point number into temp integer
JSR LAB_SSLN ; search BASIC for temp integer line number
; (pointer in Baslnl/Baslnh)
JSR LAB_GBYT ; scan memory
BEQ LAB_14D4 ; branch if no more characters
; this bit checks the - is present
CMP #TK_MINUS ; compare with token for -
BNE LAB_1460 ; return if not "-" (will be Syntax error)
; LIST [n]-m
; the - was there so set m as the end value
JSR LAB_IGBY ; increment and scan memory
JSR LAB_GFPN ; get fixed-point number into temp integer
BNE LAB_1460 ; exit if not ok
LAB_14D4
LDA Itempl ; get temporary integer low byte
ORA Itemph ; OR temporary integer high byte
BNE LAB_14E2 ; branch if start set
LDA #$FF ; set for -1
STA Itempl ; set temporary integer low byte
STA Itemph ; set temporary integer high byte
LAB_14E2
LDY #$01 ; set index for line
STY Oquote ; clear open quote flag
JSR LAB_CRLF ; print CR/LF
LDA (Baslnl),Y ; get next line pointer high byte
; pointer initially set by search at LAB_14BD
BEQ LAB_152B ; if null all done so exit
JSR LAB_1629 ; do CRTL-C check vector
INY ; increment index for line
LDA (Baslnl),Y ; get line # low byte
TAX ; copy to X
INY ; increment index
LDA (Baslnl),Y ; get line # high byte
CMP Itemph ; compare with temporary integer high byte
BNE LAB_14FF ; branch if no high byte match
CPX Itempl ; compare with temporary integer low byte
BEQ LAB_1501 ; branch if = last line to do (< will pass next branch)
LAB_14FF ; else ..
BCS LAB_152B ; if greater all done so exit
LAB_1501
STY Tidx1 ; save index for line
JSR LAB_295E ; print XA as unsigned integer
LDA #$20 ; space is the next character
LAB_1508
LDY Tidx1 ; get index for line
AND #$7F ; mask top out bit of character
LAB_150C
JSR LAB_PRNA ; go print the character
CMP #$22 ; was it " character
BNE LAB_1519 ; branch if not
; we are either entering or leaving a pair of quotes
LDA Oquote ; get open quote flag
EOR #$FF ; toggle it
STA Oquote ; save it back
LAB_1519
INY ; increment index
LDA (Baslnl),Y ; get next byte
BNE LAB_152E ; branch if not [EOL] (go print character)
TAY ; else clear index
LDA (Baslnl),Y ; get next line pointer low byte
TAX ; copy to X
INY ; increment index
LDA (Baslnl),Y ; get next line pointer high byte
STX Baslnl ; set pointer to line low byte
STA Baslnh ; set pointer to line high byte
BNE LAB_14E2 ; go do next line if not [EOT]
; else ..
LAB_152B
RTS
LAB_152E
BPL LAB_150C ; just go print it if not token byte
; else was token byte so uncrunch it (maybe)
BIT Oquote ; test the open quote flag
BMI LAB_150C ; just go print character if open quote set
LDX #>LAB_KEYT ; get table address high byte
ASL ; *2
ASL ; *4
BCC LAB_152F ; branch if no carry
INX ; else increment high byte
CLC ; clear carry for add
LAB_152F
ADC #<LAB_KEYT ; add low byte
BCC LAB_1530 ; branch if no carry
INX ; else increment high byte
LAB_1530
STA ut2_pl ; save table pointer low byte
STX ut2_ph ; save table pointer high byte
STY Tidx1 ; save index for line
LDY #$00 ; clear index
LDA (ut2_pl),Y ; get length
TAX ; copy length
INY ; increment index
LDA (ut2_pl),Y ; get 1st character
DEX ; decrement length
BEQ LAB_1508 ; if no more characters exit and print
JSR LAB_PRNA ; go print the character
INY ; increment index
LDA (ut2_pl),Y ; get keyword address low byte
PHA ; save it for now
INY ; increment index
LDA (ut2_pl),Y ; get keyword address high byte
LDY #$00
STA ut2_ph ; save keyword pointer high byte
PLA ; pull low byte
STA ut2_pl ; save keyword pointer low byte
LAB_1540
LDA (ut2_pl),Y ; get character
DEX ; decrement character count
BEQ LAB_1508 ; if last character exit and print
JSR LAB_PRNA ; go print the character
INY ; increment index
BNE LAB_1540 ; loop for next character
; perform FOR
LAB_FOR
LDA #$80 ; set FNX
STA Sufnxf ; set subscript/FNX flag
JSR LAB_LET ; go do LET
PLA ; pull return address
PLA ; pull return address
LDA #$10 ; we need 16d bytes !
JSR LAB_1212 ; check room on stack for A bytes
JSR LAB_SNBS ; scan for next BASIC statement ([:] or [EOL])
CLC ; clear carry for add
TYA ; copy index to A
ADC Bpntrl ; add BASIC execute pointer low byte
PHA ; push onto stack
LDA Bpntrh ; get BASIC execute pointer high byte
ADC #$00 ; add carry
PHA ; push onto stack
LDA Clineh ; get current line high byte
PHA ; push onto stack
LDA Clinel ; get current line low byte
PHA ; push onto stack
LDA #TK_TO ; get "TO" token
JSR LAB_SCCA ; scan for CHR$(A) , else do syntax error then warm start
JSR LAB_CTNM ; check if source is numeric, else do type mismatch
JSR LAB_EVNM ; evaluate expression and check is numeric,
; else do type mismatch
; *** begin patch 2.22p5.1 TO expression may get sign bit flipped
; *** add
JSR LAB_27BA ; round FAC1
; *** end patch 2.22p5.1 TO expression may get sign bit flipped
LDA FAC1_s ; get FAC1 sign (b7)
ORA #$7F ; set all non sign bits
AND FAC1_1 ; and FAC1 mantissa1
STA FAC1_1 ; save FAC1 mantissa1
LDA #<LAB_159F ; set return address low byte
LDY #>LAB_159F ; set return address high byte
STA ut1_pl ; save return address low byte
STY ut1_ph ; save return address high byte
JMP LAB_1B66 ; round FAC1 and put on stack (returns to next instruction)
LAB_159F
LDA #<LAB_259C ; set 1 pointer low addr (default step size)
LDY #>LAB_259C ; set 1 pointer high addr
JSR LAB_UFAC ; unpack memory (AY) into FAC1
JSR LAB_GBYT ; scan memory
CMP #TK_STEP ; compare with STEP token
BNE LAB_15B3 ; jump if not "STEP"
;.was step so ..
JSR LAB_IGBY ; increment and scan memory
JSR LAB_EVNM ; evaluate expression and check is numeric,
; else do type mismatch
LAB_15B3
JSR LAB_27CA ; return A=FF,C=1/-ve A=01,C=0/+ve
STA FAC1_s ; set FAC1 sign (b7)
; this is +1 for +ve step and -1 for -ve step, in NEXT we
; compare the FOR value and the TO value and return +1 if
; FOR > TO, 0 if FOR = TO and -1 if FOR < TO. the value
; here (+/-1) is then compared to that result and if they
; are the same (+ve and FOR > TO or -ve and FOR < TO) then
; the loop is done
; *** begin patch 2.22p5.3 potential return address -$100 (page not incremented) ***
; *** add
; note MB: Unable to port to ca65 assembly
; .IF [* & $FF] == $FD
; NOP ; return address of JSR +1 (on next page)
; .ENDIF
; *** end patch 2.22p5.3 potential return address -$100 (page not incremented) ***
JSR LAB_1B5B ; push sign, round FAC1 and put on stack
LDA Frnxth ; get var pointer for FOR/NEXT high byte
PHA ; push on stack
LDA Frnxtl ; get var pointer for FOR/NEXT low byte
PHA ; push on stack
LDA #TK_FOR ; get FOR token
PHA ; push on stack
; interpreter inner loop
LAB_15C2
JSR LAB_1629 ; do CRTL-C check vector
LDA Bpntrl ; get BASIC execute pointer low byte
LDY Bpntrh ; get BASIC execute pointer high byte
LDX Clineh ; continue line is $FFxx for immediate mode
; ($00xx for RUN from immediate mode)
INX ; increment it (now $00 if immediate mode)
;*** fix p2: skip no longer necessary as the continue pointer is saved anyway
; BEQ LAB_15D1 ; branch if null (immediate mode)
STA Cpntrl ; save continue pointer low byte
STY Cpntrh ; save continue pointer high byte
LAB_15D1
LDY #$00 ; clear index
LDA (Bpntrl),Y ; get next byte
BEQ LAB_15DC ; branch if null [EOL]
CMP #':' ; compare with ":"
BEQ LAB_15F6 ; branch if = (statement separator)
LAB_15D9
JMP LAB_SNER ; else syntax error then warm start
; have reached [EOL]
LAB_15DC
LDY #$02 ; set index
LDA (Bpntrl),Y ; get next line pointer high byte
CLC ; clear carry for no "BREAK" message
BEQ LAB_1651 ; if null go to immediate mode (was immediate or [EOT]
; marker)
INY ; increment index
LDA (Bpntrl),Y ; get line # low byte
STA Clinel ; save current line low byte
INY ; increment index
LDA (Bpntrl),Y ; get line # high byte
STA Clineh ; save current line high byte
TYA ; A now = 4
ADC Bpntrl ; add BASIC execute pointer low byte
STA Bpntrl ; save BASIC execute pointer low byte
BCC LAB_15F6 ; branch if no overflow
INC Bpntrh ; else increment BASIC execute pointer high byte
LAB_15F6
JSR LAB_IGBY ; increment and scan memory
LAB_15F9
JSR LAB_15FF ; go interpret BASIC code from (Bpntrl)
LAB_15FC
JMP LAB_15C2 ; loop
; interpret BASIC code from (Bpntrl)
LAB_15FF
BEQ LAB_1628 ; exit if zero [EOL]
LAB_1602
ASL ; *2 bytes per vector and normalise token
BCS LAB_1609 ; branch if was token
JMP LAB_LET ; else go do implied LET
LAB_1609
CMP #(TK_TAB-$80)*2 ; compare normalised token * 2 with TAB
BCS LAB_15D9 ; branch if A>=TAB (do syntax error then warm start)
; only tokens before TAB can start a line
TAY ; copy to index
LDA LAB_CTBL+1,Y ; get vector high byte
PHA ; onto stack
LDA LAB_CTBL,Y ; get vector low byte
PHA ; onto stack
JMP LAB_IGBY ; jump to increment and scan memory
; then "return" to vector
; CTRL-C check jump. this is called as a subroutine but exits back via a jump if a
; key press is detected.
LAB_1629
JMP (VEC_CC) ; ctrl c check vector
; if there was a key press it gets back here ..
LAB_1636
CMP #$03 ; compare with CTRL-C
; perform STOP
LAB_STOP
BCS LAB_163B ; branch if token follows STOP
; else just END
; END
LAB_END
CLC ; clear the carry, indicate a normal program end
LAB_163B
BNE LAB_167A ; if wasn't CTRL-C or there is a following byte return
LDA Bpntrh ; get the BASIC execute pointer high byte
;*** fix p2: skip no longer necessary as the continue pointer is saved anyway
; EOR #>Ibuffs ; compare with buffer address high byte (Cb unchanged)
; BEQ LAB_164F ; branch if the BASIC pointer is in the input buffer
; ; (can't continue in immediate mode)
; ; else ..
; EOR #>Ibuffs ; correct the bits
LDY Bpntrl ; get BASIC execute pointer low byte
STY Cpntrl ; save continue pointer low byte
STA Cpntrh ; save continue pointer high byte
LAB_1647
LDA Clinel ; get current line low byte
LDY Clineh ; get current line high byte
STA Blinel ; save break line low byte
STY Blineh ; save break line high byte
LAB_164F
PLA ; pull return address low
PLA ; pull return address high
LAB_1651
BCC LAB_165E ; if was program end just do warm start
; else ..
LDA #<LAB_BMSG ; point to "Break" low byte
LDY #>LAB_BMSG ; point to "Break" high byte
JMP LAB_1269 ; print "Break" and do warm start
LAB_165E
JMP LAB_1274 ; go do warm start
; perform RESTORE
LAB_RESTORE
BNE LAB_RESTOREn ; branch if next character not null (RESTORE n)
LAB_161A
SEC ; set carry for subtract
LDA Smeml ; get start of mem low byte
SBC #$01 ; -1
LDY Smemh ; get start of mem high byte
BCS LAB_1624 ; branch if no underflow
LAB_uflow
DEY ; else decrement high byte
LAB_1624
STA Dptrl ; save DATA pointer low byte
STY Dptrh ; save DATA pointer high byte
LAB_1628
RTS
; is RESTORE n
LAB_RESTOREn
JSR LAB_GFPN ; get fixed-point number into temp integer
JSR LAB_SNBL ; scan for next BASIC line
LDA Clineh ; get current line high byte
CMP Itemph ; compare with temporary integer high byte
BCS LAB_reset_search ; branch if >= (start search from beginning)
TYA ; else copy line index to A
SEC ; set carry (+1)
ADC Bpntrl ; add BASIC execute pointer low byte
LDX Bpntrh ; get BASIC execute pointer high byte
BCC LAB_go_search ; branch if no overflow to high byte
INX ; increment high byte
BCS LAB_go_search ; branch always (can never be carry clear)
; search for line # in temp (Itempl/Itemph) from start of mem pointer (Smeml)
LAB_reset_search
LDA Smeml ; get start of mem low byte
LDX Smemh ; get start of mem high byte
; search for line # in temp (Itempl/Itemph) from (AX)
LAB_go_search
JSR LAB_SHLN ; search Basic for temp integer line number from AX
BCS LAB_line_found ; if carry set go set pointer
JMP LAB_16F7 ; else go do "Undefined statement" error
LAB_line_found
; carry already set for subtract
LDA Baslnl ; get pointer low byte
SBC #$01 ; -1
LDY Baslnh ; get pointer high byte
BCS LAB_1624 ; branch if no underflow (save DATA pointer and return)
BCC LAB_uflow ; else decrement high byte then save DATA pointer and
; return (branch always)
; perform NULL
LAB_NULL
JSR LAB_GTBY ; get byte parameter
STX Nullct ; save new NULL count
LAB_167A
RTS
; perform CONT
LAB_CONT
BNE LAB_167A ; if following byte exit to do syntax error
LDY Cpntrh ; get continue pointer high byte
CPY #>Ibuffs ; *** fix p2: test direct mode
BNE LAB_166C ; go do continue if we can
LDX #$1E ; error code $1E ("Can't continue" error)
JMP LAB_XERR ; do error #X, then warm start
; we can continue so ..
LAB_166C
LDA #TK_ON ; set token for ON
JSR LAB_IRQ ; set IRQ flags
LDA #TK_ON ; set token for ON
JSR LAB_NMI ; set NMI flags
STY Bpntrh ; save BASIC execute pointer high byte
LDA Cpntrl ; get continue pointer low byte
STA Bpntrl ; save BASIC execute pointer low byte
LDA Blinel ; get break line low byte
LDY Blineh ; get break line high byte
STA Clinel ; set current line low byte
STY Clineh ; set current line high byte
RTS
; perform RUN
LAB_RUN
BNE LAB_1696 ; branch if RUN n
JMP LAB_1477 ; reset execution to start, clear variables, flush stack and
; return
; does RUN n
LAB_1696
JSR LAB_147A ; go do "CLEAR"
BEQ LAB_16B0 ; get n and do GOTO n (branch always as CLEAR sets Z=1)
; perform DO
LAB_DO
LDA #$05 ; need 5 bytes for DO
JSR LAB_1212 ; check room on stack for A bytes
LDA Bpntrh ; get BASIC execute pointer high byte
PHA ; push on stack
LDA Bpntrl ; get BASIC execute pointer low byte
PHA ; push on stack
LDA Clineh ; get current line high byte
PHA ; push on stack
LDA Clinel ; get current line low byte
PHA ; push on stack
LDA #TK_DO ; token for DO
PHA ; push on stack
JSR LAB_GBYT ; scan memory
JMP LAB_15C2 ; go do interpreter inner loop
; perform GOSUB
LAB_GOSUB
LDA #$05 ; need 5 bytes for GOSUB
JSR LAB_1212 ; check room on stack for A bytes
LDA Bpntrh ; get BASIC execute pointer high byte
PHA ; push on stack
LDA Bpntrl ; get BASIC execute pointer low byte
PHA ; push on stack
LDA Clineh ; get current line high byte
PHA ; push on stack
LDA Clinel ; get current line low byte
PHA ; push on stack
LDA #TK_GOSUB ; token for GOSUB
PHA ; push on stack
LAB_16B0
JSR LAB_GBYT ; scan memory
JSR LAB_GOTO ; perform GOTO n
JMP LAB_15C2 ; go do interpreter inner loop
; (can't RTS, we used the stack!)
; perform GOTO
LAB_GOTO
JSR LAB_GFPN ; get fixed-point number into temp integer
JSR LAB_SNBL ; scan for next BASIC line
LDA Clineh ; get current line high byte
CMP Itemph ; compare with temporary integer high byte
BCS LAB_16D0 ; branch if >= (start search from beginning)
TYA ; else copy line index to A
SEC ; set carry (+1)
ADC Bpntrl ; add BASIC execute pointer low byte
LDX Bpntrh ; get BASIC execute pointer high byte
BCC LAB_16D4 ; branch if no overflow to high byte
INX ; increment high byte
BCS LAB_16D4 ; branch always (can never be carry)
; search for line # in temp (Itempl/Itemph) from start of mem pointer (Smeml)
LAB_16D0
LDA Smeml ; get start of mem low byte
LDX Smemh ; get start of mem high byte
; search for line # in temp (Itempl/Itemph) from (AX)
LAB_16D4
JSR LAB_SHLN ; search Basic for temp integer line number from AX
BCC LAB_16F7 ; if carry clear go do "Undefined statement" error
; (unspecified statement)
; carry already set for subtract
LDA Baslnl ; get pointer low byte
SBC #$01 ; -1
STA Bpntrl ; save BASIC execute pointer low byte
LDA Baslnh ; get pointer high byte
SBC #$00 ; subtract carry
STA Bpntrh ; save BASIC execute pointer high byte
LAB_16E5
RTS
LAB_DONOK
LDX #$22 ; error code $22 ("LOOP without DO" error)
JMP LAB_XERR ; do error #X, then warm start
; perform LOOP
LAB_LOOP
TAY ; save following token
TSX ; copy stack pointer
LDA LAB_STAK+3,X ; get token byte from stack
CMP #TK_DO ; compare with DO token
BNE LAB_DONOK ; branch if no matching DO
INX ; dump calling routine return address
INX ; dump calling routine return address
TXS ; correct stack
TYA ; get saved following token back
BEQ LoopAlways ; if no following token loop forever
; (stack pointer in X)
CMP #':' ; could be ':'
BEQ LoopAlways ; if :... loop forever
SBC #TK_UNTIL ; subtract token for UNTIL, we know carry is set here
TAX ; copy to X (if it was UNTIL then Y will be correct)
BEQ DoRest ; branch if was UNTIL
DEX ; decrement result
BNE LAB_16FC ; if not WHILE go do syntax error and warm start
; only if the token was WHILE will this fail
DEX ; set invert result byte
DoRest
STX Frnxth ; save invert result byte
JSR LAB_IGBY ; increment and scan memory
JSR LAB_EVEX ; evaluate expression
LDA FAC1_e ; get FAC1 exponent
BEQ DoCmp ; if =0 go do straight compare
LDA #$FF ; else set all bits
DoCmp
TSX ; copy stack pointer
EOR Frnxth ; EOR with invert byte
BNE LoopDone ; if <> 0 clear stack and back to interpreter loop
; loop condition wasn't met so do it again
LoopAlways
LDA LAB_STAK+2,X ; get current line low byte
STA Clinel ; save current line low byte
LDA LAB_STAK+3,X ; get current line high byte
STA Clineh ; save current line high byte
LDA LAB_STAK+4,X ; get BASIC execute pointer low byte
STA Bpntrl ; save BASIC execute pointer low byte
LDA LAB_STAK+5,X ; get BASIC execute pointer high byte
STA Bpntrh ; save BASIC execute pointer high byte
JSR LAB_GBYT ; scan memory
JMP LAB_15C2 ; go do interpreter inner loop
; clear stack and back to interpreter loop
LoopDone
INX ; dump DO token
INX ; dump current line low byte
INX ; dump current line high byte
INX ; dump BASIC execute pointer low byte
INX ; dump BASIC execute pointer high byte
TXS ; correct stack
JMP LAB_DATA ; go perform DATA (find : or [EOL])
; do the return without gosub error
LAB_16F4
LDX #$04 ; error code $04 ("RETURN without GOSUB" error)
.byte $2C ; makes next line BIT LAB_0EA2
LAB_16F7 ; do undefined statement error
LDX #$0E ; error code $0E ("Undefined statement" error)
JMP LAB_XERR ; do error #X, then warm start
; perform RETURN
LAB_RETURN
BNE LAB_16E5 ; exit if following token (to allow syntax error)
LAB_16E8
PLA ; dump calling routine return address
PLA ; dump calling routine return address
PLA ; pull token
CMP #TK_GOSUB ; compare with GOSUB token
BNE LAB_16F4 ; branch if no matching GOSUB
LAB_16FF
PLA ; pull current line low byte
STA Clinel ; save current line low byte
PLA ; pull current line high byte
STA Clineh ; save current line high byte
PLA ; pull BASIC execute pointer low byte
STA Bpntrl ; save BASIC execute pointer low byte
PLA ; pull BASIC execute pointer high byte
STA Bpntrh ; save BASIC execute pointer high byte
; now do the DATA statement as we could be returning into
; the middle of an ON <var> GOSUB n,m,p,q line
; (the return address used by the DATA statement is the one
; pushed before the GOSUB was executed!)
; perform DATA
LAB_DATA
JSR LAB_SNBS ; scan for next BASIC statement ([:] or [EOL])
; set BASIC execute pointer
LAB_170F
TYA ; copy index to A
CLC ; clear carry for add
ADC Bpntrl ; add BASIC execute pointer low byte
STA Bpntrl ; save BASIC execute pointer low byte
BCC LAB_1719 ; skip next if no carry
INC Bpntrh ; else increment BASIC execute pointer high byte
LAB_1719
RTS
LAB_16FC
JMP LAB_SNER ; do syntax error then warm start
; scan for next BASIC statement ([:] or [EOL])
; returns Y as index to [:] or [EOL]
LAB_SNBS
LDX #':' ; set look for character = ":"
.byte $2C ; makes next line BIT $00A2
; scan for next BASIC line
; returns Y as index to [EOL]
LAB_SNBL
LDX #$00 ; set alt search character = [EOL]
LDY #$00 ; set search character = [EOL]
STY Asrch ; store search character
LAB_1725
TXA ; get alt search character
EOR Asrch ; toggle search character, effectively swap with $00
STA Asrch ; save swapped search character
LAB_172D
LDA (Bpntrl),Y ; get next byte
BEQ LAB_1719 ; exit if null [EOL]
CMP Asrch ; compare with search character
BEQ LAB_1719 ; exit if found
INY ; increment index
CMP #$22 ; compare current character with open quote
BNE LAB_172D ; if not open quote go get next character
BEQ LAB_1725 ; if found go swap search character for alt search character
; perform IF
LAB_IF
JSR LAB_EVEX ; evaluate the expression
JSR LAB_GBYT ; scan memory
CMP #TK_THEN ; compare with THEN token
BEQ LAB_174B ; if it was THEN go do IF
; wasn't IF .. THEN so must be IF .. GOTO
CMP #TK_GOTO ; compare with GOTO token
BNE LAB_16FC ; if it wasn't GOTO go do syntax error
LDX Bpntrl ; save the basic pointer low byte
LDY Bpntrh ; save the basic pointer high byte
JSR LAB_IGBY ; increment and scan memory
BCS LAB_16FC ; if not numeric go do syntax error
STX Bpntrl ; restore the basic pointer low byte
STY Bpntrh ; restore the basic pointer high byte
LAB_174B
LDA FAC1_e ; get FAC1 exponent
BEQ LAB_174E ; if the result was zero go look for an ELSE
JSR LAB_IGBY ; else increment and scan memory
BCS LAB_174D ; if not numeric go do var or keyword
LAB_174C
JMP LAB_GOTO ; else was numeric so do GOTO n
; is var or keyword
LAB_174D
; *** patch allow NEXT, LOOP & RETURN to find FOR, DO or GOSUB structure on stack
; *** replace
; CMP #TK_RETURN ; compare the byte with the token for RETURN
; BNE LAB_174G ; if it wasn't RETURN go interpret BASIC code from (Bpntrl)
; ; and return to this code to process any following code
;
; JMP LAB_1602 ; else it was RETURN so interpret BASIC code from (Bpntrl)
; ; but don't return here
;
;LAB_174G
; JSR LAB_15FF ; interpret BASIC code from (Bpntrl)
;
;; the IF was executed and there may be a following ELSE so the code needs to return
;; here to check and ignore the ELSE if present
;
; LDY #$00 ; clear the index
; LDA (Bpntrl),Y ; get the next BASIC byte
; CMP #TK_ELSE ; compare it with the token for ELSE
; BEQ LAB_DATA ; if ELSE ignore the following statement
;
;; there was no ELSE so continue execution of IF <expr> THEN <stat> [: <stat>]. any
;; following ELSE will, correctly, cause a syntax error
;
; RTS ; else return to the interpreter inner loop
;
; *** with
PLA ; discard interpreter loop return address
PLA ; so data structures are at the correct stack offset
JSR LAB_GBYT ; restore token or variable
JSR LAB_15FF ; interpret BASIC code from (Bpntrl)
; the IF was executed and there may be a following ELSE so the code needs to return
; here to check and ignore the ELSE if present
LDY #$00 ; clear the index
LDA (Bpntrl),Y ; get the next BASIC byte
CMP #TK_ELSE ; compare it with the token for ELSE
BNE LAB_no_ELSE ; no - continue on this line
JSR LAB_DATA ; yes - skip the rest of the line
; there was no ELSE so continue execution of IF <expr> THEN <stat> [: <stat>]. any
; following ELSE will, correctly, cause a syntax error
LAB_no_ELSE
JMP LAB_15C2 ; return to the interpreter inner loop
; *** end patch allow NEXT, LOOP & RETURN to find FOR, DO or GOSUB structure on stack
; perform ELSE after IF
LAB_174E
LDY #$00 ; clear the BASIC byte index
LDX #$01 ; clear the nesting depth
LAB_1750
INY ; increment the BASIC byte index
LDA (Bpntrl),Y ; get the next BASIC byte
BEQ LAB_1753 ; if EOL go add the pointer and return
CMP #TK_IF ; compare the byte with the token for IF
BNE LAB_1752 ; if not IF token skip the depth increment
INX ; else increment the nesting depth ..
BNE LAB_1750 ; .. and continue looking
LAB_1752
CMP #TK_ELSE ; compare the byte with the token for ELSE
BNE LAB_1750 ; if not ELSE token continue looking
DEX ; was ELSE so decrement the nesting depth
BNE LAB_1750 ; loop if still nested
INY ; increment the BASIC byte index past the ELSE
; found the matching ELSE, now do <{n|statement}>
LAB_1753
TYA ; else copy line index to A
CLC ; clear carry for add
ADC Bpntrl ; add the BASIC execute pointer low byte
STA Bpntrl ; save the BASIC execute pointer low byte
BCC LAB_1754 ; branch if no overflow to high byte
INC Bpntrh ; else increment the BASIC execute pointer high byte
LAB_1754
JSR LAB_GBYT ; scan memory
BCC LAB_174C ; if numeric do GOTO n
; the code will return to the interpreter loop at the
; tail end of the GOTO <n>
JMP LAB_15FF ; interpret BASIC code from (Bpntrl)
; the code will return to the interpreter loop at the
; tail end of the <statement>
; perform REM, skip (rest of) line
LAB_REM
JSR LAB_SNBL ; scan for next BASIC line
JMP LAB_170F ; go set BASIC execute pointer and return, branch always
LAB_16FD
JMP LAB_SNER ; do syntax error then warm start
; perform ON
LAB_ON
CMP #TK_IRQ ; was it IRQ token ?
BNE LAB_NOIN ; if not go check NMI
JMP LAB_SIRQ ; else go set-up IRQ
LAB_NOIN
CMP #TK_NMI ; was it NMI token ?
BNE LAB_NONM ; if not go do normal ON command
JMP LAB_SNMI ; else go set-up NMI
LAB_NONM
JSR LAB_GTBY ; get byte parameter
PHA ; push GOTO/GOSUB token
CMP #TK_GOSUB ; compare with GOSUB token
BEQ LAB_176B ; branch if GOSUB
CMP #TK_GOTO ; compare with GOTO token
LAB_1767
BNE LAB_16FD ; if not GOTO do syntax error then warm start
; next character was GOTO or GOSUB
LAB_176B
DEC FAC1_3 ; decrement index (byte value)
BNE LAB_1773 ; branch if not zero
PLA ; pull GOTO/GOSUB token
JMP LAB_1602 ; go execute it
LAB_1773
JSR LAB_IGBY ; increment and scan memory
JSR LAB_GFPN ; get fixed-point number into temp integer (skip this n)
; (we could LDX #',' and JSR LAB_SNBL+2, then we
; just BNE LAB_176B for the loop. should be quicker ..
; no we can't, what if we meet a colon or [EOL]?)
CMP #$2C ; compare next character with ","
BEQ LAB_176B ; loop if ","
LAB_177E
PLA ; else pull keyword token (run out of options)
; also dump +/-1 pointer low byte and exit
LAB_177F
RTS
; takes n * 106 + 11 cycles where n is the number of digits
; get fixed-point number into temp integer
LAB_GFPN
LDX #$00 ; clear reg
STX Itempl ; clear temporary integer low byte
LAB_1785
STX Itemph ; save temporary integer high byte
BCS LAB_177F ; return if carry set, end of scan, character was
; not 0-9
CPX #$19 ; compare high byte with $19
TAY ; ensure Zb = 0 if the branch is taken
BCS LAB_1767 ; branch if >=, makes max line # 63999 because next
; bit does *$0A, = 64000, compare at target will fail
; and do syntax error
SBC #'0'-1 ; subtract "0", $2F + carry, from byte
TAY ; copy binary digit
LDA Itempl ; get temporary integer low byte
ASL ; *2 low byte
ROL Itemph ; *2 high byte
ASL ; *2 low byte
ROL Itemph ; *2 high byte, *4
ADC Itempl ; + low byte, *5
STA Itempl ; save it
TXA ; get high byte copy to A
ADC Itemph ; + high byte, *5
ASL Itempl ; *2 low byte, *10d
ROL ; *2 high byte, *10d
TAX ; copy high byte back to X
TYA ; get binary digit back
ADC Itempl ; add number low byte
STA Itempl ; save number low byte
BCC LAB_17B3 ; if no overflow to high byte get next character
INX ; else increment high byte
LAB_17B3
JSR LAB_IGBY ; increment and scan memory
JMP LAB_1785 ; loop for next character
; perform DEC
LAB_DEC
LDA #<LAB_2AFD ; set -1 pointer low byte
.byte $2C ; BIT abs to skip the LDA below
; perform INC
LAB_INC
LDA #<LAB_259C ; set 1 pointer low byte
LAB_17B5
PHA ; save +/-1 pointer low byte
LAB_17B7
JSR LAB_GVAR ; get var address
LDX Dtypef ; get data type flag, $FF=string, $00=numeric
BMI IncrErr ; exit if string
STA Lvarpl ; save var address low byte
STY Lvarph ; save var address high byte
JSR LAB_UFAC ; unpack memory (AY) into FAC1
PLA ; get +/-1 pointer low byte
PHA ; save +/-1 pointer low byte
LDY #>LAB_259C ; set +/-1 pointer high byte (both the same)
JSR LAB_246C ; add (AY) to FAC1
JSR LAB_PFAC ; pack FAC1 into variable (Lvarpl)
JSR LAB_GBYT ; scan memory
CMP #',' ; compare with ","
BNE LAB_177E ; exit if not "," (either end or error)
; was "," so another INCR variable to do
JSR LAB_IGBY ; increment and scan memory
JMP LAB_17B7 ; go do next var
IncrErr
JMP LAB_1ABC ; do "Type mismatch" error then warm start
; perform LET
LAB_LET
JSR LAB_GVAR ; get var address
STA Lvarpl ; save var address low byte
STY Lvarph ; save var address high byte
LDA #TK_EQUAL ; get = token
JSR LAB_SCCA ; scan for CHR$(A), else do syntax error then warm start
LDA Dtypef ; get data type flag, $FF=string, $00=numeric
PHA ; push data type flag
JSR LAB_EVEX ; evaluate expression
PLA ; pop data type flag
ROL ; set carry if type = string
; *** begin patch result of a string compare stores string pointer to variable
; but should store FAC1 (true/false value)
; *** replace
; JSR LAB_CKTM ; type match check, set C for string
; BNE LAB_17D5 ; branch if string
; *** with
JSR LAB_CKTM ; type match check, keep C (expected type)
BCS LAB_17D5 ; branch if string
; *** end patch
JMP LAB_PFAC ; pack FAC1 into variable (Lvarpl) and return
; string LET
LAB_17D5
LDY #$02 ; set index to pointer high byte
LDA (des_pl),Y ; get string pointer high byte
CMP Sstorh ; compare bottom of string space high byte
BCC LAB_17F4 ; if less assign value and exit (was in program memory)
BNE LAB_17E6 ; branch if >
; else was equal so compare low bytes
DEY ; decrement index
LDA (des_pl),Y ; get pointer low byte
CMP Sstorl ; compare bottom of string space low byte
BCC LAB_17F4 ; if less assign value and exit (was in program memory)
; pointer was >= to bottom of string space pointer
LAB_17E6
LDY des_ph ; get descriptor pointer high byte
CPY Svarh ; compare start of vars high byte
BCC LAB_17F4 ; branch if less (descriptor is on stack)
BNE LAB_17FB ; branch if greater (descriptor is not on stack)
; else high bytes were equal so ..
LDA des_pl ; get descriptor pointer low byte
CMP Svarl ; compare start of vars low byte
BCS LAB_17FB ; branch if >= (descriptor is not on stack)
LAB_17F4
LDA des_pl ; get descriptor pointer low byte
LDY des_ph ; get descriptor pointer high byte
JMP LAB_1811 ; clean stack, copy descriptor to variable and return
; make space and copy string
LAB_17FB
LDY #$00 ; index to length
LDA (des_pl),Y ; get string length
JSR LAB_209C ; copy string
LDA des_2l ; get descriptor pointer low byte
LDY des_2h ; get descriptor pointer high byte
STA ssptr_l ; save descriptor pointer low byte
STY ssptr_h ; save descriptor pointer high byte
JSR LAB_228A ; copy string from descriptor (sdescr) to (Sutill)
LDA #<FAC1_e ; set descriptor pointer low byte
LDY #>FAC1_e ; get descriptor pointer high byte
; clean stack and assign value to string variable
LAB_1811
STA des_2l ; save descriptor_2 pointer low byte
STY des_2h ; save descriptor_2 pointer high byte
JSR LAB_22EB ; clean descriptor stack, YA = pointer
LDY #$00 ; index to length
LDA (des_2l),Y ; get string length
STA (Lvarpl),Y ; copy to let string variable
INY ; index to string pointer low byte
LDA (des_2l),Y ; get string pointer low byte
STA (Lvarpl),Y ; copy to let string variable
INY ; index to string pointer high byte
LDA (des_2l),Y ; get string pointer high byte
STA (Lvarpl),Y ; copy to let string variable
RTS
; perform GET
LAB_GET
JSR LAB_GVAR ; get var address
STA Lvarpl ; save var address low byte
STY Lvarph ; save var address high byte
JSR INGET ; get input byte
LDX Dtypef ; get data type flag, $FF=string, $00=numeric
BMI LAB_GETS ; go get string character
; was numeric get
TAY ; copy character to Y
JSR LAB_1FD0 ; convert Y to byte in FAC1
JMP LAB_PFAC ; pack FAC1 into variable (Lvarpl) and return
LAB_GETS
PHA ; save character
LDA #$01 ; string is single byte
BCS LAB_IsByte ; branch if byte received
PLA ; string is null
LAB_IsByte
JSR LAB_MSSP ; make string space A bytes long A=$AC=length,
; X=$AD=Sutill=ptr low byte, Y=$AE=Sutilh=ptr high byte
BEQ LAB_NoSt ; skip store if null string
PLA ; get character back
LDY #$00 ; clear index
STA (str_pl),Y ; save byte in string (byte IS string!)
LAB_NoSt
JSR LAB_RTST ; check for space on descriptor stack then put address
; and length on descriptor stack and update stack pointers
JMP LAB_17D5 ; do string LET and return
; perform PRINT
LAB_1829
JSR LAB_18C6 ; print string from Sutill/Sutilh
LAB_182C
JSR LAB_GBYT ; scan memory
; PRINT
LAB_PRINT
BEQ LAB_CRLF ; if nothing following just print CR/LF
LAB_1831
CMP #TK_TAB ; compare with TAB( token
BEQ LAB_18A2 ; go do TAB/SPC
CMP #TK_SPC ; compare with SPC( token
BEQ LAB_18A2 ; go do TAB/SPC
CMP #',' ; compare with ","
BEQ LAB_188B ; go do move to next TAB mark
CMP #';' ; compare with ";"
BEQ LAB_18BD ; if ";" continue with PRINT processing
JSR LAB_EVEX ; evaluate expression
BIT Dtypef ; test data type flag, $FF=string, $00=numeric
BMI LAB_1829 ; branch if string
JSR LAB_296E ; convert FAC1 to string
JSR LAB_20AE ; print " terminated string to Sutill/Sutilh
LDY #$00 ; clear index
; don't check fit if terminal width byte is zero
LDA TWidth ; get terminal width byte
BEQ LAB_185E ; skip check if zero
SEC ; set carry for subtract
SBC TPos ; subtract terminal position
SBC (des_pl),Y ; subtract string length
BCS LAB_185E ; branch if less than terminal width
JSR LAB_CRLF ; else print CR/LF
LAB_185E
JSR LAB_18C6 ; print string from Sutill/Sutilh
BEQ LAB_182C ; always go continue processing line
; CR/LF return to BASIC from BASIC input handler
LAB_1866
LDA #$00 ; clear byte
STA Ibuffs,X ; null terminate input
LDX #<Ibuffs ; set X to buffer start-1 low byte
LDY #>Ibuffs ; set Y to buffer start-1 high byte
; print CR/LF
LAB_CRLF
LDA #$0D ; load [CR]
JSR LAB_PRNA ; go print the character
LDA #$0A ; load [LF]
BNE LAB_PRNA ; go print the character and return, branch always
LAB_188B
LDA TPos ; get terminal position
CMP Iclim ; compare with input column limit
BCC LAB_1897 ; branch if less
JSR LAB_CRLF ; else print CR/LF (next line)
BNE LAB_18BD ; continue with PRINT processing (branch always)
LAB_1897
SEC ; set carry for subtract
LAB_1898
SBC TabSiz ; subtract TAB size
BCS LAB_1898 ; loop if result was +ve
EOR #$FF ; complement it
ADC #$01 ; +1 (twos complement)
BNE LAB_18B6 ; always print A spaces (result is never $00)
; do TAB/SPC
LAB_18A2
PHA ; save token
JSR LAB_SGBY ; scan and get byte parameter
CMP #$29 ; is next character )
BNE LAB_1910 ; if not do syntax error then warm start
PLA ; get token back
CMP #TK_TAB ; was it TAB ?
BNE LAB_18B7 ; if not go do SPC
; calculate TAB offset
TXA ; copy integer value to A
SBC TPos ; subtract terminal position
BCC LAB_18BD ; branch if result was < 0 (can't TAB backwards)
; print A spaces
LAB_18B6
TAX ; copy result to X
LAB_18B7
TXA ; set flags on size for SPC
BEQ LAB_18BD ; branch if result was = $0, already here
; print X spaces
LAB_18BA
JSR LAB_18E0 ; print " "
DEX ; decrement count
BNE LAB_18BA ; loop if not all done
; continue with PRINT processing
LAB_18BD
JSR LAB_IGBY ; increment and scan memory
BNE LAB_1831 ; if more to print go do it
RTS
; print null terminated string from memory
LAB_18C3
JSR LAB_20AE ; print " terminated string to Sutill/Sutilh
; print string from Sutill/Sutilh
LAB_18C6
JSR LAB_22B6 ; pop string off descriptor stack, or from top of string
; space returns with A = length, X=$71=pointer low byte,
; Y=$72=pointer high byte
LDY #$00 ; reset index
TAX ; copy length to X
BEQ LAB_188C ; exit (RTS) if null string
LAB_18CD
LDA (ut1_pl),Y ; get next byte
JSR LAB_PRNA ; go print the character
INY ; increment index
DEX ; decrement count
BNE LAB_18CD ; loop if not done yet
RTS
; Print single format character
; print " "
LAB_18E0
LDA #$20 ; load " "
.byte $2C ; change next line to BIT LAB_3FA9
; print "?" character
LAB_18E3
LDA #$3F ; load "?" character
; print character in A
; now includes the null handler
; also includes infinite line length code
; note! some routines expect this one to exit with Zb=0
LAB_PRNA
CMP #' ' ; compare with " "
BCC LAB_18F9 ; branch if less (non printing)
; else printable character
PHA ; save the character
; don't check fit if terminal width byte is zero
LDA TWidth ; get terminal width
BNE LAB_18F0 ; branch if not zero (not infinite length)
; is "infinite line" so check TAB position
LDA TPos ; get position
SBC TabSiz ; subtract TAB size, carry set by CMP #$20 above
BNE LAB_18F7 ; skip reset if different
STA TPos ; else reset position
BEQ LAB_18F7 ; go print character
LAB_18F0
CMP TPos ; compare with terminal character position
BNE LAB_18F7 ; branch if not at end of line
JSR LAB_CRLF ; else print CR/LF
LAB_18F7
INC TPos ; increment terminal position
PLA ; get character back
LAB_18F9
JSR V_OUTP ; output byte via output vector
CMP #$0D ; compare with [CR]
BNE LAB_188A ; branch if not [CR]
; else print nullct nulls after the [CR]
STX TempB ; save buffer index
LDX Nullct ; get null count
BEQ LAB_1886 ; branch if no nulls
LDA #$00 ; load [NULL]
LAB_1880
JSR LAB_PRNA ; go print the character
DEX ; decrement count
BNE LAB_1880 ; loop if not all done
LDA #$0D ; restore the character (and set the flags)
LAB_1886
STX TPos ; clear terminal position (X always = zero when we get here)
LDX TempB ; restore buffer index
LAB_188A
AND #$FF ; set the flags
LAB_188C
RTS
; handle bad input data
LAB_1904
LDA Imode ; get input mode flag, $00=INPUT, $00=READ
BPL LAB_1913 ; branch if INPUT (go do redo)
LDA Dlinel ; get current DATA line low byte
LDY Dlineh ; get current DATA line high byte
STA Clinel ; save current line low byte
STY Clineh ; save current line high byte
LAB_1910
JMP LAB_SNER ; do syntax error then warm start
; mode was INPUT
LAB_1913
LDA #<LAB_REDO ; point to redo message (low addr)
LDY #>LAB_REDO ; point to redo message (high addr)
JSR LAB_18C3 ; print null terminated string from memory
LDA Cpntrl ; get continue pointer low byte
LDY Cpntrh ; get continue pointer high byte
STA Bpntrl ; save BASIC execute pointer low byte
STY Bpntrh ; save BASIC execute pointer high byte
RTS
; perform INPUT
LAB_INPUT
CMP #$22 ; compare next byte with open quote
BNE LAB_1934 ; branch if no prompt string
JSR LAB_1BC1 ; print "..." string
LDA #$3B ; load A with ";"
JSR LAB_SCCA ; scan for CHR$(A), else do syntax error then warm start
JSR LAB_18C6 ; print string from Sutill/Sutilh
; done with prompt, now get data
LAB_1934
JSR LAB_CKRN ; check not Direct, back here if ok
JSR LAB_INLN ; print "? " and get BASIC input
LDA #$00 ; set mode = INPUT
CMP Ibuffs ; test first byte in buffer
BNE LAB_1953 ; branch if not null input
; *** change p2: keep carry set to throw break message
; CLC ; was null input so clear carry to exit program
JMP LAB_1647 ; go do BREAK exit
; perform READ
LAB_READ
LDX Dptrl ; get DATA pointer low byte
LDY Dptrh ; get DATA pointer high byte
LDA #$80 ; set mode = READ
LAB_1953
STA Imode ; set input mode flag, $00=INPUT, $80=READ
STX Rdptrl ; save READ pointer low byte
STY Rdptrh ; save READ pointer high byte
; READ or INPUT next variable from list
LAB_195B
JSR LAB_GVAR ; get (var) address
STA Lvarpl ; save address low byte
STY Lvarph ; save address high byte
LDA Bpntrl ; get BASIC execute pointer low byte
LDY Bpntrh ; get BASIC execute pointer high byte
STA Itempl ; save as temporary integer low byte
STY Itemph ; save as temporary integer high byte
LDX Rdptrl ; get READ pointer low byte
LDY Rdptrh ; get READ pointer high byte
STX Bpntrl ; set BASIC execute pointer low byte
STY Bpntrh ; set BASIC execute pointer high byte
JSR LAB_GBYT ; scan memory
BNE LAB_1988 ; branch if not null
; pointer was to null entry
BIT Imode ; test input mode flag, $00=INPUT, $80=READ
BMI LAB_19DD ; branch if READ
; mode was INPUT
JSR LAB_18E3 ; print "?" character (double ? for extended input)
JSR LAB_INLN ; print "? " and get BASIC input
STX Bpntrl ; set BASIC execute pointer low byte
STY Bpntrh ; set BASIC execute pointer high byte
LAB_1985
JSR LAB_GBYT ; scan memory
LAB_1988
BIT Dtypef ; test data type flag, $FF=string, $00=numeric
BPL LAB_19B0 ; branch if numeric
; else get string
STA Srchc ; save search character
CMP #$22 ; was it " ?
BEQ LAB_1999 ; branch if so
LDA #':' ; else search character is ":"
STA Srchc ; set new search character
LDA #',' ; other search character is ","
CLC ; clear carry for add
LAB_1999
STA Asrch ; set second search character
LDA Bpntrl ; get BASIC execute pointer low byte
LDY Bpntrh ; get BASIC execute pointer high byte
ADC #$00 ; c is =1 if we came via the BEQ LAB_1999, else =0
BCC LAB_19A4 ; branch if no execute pointer low byte rollover
INY ; else increment high byte
LAB_19A4
JSR LAB_20B4 ; print Srchc or Asrch terminated string to Sutill/Sutilh
JSR LAB_23F3 ; restore BASIC execute pointer from temp (Btmpl/Btmph)
JSR LAB_17D5 ; go do string LET
JMP LAB_19B6 ; go check string terminator
; get numeric INPUT
LAB_19B0
JSR LAB_2887 ; get FAC1 from string
JSR LAB_PFAC ; pack FAC1 into (Lvarpl)
LAB_19B6
JSR LAB_GBYT ; scan memory
BEQ LAB_19C5 ; branch if null (last entry)
CMP #',' ; else compare with ","
BEQ LAB_19C2 ; branch if ","
JMP LAB_1904 ; else go handle bad input data
; got good input data
LAB_19C2
JSR LAB_IGBY ; increment and scan memory
LAB_19C5
LDA Bpntrl ; get BASIC execute pointer low byte (temp READ/INPUT ptr)
LDY Bpntrh ; get BASIC execute pointer high byte (temp READ/INPUT ptr)
STA Rdptrl ; save for now
STY Rdptrh ; save for now
LDA Itempl ; get temporary integer low byte (temp BASIC execute ptr)
LDY Itemph ; get temporary integer high byte (temp BASIC execute ptr)
STA Bpntrl ; set BASIC execute pointer low byte
STY Bpntrh ; set BASIC execute pointer high byte
JSR LAB_GBYT ; scan memory
BEQ LAB_1A03 ; if null go do extra ignored message
JSR LAB_1C01 ; else scan for "," , else do syntax error then warm start
JMP LAB_195B ; go INPUT next variable from list
; find next DATA statement or do "Out of DATA" error
LAB_19DD
JSR LAB_SNBS ; scan for next BASIC statement ([:] or [EOL])
INY ; increment index
TAX ; copy character ([:] or [EOL])
BNE LAB_19F6 ; branch if [:]
LDX #$06 ; set for "Out of DATA" error
INY ; increment index, now points to next line pointer high byte
LDA (Bpntrl),Y ; get next line pointer high byte
BEQ LAB_1A54 ; branch if end (eventually does error X)
INY ; increment index
LDA (Bpntrl),Y ; get next line # low byte
STA Dlinel ; save current DATA line low byte
INY ; increment index
LDA (Bpntrl),Y ; get next line # high byte
INY ; increment index
STA Dlineh ; save current DATA line high byte
LAB_19F6
LDA (Bpntrl),Y ; get byte
INY ; increment index
TAX ; copy to X
JSR LAB_170F ; set BASIC execute pointer
CPX #TK_DATA ; compare with "DATA" token
BEQ LAB_1985 ; was "DATA" so go do next READ
BNE LAB_19DD ; go find next statement if not "DATA"
; end of INPUT/READ routine
LAB_1A03
LDA Rdptrl ; get temp READ pointer low byte
LDY Rdptrh ; get temp READ pointer high byte
LDX Imode ; get input mode flag, $00=INPUT, $80=READ
BPL LAB_1A0E ; branch if INPUT
JMP LAB_1624 ; save AY as DATA pointer and return
; we were getting INPUT
LAB_1A0E
LDY #$00 ; clear index
LDA (Rdptrl),Y ; get next byte
BNE LAB_1A1B ; error if not end of INPUT
RTS
; user typed too much
LAB_1A1B
LDA #<LAB_IMSG ; point to extra ignored message (low addr)
LDY #>LAB_IMSG ; point to extra ignored message (high addr)
JMP LAB_18C3 ; print null terminated string from memory and return
; search the stack for FOR activity
; exit with z=1 if FOR else exit with z=0
LAB_11A1
TSX ; copy stack pointer
INX ; +1 pass return address
INX ; +2 pass return address
INX ; +3 pass calling routine return address
INX ; +4 pass calling routine return address
LAB_11A6
LDA LAB_STAK+1,X ; get token byte from stack
CMP #TK_FOR ; is it FOR token
BNE LAB_11CE ; exit if not FOR token
; was FOR token
LDA Frnxth ; get var pointer for FOR/NEXT high byte
BNE LAB_11BB ; branch if not null
LDA LAB_STAK+2,X ; get FOR variable pointer low byte
STA Frnxtl ; save var pointer for FOR/NEXT low byte
LDA LAB_STAK+3,X ; get FOR variable pointer high byte
STA Frnxth ; save var pointer for FOR/NEXT high byte
LAB_11BB
CMP LAB_STAK+3,X ; compare var pointer with stacked var pointer (high byte)
BNE LAB_11C7 ; branch if no match
LDA Frnxtl ; get var pointer for FOR/NEXT low byte
CMP LAB_STAK+2,X ; compare var pointer with stacked var pointer (low byte)
BEQ LAB_11CE ; exit if match found
LAB_11C7
TXA ; copy index
CLC ; clear carry for add
ADC #$10 ; add FOR stack use size
TAX ; copy back to index
BNE LAB_11A6 ; loop if not at start of stack
LAB_11CE
RTS
; perform NEXT
LAB_NEXT
BNE LAB_1A46 ; branch if NEXT var
LDY #$00 ; else clear Y
BEQ LAB_1A49 ; branch always (no variable to search for)
; NEXT var
LAB_1A46
JSR LAB_GVAR ; get variable address
LAB_1A49
STA Frnxtl ; store variable pointer low byte
STY Frnxth ; store variable pointer high byte
; (both cleared if no variable defined)
JSR LAB_11A1 ; search the stack for FOR activity
BEQ LAB_1A56 ; branch if found
LDX #$00 ; else set error $00 ("NEXT without FOR" error)
LAB_1A54
BEQ LAB_1ABE ; do error #X, then warm start
LAB_1A56
TXS ; set stack pointer, X set by search, dumps return addresses
TXA ; copy stack pointer
SEC ; set carry for subtract
SBC #$F7 ; point to TO var
STA ut2_pl ; save pointer to TO var for compare
ADC #$FB ; point to STEP var
LDY #>LAB_STAK ; point to stack page high byte
JSR LAB_UFAC ; unpack memory (STEP value) into FAC1
TSX ; get stack pointer back
LDA LAB_STAK+8,X ; get step sign
STA FAC1_s ; save FAC1 sign (b7)
LDA Frnxtl ; get FOR variable pointer low byte
LDY Frnxth ; get FOR variable pointer high byte
JSR LAB_246C ; add (FOR variable) to FAC1
JSR LAB_PFAC ; pack FAC1 into (FOR variable)
LDY #>LAB_STAK ; point to stack page high byte
JSR LAB_27FA ; compare FAC1 with (Y,ut2_pl) (TO value)
TSX ; get stack pointer back
CMP LAB_STAK+8,X ; compare step sign
BEQ LAB_1A9B ; branch if = (loop complete)
; loop back and do it all again
LDA LAB_STAK+$0D,X ; get FOR line low byte
STA Clinel ; save current line low byte
LDA LAB_STAK+$0E,X ; get FOR line high byte
STA Clineh ; save current line high byte
LDA LAB_STAK+$10,X ; get BASIC execute pointer low byte
STA Bpntrl ; save BASIC execute pointer low byte
LDA LAB_STAK+$0F,X ; get BASIC execute pointer high byte
STA Bpntrh ; save BASIC execute pointer high byte
LAB_1A98
JMP LAB_15C2 ; go do interpreter inner loop
; loop complete so carry on
LAB_1A9B
TXA ; stack copy to A
ADC #$0F ; add $10 ($0F+carry) to dump FOR structure
TAX ; copy back to index
TXS ; copy to stack pointer
JSR LAB_GBYT ; scan memory
CMP #',' ; compare with ","
BNE LAB_1A98 ; branch if not "," (go do interpreter inner loop)
; was "," so another NEXT variable to do
JSR LAB_IGBY ; else increment and scan memory
JSR LAB_1A46 ; do NEXT (var)
; evaluate expression and check is numeric, else do type mismatch
LAB_EVNM
JSR LAB_EVEX ; evaluate expression
; check if source is numeric, else do type mismatch
LAB_CTNM
CLC ; destination is numeric
.byte $24 ; makes next line BIT $38
; check if source is string, else do type mismatch
LAB_CTST
SEC ; required type is string
; type match check, set C for string, clear C for numeric
LAB_CKTM
BIT Dtypef ; test data type flag, $FF=string, $00=numeric
BMI LAB_1ABA ; branch if data type is string
; else data type was numeric
BCS LAB_1ABC ; if required type is string do type mismatch error
LAB_1AB9
RTS
; data type was string, now check required type
LAB_1ABA
BCS LAB_1AB9 ; exit if required type is string
; else do type mismatch error
LAB_1ABC
LDX #$18 ; error code $18 ("Type mismatch" error)
LAB_1ABE
JMP LAB_XERR ; do error #X, then warm start
; evaluate expression
LAB_EVEX
LDX Bpntrl ; get BASIC execute pointer low byte
BNE LAB_1AC7 ; skip next if not zero
DEC Bpntrh ; else decrement BASIC execute pointer high byte
LAB_1AC7
DEC Bpntrl ; decrement BASIC execute pointer low byte
LAB_EVEZ
LDA #$00 ; set null precedence (flag done)
LAB_1ACC
PHA ; push precedence byte
LDA #$02 ; 2 bytes
JSR LAB_1212 ; check room on stack for A bytes
JSR LAB_GVAL ; get value from line
LDA #$00 ; clear A
STA comp_f ; clear compare function flag
LAB_1ADB
JSR LAB_GBYT ; scan memory
LAB_1ADE
SEC ; set carry for subtract
SBC #TK_GT ; subtract token for > (lowest comparison function)
BCC LAB_1AFA ; branch if < TK_GT
CMP #$03 ; compare with ">" to "<" tokens
BCS LAB_1AFA ; branch if >= TK_SGN (highest evaluation function +1)
; was token for > = or < (A = 0, 1 or 2)
CMP #$01 ; compare with token for =
ROL ; *2, b0 = carry (=1 if token was = or <)
; (A = 0, 3 or 5)
EOR #$01 ; toggle b0
; (A = 1, 2 or 4. 1 if >, 2 if =, 4 if <)
EOR comp_f ; EOR with compare function flag bits
CMP comp_f ; compare with compare function flag
BCC LAB_1B53 ; if <(comp_f) do syntax error then warm start
; was more than one <, = or >)
STA comp_f ; save new compare function flag
JSR LAB_IGBY ; increment and scan memory
JMP LAB_1ADE ; go do next character
; token is < ">" or > "<" tokens
LAB_1AFA
LDX comp_f ; get compare function flag
BNE LAB_1B2A ; branch if compare function
BCS LAB_1B78 ; go do functions
; else was < TK_GT so is operator or lower
ADC #TK_GT-TK_PLUS ; add # of operators (+, -, *, /, ^, AND, OR or EOR)
BCC LAB_1B78 ; branch if < + operator
; carry was set so token was +, -, *, /, ^, AND, OR or EOR
BNE LAB_1B0B ; branch if not + token
BIT Dtypef ; test data type flag, $FF=string, $00=numeric
BPL LAB_1B0B ; branch if not string
; will only be $00 if type is string and token was +
JMP LAB_224D ; add strings, string 1 is in descriptor des_pl, string 2
; is in line, and return
LAB_1B0B
STA ut1_pl ; save it
ASL ; *2
ADC ut1_pl ; *3
TAY ; copy to index
LAB_1B13
PLA ; pull previous precedence
CMP LAB_OPPT,Y ; compare with precedence byte
BCS LAB_1B7D ; branch if A >=
JSR LAB_CTNM ; check if source is numeric, else do type mismatch
LAB_1B1C
PHA ; save precedence
LAB_1B1D
JSR LAB_1B43 ; get vector, execute function then continue evaluation
PLA ; restore precedence
LDY prstk ; get precedence stacked flag
BPL LAB_1B3C ; branch if stacked values
TAX ; copy precedence (set flags)
BEQ LAB_1B9D ; exit if done
BNE LAB_1B86 ; else pop FAC2 and return, branch always
LAB_1B2A
ROL Dtypef ; shift data type flag into Cb
TXA ; copy compare function flag
STA Dtypef ; clear data type flag, X is 0xxx xxxx
ROL ; shift data type into compare function byte b0
LDX Bpntrl ; get BASIC execute pointer low byte
BNE LAB_1B34 ; branch if no underflow
DEC Bpntrh ; else decrement BASIC execute pointer high byte
LAB_1B34
DEC Bpntrl ; decrement BASIC execute pointer low byte
TK_LT_PLUS = TK_LT-TK_PLUS
LDY #TK_LT_PLUS*3 ; set offset to last operator entry
STA comp_f ; save new compare function flag
BNE LAB_1B13 ; branch always
LAB_1B3C
CMP LAB_OPPT,Y ;.compare with stacked function precedence
BCS LAB_1B86 ; branch if A >=, pop FAC2 and return
BCC LAB_1B1C ; branch always
;.get vector, execute function then continue evaluation
LAB_1B43
LDA LAB_OPPT+2,Y ; get function vector high byte
PHA ; onto stack
LDA LAB_OPPT+1,Y ; get function vector low byte
PHA ; onto stack
; now push sign, round FAC1 and put on stack
; *** begin patch 2.22p5.3 potential return address -$100 (page not incremented) ***
; *** add
; note MB: Unable to port to ca65 assembly
; .IF [* & $FF] == $FD
; NOP ; return address of JSR +1 (on next page)
; .ENDIF
; *** end patch 2.22p5.3 potential return address -$100 (page not incremented) ***
JSR LAB_1B5B ; function will return here, then the next RTS will call
; the function
LDA comp_f ; get compare function flag
PHA ; push compare evaluation byte
LDA LAB_OPPT,Y ; get precedence byte
JMP LAB_1ACC ; continue evaluating expression
LAB_1B53
JMP LAB_SNER ; do syntax error then warm start
; push sign, round FAC1 and put on stack
LAB_1B5B
PLA ; get return addr low byte
STA ut1_pl ; save it
INC ut1_pl ; increment it (was ret-1 pushed? yes!)
; note! no check is made on the high byte! if the calling
; routine assembles to a page edge then this all goes
; horribly wrong !!!
PLA ; get return addr high byte
STA ut1_ph ; save it
LDA FAC1_s ; get FAC1 sign (b7)
PHA ; push sign
; round FAC1 and put on stack
; *** begin patch 2.22p5.1 TO expression may get sign bit flipped
; *** replace
;LAB_1B66
; JSR LAB_27BA ; round FAC1
; *** with
JSR LAB_27BA ; round FAC1
LAB_1B66
; *** end patch 2.22p5.1 TO expression may get sign bit flipped
LDA FAC1_3 ; get FAC1 mantissa3
PHA ; push on stack
LDA FAC1_2 ; get FAC1 mantissa2
PHA ; push on stack
LDA FAC1_1 ; get FAC1 mantissa1
PHA ; push on stack
LDA FAC1_e ; get FAC1 exponent
PHA ; push on stack
JMP (ut1_pl) ; return, sort of
; do functions
LAB_1B78
LDY #$FF ; flag function
PLA ; pull precedence byte
LAB_1B7B
BEQ LAB_1B9D ; exit if done
LAB_1B7D
CMP #$64 ; compare previous precedence with $64
BEQ LAB_1B84 ; branch if was $64 (< function)
JSR LAB_CTNM ; check if source is numeric, else do type mismatch
LAB_1B84
STY prstk ; save precedence stacked flag
; pop FAC2 and return
LAB_1B86
PLA ; pop byte
LSR ; shift out comparison evaluation lowest bit
STA Cflag ; save comparison evaluation flag
PLA ; pop exponent
STA FAC2_e ; save FAC2 exponent
PLA ; pop mantissa1
STA FAC2_1 ; save FAC2 mantissa1
PLA ; pop mantissa2
STA FAC2_2 ; save FAC2 mantissa2
PLA ; pop mantissa3
STA FAC2_3 ; save FAC2 mantissa3
PLA ; pop sign
STA FAC2_s ; save FAC2 sign (b7)
EOR FAC1_s ; EOR FAC1 sign (b7)
STA FAC_sc ; save sign compare (FAC1 EOR FAC2)
LAB_1B9D
LDA FAC1_e ; get FAC1 exponent
RTS
; print "..." string to string util area
LAB_1BC1
LDA Bpntrl ; get BASIC execute pointer low byte
LDY Bpntrh ; get BASIC execute pointer high byte
ADC #$00 ; add carry to low byte
BCC LAB_1BCA ; branch if no overflow
INY ; increment high byte
LAB_1BCA
JSR LAB_20AE ; print " terminated string to Sutill/Sutilh
JMP LAB_23F3 ; restore BASIC execute pointer from temp and return
; get value from line
LAB_GVAL
JSR LAB_IGBY ; increment and scan memory
BCS LAB_1BAC ; branch if not numeric character
; else numeric string found (e.g. 123)
LAB_1BA9
JMP LAB_2887 ; get FAC1 from string and return
; get value from line .. continued
; wasn't a number so ..
LAB_1BAC
TAX ; set the flags
BMI LAB_1BD0 ; if -ve go test token values
; else it is either a string, number, variable or (<expr>)
CMP #'$' ; compare with "$"
BEQ LAB_1BA9 ; branch if "$", hex number
CMP #'%' ; else compare with "%"
BEQ LAB_1BA9 ; branch if "%", binary number
CMP #'.' ; compare with "."
BEQ LAB_1BA9 ; if so get FAC1 from string and return (e.g. was .123)
; it wasn't any sort of number so ..
CMP #$22 ; compare with "
BEQ LAB_1BC1 ; branch if open quote
; wasn't any sort of number so ..
; evaluate expression within parentheses
CMP #'(' ; compare with "("
BNE LAB_1C18 ; if not "(" get (var), return value in FAC1 and $ flag
LAB_1BF7
JSR LAB_EVEZ ; evaluate expression, no decrement
; all the 'scan for' routines return the character after the sought character
; scan for ")" , else do syntax error then warm start
LAB_1BFB
LDA #$29 ; load A with ")"
; scan for CHR$(A) , else do syntax error then warm start
LAB_SCCA
LDY #$00 ; clear index
CMP (Bpntrl),Y ; check next byte is = A
BNE LAB_SNER ; if not do syntax error then warm start
JMP LAB_IGBY ; increment and scan memory then return
; scan for "(" , else do syntax error then warm start
LAB_1BFE
LDA #$28 ; load A with "("
BNE LAB_SCCA ; scan for CHR$(A), else do syntax error then warm start
; (branch always)
; scan for "," , else do syntax error then warm start
LAB_1C01
LDA #$2C ; load A with ","
BNE LAB_SCCA ; scan for CHR$(A), else do syntax error then warm start
; (branch always)
; syntax error then warm start
LAB_SNER
LDX #$02 ; error code $02 ("Syntax" error)
JMP LAB_XERR ; do error #X, then warm start
; get value from line .. continued
; do tokens
LAB_1BD0
CMP #TK_MINUS ; compare with token for -
BEQ LAB_1C11 ; branch if - token (do set-up for functions)
; wasn't -n so ..
CMP #TK_PLUS ; compare with token for +
BEQ LAB_GVAL ; branch if + token (+n = n so ignore leading +)
CMP #TK_NOT ; compare with token for NOT
BNE LAB_1BE7 ; branch if not token for NOT
; was NOT token
TK_EQUAL_PLUS = TK_EQUAL-TK_PLUS
LDY #TK_EQUAL_PLUS*3 ; offset to NOT function
BNE LAB_1C13 ; do set-up for function then execute (branch always)
; do = compare
LAB_EQUAL
JSR LAB_EVIR ; evaluate integer expression (no sign check)
LDA FAC1_3 ; get FAC1 mantissa3
EOR #$FF ; invert it
TAY ; copy it
LDA FAC1_2 ; get FAC1 mantissa2
EOR #$FF ; invert it
JMP LAB_AYFC ; save and convert integer AY to FAC1 and return
; get value from line .. continued
; wasn't +, -, or NOT so ..
LAB_1BE7
CMP #TK_FN ; compare with token for FN
BNE LAB_1BEE ; branch if not token for FN
JMP LAB_201E ; go evaluate FNx
; get value from line .. continued
; wasn't +, -, NOT or FN so ..
LAB_1BEE
SBC #TK_SGN ; subtract with token for SGN
BCS LAB_1C27 ; if a function token go do it
JMP LAB_SNER ; else do syntax error
; set-up for functions
LAB_1C11
TK_GT_PLUS = TK_GT-TK_PLUS
LDY #TK_GT_PLUS*3 ; set offset from base to > operator
LAB_1C13
PLA ; dump return address low byte
; *** begin patch 2.22p5.4 concatenate MINUS or NOT() crashes EhBASIC ***
; *** replace
; PLA ; dump return address high byte
; JMP LAB_1B1D ; execute function then continue evaluation
; *** with
TAX ; save to trap concatenate
PLA ; dump return address high byte
CPX #<(LAB_224Da+2) ; from concatenate low return address?
BNE LAB_1C13b ; No - continue!
CMP #>(LAB_224Da+2) ; from concatenate high return address?
BEQ LAB_1C13a ; Yes - error!
LAB_1C13b
JMP LAB_1B1D ; execute function then continue evaluation
LAB_1C13a
JMP LAB_1ABC ; throw "type mismatch error" then warm start
; *** end patch 2.22p5.4 concatenate MINUS or NOT() crashes EhBASIC ***
; variable name set-up
; get (var), return value in FAC_1 and $ flag
LAB_1C18
JSR LAB_GVAR ; get (var) address
STA FAC1_2 ; save address low byte in FAC1 mantissa2
STY FAC1_3 ; save address high byte in FAC1 mantissa3
LDX Dtypef ; get data type flag, $FF=string, $00=numeric
BMI LAB_1C25 ; if string then return (does RTS)
LAB_1C24
JMP LAB_UFAC ; unpack memory (AY) into FAC1
LAB_1C25
; *** begin patch string pointer high byte trashed when moved to stack
; *** add
LSR FAC1_r ; clear bit 7 (<$80) = do not round up
; *** end patch
RTS
; get value from line .. continued
; only functions left so ..
; set up function references
; new for V2.0+ this replaces a lot of IF .. THEN .. ELSEIF .. THEN .. that was needed
; to process function calls. now the function vector is computed and pushed on the stack
; and the preprocess offset is read. if the preprocess offset is non zero then the vector
; is calculated and the routine called, if not this routine just does RTS. whichever
; happens the RTS at the end of this routine, or the end of the preprocess routine, calls
; the function code
; this also removes some less than elegant code that was used to bypass type checking
; for functions that returned strings
LAB_1C27
ASL ; *2 (2 bytes per function address)
TAY ; copy to index
LDA LAB_FTBM,Y ; get function jump vector high byte
PHA ; push functions jump vector high byte
LDA LAB_FTBL,Y ; get function jump vector low byte
PHA ; push functions jump vector low byte
LDA LAB_FTPM,Y ; get function pre process vector high byte
BEQ LAB_1C56 ; skip pre process if null vector
PHA ; push functions pre process vector high byte
LDA LAB_FTPL,Y ; get function pre process vector low byte
PHA ; push functions pre process vector low byte
LAB_1C56
RTS ; do function, or pre process, call
; process string expression in parenthesis
LAB_PPFS
JSR LAB_1BF7 ; process expression in parenthesis
JMP LAB_CTST ; check if source is string then do function,
; else do type mismatch
; process numeric expression in parenthesis
LAB_PPFN
JSR LAB_1BF7 ; process expression in parenthesis
JMP LAB_CTNM ; check if source is numeric then do function,
; else do type mismatch
; set numeric data type and increment BASIC execute pointer
LAB_PPBI
LSR Dtypef ; clear data type flag, $FF=string, $00=numeric
JMP LAB_IGBY ; increment and scan memory then do function
; process string for LEFT$, RIGHT$ or MID$
LAB_LRMS
JSR LAB_EVEZ ; evaluate (should be string) expression
JSR LAB_1C01 ; scan for ",", else do syntax error then warm start
JSR LAB_CTST ; check if source is string, else do type mismatch
PLA ; get function jump vector low byte
TAX ; save functions jump vector low byte
PLA ; get function jump vector high byte
TAY ; save functions jump vector high byte
LDA des_ph ; get descriptor pointer high byte
PHA ; push string pointer high byte
LDA des_pl ; get descriptor pointer low byte
PHA ; push string pointer low byte
TYA ; get function jump vector high byte back
PHA ; save functions jump vector high byte
TXA ; get function jump vector low byte back
PHA ; save functions jump vector low byte
JSR LAB_GTBY ; get byte parameter
TXA ; copy byte parameter to A
RTS ; go do function
; process numeric expression(s) for BIN$ or HEX$
LAB_BHSS
JSR LAB_EVEZ ; process expression
JSR LAB_CTNM ; check if source is numeric, else do type mismatch
LDA FAC1_e ; get FAC1 exponent
CMP #$98 ; compare with exponent = 2^24
BCS LAB_BHER ; branch if n>=2^24 (is too big)
JSR LAB_2831 ; convert FAC1 floating-to-fixed
LDX #$02 ; 3 bytes to do
LAB_CFAC
LDA FAC1_1,X ; get byte from FAC1
STA nums_1,X ; save byte to temp
DEX ; decrement index
BPL LAB_CFAC ; copy FAC1 mantissa to temp
JSR LAB_GBYT ; get next BASIC byte
LDX #$00 ; set default to no leading "0"s
CMP #')' ; compare with close bracket
BEQ LAB_1C54 ; if ")" go do rest of function
JSR LAB_SCGB ; scan for "," and get byte
JSR LAB_GBYT ; get last byte back
CMP #')' ; is next character )
BNE LAB_BHER ; if not ")" go do error
LAB_1C54
RTS ; else do function
LAB_BHER
JMP LAB_FCER ; do function call error then warm start
; perform EOR
; added operator format is the same as AND or OR, precedence is the same as OR
; this bit worked first time but it took a while to sort out the operator table
; pointers and offsets afterwards!
LAB_EOR
JSR GetFirst ; get first integer expression (no sign check)
EOR XOAw_l ; EOR with expression 1 low byte
TAY ; save in Y
LDA FAC1_2 ; get FAC1 mantissa2
EOR XOAw_h ; EOR with expression 1 high byte
JMP LAB_AYFC ; save and convert integer AY to FAC1 and return
; perform OR
LAB_OR
JSR GetFirst ; get first integer expression (no sign check)
ORA XOAw_l ; OR with expression 1 low byte
TAY ; save in Y
LDA FAC1_2 ; get FAC1 mantissa2
ORA XOAw_h ; OR with expression 1 high byte
JMP LAB_AYFC ; save and convert integer AY to FAC1 and return
; perform AND
LAB_AND
JSR GetFirst ; get first integer expression (no sign check)
AND XOAw_l ; AND with expression 1 low byte
TAY ; save in Y
LDA FAC1_2 ; get FAC1 mantissa2
AND XOAw_h ; AND with expression 1 high byte
JMP LAB_AYFC ; save and convert integer AY to FAC1 and return
; get first value for OR, AND or EOR
GetFirst
JSR LAB_EVIR ; evaluate integer expression (no sign check)
LDA FAC1_2 ; get FAC1 mantissa2
STA XOAw_h ; save it
LDA FAC1_3 ; get FAC1 mantissa3
STA XOAw_l ; save it
JSR LAB_279B ; copy FAC2 to FAC1 (get 2nd value in expression)
JSR LAB_EVIR ; evaluate integer expression (no sign check)
LDA FAC1_3 ; get FAC1 mantissa3
LAB_1C95
RTS
; perform comparisons
; do < compare
LAB_LTHAN
JSR LAB_CKTM ; type match check, set C for string
BCS LAB_1CAE ; branch if string
; do numeric < compare
LDA FAC2_s ; get FAC2 sign (b7)
ORA #$7F ; set all non sign bits
AND FAC2_1 ; and FAC2 mantissa1 (AND in sign bit)
STA FAC2_1 ; save FAC2 mantissa1
LDA #<FAC2_e ; set pointer low byte to FAC2
LDY #>FAC2_e ; set pointer high byte to FAC2
JSR LAB_27F8 ; compare FAC1 with FAC2 (AY)
TAX ; copy result
JMP LAB_1CE1 ; go evaluate result
; do string < compare
LAB_1CAE
LSR Dtypef ; clear data type flag, $FF=string, $00=numeric
DEC comp_f ; clear < bit in compare function flag
JSR LAB_22B6 ; pop string off descriptor stack, or from top of string
; space returns with A = length, X=pointer low byte,
; Y=pointer high byte
STA str_ln ; save length
STX str_pl ; save string pointer low byte
STY str_ph ; save string pointer high byte
LDA FAC2_2 ; get descriptor pointer low byte
LDY FAC2_3 ; get descriptor pointer high byte
JSR LAB_22BA ; pop (YA) descriptor off stack or from top of string space
; returns with A = length, X=pointer low byte,
; Y=pointer high byte
STX FAC2_2 ; save string pointer low byte
STY FAC2_3 ; save string pointer high byte
TAX ; copy length
SEC ; set carry for subtract
SBC str_ln ; subtract string 1 length
BEQ LAB_1CD6 ; branch if str 1 length = string 2 length
LDA #$01 ; set str 1 length > string 2 length
BCC LAB_1CD6 ; branch if so
LDX str_ln ; get string 1 length
LDA #$FF ; set str 1 length < string 2 length
LAB_1CD6
STA FAC1_s ; save length compare
LDY #$FF ; set index
INX ; adjust for loop
LAB_1CDB
INY ; increment index
DEX ; decrement count
BNE LAB_1CE6 ; branch if still bytes to do
LDX FAC1_s ; get length compare back
LAB_1CE1
BMI LAB_1CF2 ; branch if str 1 < str 2
CLC ; flag str 1 <= str 2
BCC LAB_1CF2 ; go evaluate result
LAB_1CE6
LDA (FAC2_2),Y ; get string 2 byte
CMP (FAC1_1),Y ; compare with string 1 byte
BEQ LAB_1CDB ; loop if bytes =
LDX #$FF ; set str 1 < string 2
BCS LAB_1CF2 ; branch if so
LDX #$01 ; set str 1 > string 2
LAB_1CF2
INX ; x = 0, 1 or 2
TXA ; copy to A
ROL ; *2 (1, 2 or 4)
AND Cflag ; AND with comparison evaluation flag
BEQ LAB_1CFB ; branch if 0 (compare is false)
LDA #$FF ; else set result true
LAB_1CFB
JMP LAB_27DB ; save A as integer byte and return
LAB_1CFE
JSR LAB_1C01 ; scan for ",", else do syntax error then warm start
; perform DIM
LAB_DIM
TAX ; copy "DIM" flag to X
JSR LAB_1D10 ; search for variable
JSR LAB_GBYT ; scan memory
BNE LAB_1CFE ; scan for "," and loop if not null
RTS
; perform << (left shift)
LAB_LSHIFT
JSR GetPair ; get integer expression and byte (no sign check)
LDA FAC1_2 ; get expression high byte
LDX TempB ; get shift count
BEQ NoShift ; branch if zero
CPX #$10 ; compare bit count with 16d
BCS TooBig ; branch if >=
Ls_loop
ASL FAC1_3 ; shift low byte
ROL ; shift high byte
DEX ; decrement bit count
BNE Ls_loop ; loop if shift not complete
LDY FAC1_3 ; get expression low byte
JMP LAB_AYFC ; save and convert integer AY to FAC1 and return
; perform >> (right shift)
LAB_RSHIFT
JSR GetPair ; get integer expression and byte (no sign check)
LDA FAC1_2 ; get expression high byte
LDX TempB ; get shift count
BEQ NoShift ; branch if zero
CPX #$10 ; compare bit count with 16d
BCS TooBig ; branch if >=
Rs_loop
LSR ; shift high byte
ROR FAC1_3 ; shift low byte
DEX ; decrement bit count
BNE Rs_loop ; loop if shift not complete
NoShift
LDY FAC1_3 ; get expression low byte
JMP LAB_AYFC ; save and convert integer AY to FAC1 and return
TooBig
LDA #$00 ; clear high byte
TAY ; copy to low byte
JMP LAB_AYFC ; save and convert integer AY to FAC1 and return
GetPair
JSR LAB_EVBY ; evaluate byte expression, result in X
STX TempB ; save it
JSR LAB_279B ; copy FAC2 to FAC1 (get 2nd value in expression)
JMP LAB_EVIR ; evaluate integer expression (no sign check)
; search for variable
; return pointer to variable in Cvaral/Cvarah
LAB_GVAR
LDX #$00 ; set DIM flag = $00
JSR LAB_GBYT ; scan memory (1st character)
LAB_1D10
STX Defdim ; save DIM flag
LAB_1D12
STA Varnm1 ; save 1st character
AND #$7F ; clear FN flag bit
JSR LAB_CASC ; check byte, return C=0 if<"A" or >"Z"
BCS LAB_1D1F ; branch if ok
JMP LAB_SNER ; else syntax error then warm start
; was variable name so ..
LAB_1D1F
LDX #$00 ; clear 2nd character temp
STX Dtypef ; clear data type flag, $FF=string, $00=numeric
JSR LAB_IGBY ; increment and scan memory (2nd character)
BCC LAB_1D2D ; branch if character = "0"-"9" (ok)
; 2nd character wasn't "0" to "9" so ..
JSR LAB_CASC ; check byte, return C=0 if<"A" or >"Z"
BCC LAB_1D38 ; branch if <"A" or >"Z" (go check if string)
LAB_1D2D
TAX ; copy 2nd character
; ignore further (valid) characters in the variable name
LAB_1D2E
JSR LAB_IGBY ; increment and scan memory (3rd character)
BCC LAB_1D2E ; loop if character = "0"-"9" (ignore)
JSR LAB_CASC ; check byte, return C=0 if<"A" or >"Z"
BCS LAB_1D2E ; loop if character = "A"-"Z" (ignore)
; check if string variable
LAB_1D38
CMP #'$' ; compare with "$"
BNE LAB_1D47 ; branch if not string
; to introduce a new variable type (% suffix for integers say) then this branch
; will need to go to that check and then that branch, if it fails, go to LAB_1D47
; type is string
LDA #$FF ; set data type = string
STA Dtypef ; set data type flag, $FF=string, $00=numeric
TXA ; get 2nd character back
ORA #$80 ; set top bit (indicate string var)
TAX ; copy back to 2nd character temp
JSR LAB_IGBY ; increment and scan memory
; after we have determined the variable type we need to come back here to determine
; if it's an array of type. this would plug in a%(b[,c[,d]])) integer arrays nicely
LAB_1D47 ; gets here with character after var name in A
STX Varnm2 ; save 2nd character
ORA Sufnxf ; or with subscript/FNX flag (or FN name)
CMP #'(' ; compare with "("
BNE LAB_1D53 ; branch if not "("
JMP LAB_1E17 ; go find, or make, array
; either find or create var
; var name (1st two characters only!) is in Varnm1,Varnm2
; variable name wasn't var(... so look for plain var
LAB_1D53
LDA #$00 ; clear A
STA Sufnxf ; clear subscript/FNX flag
LDA Svarl ; get start of vars low byte
LDX Svarh ; get start of vars high byte
LDY #$00 ; clear index
LAB_1D5D
STX Vrschh ; save search address high byte
LAB_1D5F
STA Vrschl ; save search address low byte
CPX Sarryh ; compare high address with var space end
BNE LAB_1D69 ; skip next compare if <>
; high addresses were = so compare low addresses
CMP Sarryl ; compare low address with var space end
BEQ LAB_1D8B ; if not found go make new var
LAB_1D69
LDA Varnm1 ; get 1st character of var to find
CMP (Vrschl),Y ; compare with variable name 1st character
BNE LAB_1D77 ; branch if no match
; 1st characters match so compare 2nd characters
LDA Varnm2 ; get 2nd character of var to find
INY ; index to point to variable name 2nd character
CMP (Vrschl),Y ; compare with variable name 2nd character
BEQ LAB_1DD7 ; branch if match (found var)
DEY ; else decrement index (now = $00)
LAB_1D77
CLC ; clear carry for add
LDA Vrschl ; get search address low byte
ADC #$06 ; +6 (offset to next var name)
BCC LAB_1D5F ; loop if no overflow to high byte
INX ; else increment high byte
BNE LAB_1D5D ; loop always (RAM doesn't extend to $FFFF !)
; check byte, return C=0 if<"A" or >"Z" or "a" to "z"
LAB_CASC
CMP #'a' ; compare with "a"
BCS LAB_1D83 ; go check <"z"+1
; check byte, return C=0 if<"A" or >"Z"
LAB_1D82
CMP #'A' ; compare with "A"
BCC LAB_1D8A ; exit if less
; carry is set
SBC #$5B ; subtract "Z"+1
SEC ; set carry
SBC #$A5 ; subtract $A5 (restore byte)
; carry clear if byte>$5A
LAB_1D8A
RTS
LAB_1D83
SBC #$7B ; subtract "z"+1
SEC ; set carry
SBC #$85 ; subtract $85 (restore byte)
; carry clear if byte>$7A
RTS
; reached end of variable mem without match
; .. so create new variable
LAB_1D8B
PLA ; pop return address low byte
PHA ; push return address low byte
LAB_1C18p2 = LAB_1C18+2
CMP #<LAB_1C18p2 ; compare with expected calling routine return low byte
BNE LAB_1D98 ; if not get (var) go create new var
; This will only drop through if the call was from LAB_1C18 and is only called
; from there if it is searching for a variable from the RHS of a LET a=b statement
; it prevents the creation of variables not assigned a value.
; value returned by this is either numeric zero (exponent byte is $00) or null string
; (descriptor length byte is $00). in fact a pointer to any $00 byte would have done.
; doing this saves 6 bytes of variable memory and 168 machine cycles of time
; this is where you would put the undefined variable error call e.g.
; ; variable doesn't exist so flag error
; LDX #$24 ; error code $24 ("undefined variable" error)
; JMP LAB_XERR ; do error #X then warm start
; the above code has been tested and works a treat! (it replaces the three code lines
; below)
; else return dummy null value
LDA #<LAB_1D96 ; low byte point to $00,$00
; (uses part of misc constants table)
LDY #>LAB_1D96 ; high byte point to $00,$00
RTS
; create new numeric variable
LAB_1D98
LDA Sarryl ; get var mem end low byte
LDY Sarryh ; get var mem end high byte
STA Ostrtl ; save old block start low byte
STY Ostrth ; save old block start high byte
LDA Earryl ; get array mem end low byte
LDY Earryh ; get array mem end high byte
STA Obendl ; save old block end low byte
STY Obendh ; save old block end high byte
CLC ; clear carry for add
ADC #$06 ; +6 (space for one var)
BCC LAB_1DAE ; branch if no overflow to high byte
INY ; else increment high byte
LAB_1DAE
STA Nbendl ; set new block end low byte
STY Nbendh ; set new block end high byte
JSR LAB_11CF ; open up space in memory
LDA Nbendl ; get new start low byte
LDY Nbendh ; get new start high byte (-$100)
INY ; correct high byte
STA Sarryl ; save new var mem end low byte
STY Sarryh ; save new var mem end high byte
LDY #$00 ; clear index
LDA Varnm1 ; get var name 1st character
STA (Vrschl),Y ; save var name 1st character
INY ; increment index
LDA Varnm2 ; get var name 2nd character
STA (Vrschl),Y ; save var name 2nd character
LDA #$00 ; clear A
INY ; increment index
STA (Vrschl),Y ; initialise var byte
INY ; increment index
STA (Vrschl),Y ; initialise var byte
INY ; increment index
STA (Vrschl),Y ; initialise var byte
INY ; increment index
STA (Vrschl),Y ; initialise var byte
; found a match for var ((Vrschl) = ptr)
LAB_1DD7
LDA Vrschl ; get var address low byte
CLC ; clear carry for add
ADC #$02 ; +2 (offset past var name bytes)
LDY Vrschh ; get var address high byte
BCC LAB_1DE1 ; branch if no overflow from add
INY ; else increment high byte
LAB_1DE1
STA Cvaral ; save current var address low byte
STY Cvarah ; save current var address high byte
RTS
; set-up array pointer (Adatal/h) to first element in array
; set Adatal,Adatah to Astrtl,Astrth+2*Dimcnt+#$05
LAB_1DE6
LDA Dimcnt ; get # of dimensions (1, 2 or 3)
ASL ; *2 (also clears the carry !)
ADC #$05 ; +5 (result is 7, 9 or 11 here)
ADC Astrtl ; add array start pointer low byte
LDY Astrth ; get array pointer high byte
BCC LAB_1DF2 ; branch if no overflow
INY ; else increment high byte
LAB_1DF2
STA Adatal ; save array data pointer low byte
STY Adatah ; save array data pointer high byte
RTS
; evaluate integer expression
LAB_EVIN
JSR LAB_IGBY ; increment and scan memory
JSR LAB_EVNM ; evaluate expression and check is numeric,
; else do type mismatch
; evaluate integer expression (no check)
LAB_EVPI
LDA FAC1_s ; get FAC1 sign (b7)
BMI LAB_1E12 ; do function call error if -ve
; evaluate integer expression (no sign check)
LAB_EVIR
LDA FAC1_e ; get FAC1 exponent
CMP #$90 ; compare with exponent = 2^16 (n>2^15)
BCC LAB_1E14 ; branch if n<2^16 (is ok)
LDA #<LAB_1DF7 ; set pointer low byte to -32768
LDY #>LAB_1DF7 ; set pointer high byte to -32768
JSR LAB_27F8 ; compare FAC1 with (AY)
LAB_1E12
BNE LAB_FCER ; if <> do function call error then warm start
LAB_1E14
JMP LAB_2831 ; convert FAC1 floating-to-fixed and return
; find or make array
LAB_1E17
LDA Defdim ; get DIM flag
PHA ; push it
LDA Dtypef ; get data type flag, $FF=string, $00=numeric
PHA ; push it
LDY #$00 ; clear dimensions count
; now get the array dimension(s) and stack it (them) before the data type and DIM flag
LAB_1E1F
TYA ; copy dimensions count
PHA ; save it
LDA Varnm2 ; get array name 2nd byte
PHA ; save it
LDA Varnm1 ; get array name 1st byte
PHA ; save it
JSR LAB_EVIN ; evaluate integer expression
PLA ; pull array name 1st byte
STA Varnm1 ; restore array name 1st byte
PLA ; pull array name 2nd byte
STA Varnm2 ; restore array name 2nd byte
PLA ; pull dimensions count
TAY ; restore it
TSX ; copy stack pointer
LDA LAB_STAK+2,X ; get DIM flag
PHA ; push it
LDA LAB_STAK+1,X ; get data type flag
PHA ; push it
LDA FAC1_2 ; get this dimension size high byte
STA LAB_STAK+2,X ; stack before flag bytes
LDA FAC1_3 ; get this dimension size low byte
STA LAB_STAK+1,X ; stack before flag bytes
INY ; increment dimensions count
JSR LAB_GBYT ; scan memory
CMP #',' ; compare with ","
BEQ LAB_1E1F ; if found go do next dimension
STY Dimcnt ; store dimensions count
JSR LAB_1BFB ; scan for ")" , else do syntax error then warm start
PLA ; pull data type flag
STA Dtypef ; restore data type flag, $FF=string, $00=numeric
PLA ; pull DIM flag
STA Defdim ; restore DIM flag
LDX Sarryl ; get array mem start low byte
LDA Sarryh ; get array mem start high byte
; now check to see if we are at the end of array memory (we would be if there were
; no arrays).
LAB_1E5C
STX Astrtl ; save as array start pointer low byte
STA Astrth ; save as array start pointer high byte
CMP Earryh ; compare with array mem end high byte
BNE LAB_1E68 ; branch if not reached array mem end
CPX Earryl ; else compare with array mem end low byte
BEQ LAB_1EA1 ; go build array if not found
; search for array
LAB_1E68
LDY #$00 ; clear index
LDA (Astrtl),Y ; get array name first byte
INY ; increment index to second name byte
CMP Varnm1 ; compare with this array name first byte
BNE LAB_1E77 ; branch if no match
LDA Varnm2 ; else get this array name second byte
CMP (Astrtl),Y ; compare with array name second byte
BEQ LAB_1E8D ; array found so branch
; no match
LAB_1E77
INY ; increment index
LDA (Astrtl),Y ; get array size low byte
CLC ; clear carry for add
ADC Astrtl ; add array start pointer low byte
TAX ; copy low byte to X
INY ; increment index
LDA (Astrtl),Y ; get array size high byte
ADC Astrth ; add array mem pointer high byte
BCC LAB_1E5C ; if no overflow go check next array
; do array bounds error
LAB_1E85
LDX #$10 ; error code $10 ("Array bounds" error)
.byte $2C ; makes next bit BIT LAB_08A2
; do function call error
LAB_FCER
LDX #$08 ; error code $08 ("Function call" error)
LAB_1E8A
JMP LAB_XERR ; do error #X, then warm start
; found array, are we trying to dimension it?
LAB_1E8D
LDX #$12 ; set error $12 ("Double dimension" error)
LDA Defdim ; get DIM flag
BNE LAB_1E8A ; if we are trying to dimension it do error #X, then warm
; start
; found the array and we're not dimensioning it so we must find an element in it
JSR LAB_1DE6 ; set-up array pointer (Adatal/h) to first element in array
; (Astrtl,Astrth points to start of array)
LDA Dimcnt ; get dimensions count
LDY #$04 ; set index to array's # of dimensions
CMP (Astrtl),Y ; compare with no of dimensions
BNE LAB_1E85 ; if wrong do array bounds error, could do "Wrong
; dimensions" error here .. if we want a different
; error message
JMP LAB_1F28 ; found array so go get element
; (could jump to LAB_1F28 as all LAB_1F24 does is take
; Dimcnt and save it at (Astrtl),Y which is already the
; same or we would have taken the BNE)
; array not found, so build it
LAB_1EA1
JSR LAB_1DE6 ; set-up array pointer (Adatal/h) to first element in array
; (Astrtl,Astrth points to start of array)
JSR LAB_121F ; check available memory, "Out of memory" error if no room
; addr to check is in AY (low/high)
LDY #$00 ; clear Y (don't need to clear A)
STY Aspth ; clear array data size high byte
LDA Varnm1 ; get variable name 1st byte
STA (Astrtl),Y ; save array name 1st byte
INY ; increment index
LDA Varnm2 ; get variable name 2nd byte
STA (Astrtl),Y ; save array name 2nd byte
LDA Dimcnt ; get dimensions count
LDY #$04 ; index to dimension count
STY Asptl ; set array data size low byte (four bytes per element)
STA (Astrtl),Y ; set array's dimensions count
; now calculate the size of the data space for the array
CLC ; clear carry for add (clear on subsequent loops)
LAB_1EC0
LDX #$0B ; set default dimension value low byte
LDA #$00 ; set default dimension value high byte
BIT Defdim ; test default DIM flag
BVC LAB_1ED0 ; branch if b6 of Defdim is clear
PLA ; else pull dimension value low byte
ADC #$01 ; +1 (allow for zeroeth element)
TAX ; copy low byte to X
PLA ; pull dimension value high byte
ADC #$00 ; add carry from low byte
LAB_1ED0
INY ; index to dimension value high byte
STA (Astrtl),Y ; save dimension value high byte
INY ; index to dimension value high byte
TXA ; get dimension value low byte
STA (Astrtl),Y ; save dimension value low byte
JSR LAB_1F7C ; does XY = (Astrtl),Y * (Asptl)
STX Asptl ; save array data size low byte
STA Aspth ; save array data size high byte
LDY ut1_pl ; restore index (saved by subroutine)
DEC Dimcnt ; decrement dimensions count
BNE LAB_1EC0 ; loop while not = 0
ADC Adatah ; add size high byte to first element high byte
; (carry is always clear here)
BCS LAB_1F45 ; if overflow go do "Out of memory" error
STA Adatah ; save end of array high byte
TAY ; copy end high byte to Y
TXA ; get array size low byte
ADC Adatal ; add array start low byte
BCC LAB_1EF3 ; branch if no carry
INY ; else increment end of array high byte
BEQ LAB_1F45 ; if overflow go do "Out of memory" error
; set-up mostly complete, now zero the array
LAB_1EF3
JSR LAB_121F ; check available memory, "Out of memory" error if no room
; addr to check is in AY (low/high)
STA Earryl ; save array mem end low byte
STY Earryh ; save array mem end high byte
LDA #$00 ; clear byte for array clear
INC Aspth ; increment array size high byte (now block count)
LDY Asptl ; get array size low byte (now index to block)
BEQ LAB_1F07 ; branch if low byte = $00
LAB_1F02
DEY ; decrement index (do 0 to n-1)
STA (Adatal),Y ; zero byte
BNE LAB_1F02 ; loop until this block done
LAB_1F07
DEC Adatah ; decrement array pointer high byte
DEC Aspth ; decrement block count high byte
BNE LAB_1F02 ; loop until all blocks done
INC Adatah ; correct for last loop
SEC ; set carry for subtract
LDY #$02 ; index to array size low byte
LDA Earryl ; get array mem end low byte
SBC Astrtl ; subtract array start low byte
STA (Astrtl),Y ; save array size low byte
INY ; index to array size high byte
LDA Earryh ; get array mem end high byte
SBC Astrth ; subtract array start high byte
STA (Astrtl),Y ; save array size high byte
LDA Defdim ; get default DIM flag
BNE LAB_1F7B ; exit (RET) if this was a DIM command
; else, find element
INY ; index to # of dimensions
LAB_1F24
LDA (Astrtl),Y ; get array's dimension count
STA Dimcnt ; save it
; we have found, or built, the array. now we need to find the element
LAB_1F28
LDA #$00 ; clear byte
STA Asptl ; clear array data pointer low byte
LAB_1F2C
STA Aspth ; save array data pointer high byte
INY ; increment index (point to array bound high byte)
PLA ; pull array index low byte
TAX ; copy to X
STA FAC1_2 ; save index low byte to FAC1 mantissa2
PLA ; pull array index high byte
STA FAC1_3 ; save index high byte to FAC1 mantissa3
CMP (Astrtl),Y ; compare with array bound high byte
BCC LAB_1F48 ; branch if within bounds
BNE LAB_1F42 ; if outside bounds do array bounds error
; else high byte was = so test low bytes
INY ; index to array bound low byte
TXA ; get array index low byte
CMP (Astrtl),Y ; compare with array bound low byte
BCC LAB_1F49 ; branch if within bounds
LAB_1F42
JMP LAB_1E85 ; else do array bounds error
LAB_1F45
JMP LAB_OMER ; do "Out of memory" error then warm start
LAB_1F48
INY ; index to array bound low byte
LAB_1F49
LDA Aspth ; get array data pointer high byte
ORA Asptl ; OR with array data pointer low byte
BEQ LAB_1F5A ; branch if array data pointer = null (skip multiply)
JSR LAB_1F7C ; does XY = (Astrtl),Y * (Asptl)
TXA ; get result low byte
ADC FAC1_2 ; add index low byte from FAC1 mantissa2
TAX ; save result low byte
TYA ; get result high byte
LDY ut1_pl ; restore index
LAB_1F5A
ADC FAC1_3 ; add index high byte from FAC1 mantissa3
STX Asptl ; save array data pointer low byte
DEC Dimcnt ; decrement dimensions count
BNE LAB_1F2C ; loop if dimensions still to do
ASL Asptl ; array data pointer low byte * 2
ROL ; array data pointer high byte * 2
ASL Asptl ; array data pointer low byte * 4
ROL ; array data pointer high byte * 4
TAY ; copy high byte
LDA Asptl ; get low byte
ADC Adatal ; add array data start pointer low byte
STA Cvaral ; save as current var address low byte
TYA ; get high byte back
ADC Adatah ; add array data start pointer high byte
STA Cvarah ; save as current var address high byte
TAY ; copy high byte to Y
LDA Cvaral ; get current var address low byte
LAB_1F7B
RTS
; does XY = (Astrtl),Y * (Asptl)
LAB_1F7C
STY ut1_pl ; save index
LDA (Astrtl),Y ; get dimension size low byte
STA dims_l ; save dimension size low byte
DEY ; decrement index
LDA (Astrtl),Y ; get dimension size high byte
STA dims_h ; save dimension size high byte
LDA #$10 ; count = $10 (16 bit multiply)
STA numbit ; save bit count
LDX #$00 ; clear result low byte
LDY #$00 ; clear result high byte
LAB_1F8F
TXA ; get result low byte
ASL ; *2
TAX ; save result low byte
TYA ; get result high byte
ROL ; *2
TAY ; save result high byte
BCS LAB_1F45 ; if overflow go do "Out of memory" error
ASL Asptl ; shift multiplier low byte
ROL Aspth ; shift multiplier high byte
BCC LAB_1FA8 ; skip add if no carry
CLC ; else clear carry for add
TXA ; get result low byte
ADC dims_l ; add dimension size low byte
TAX ; save result low byte
TYA ; get result high byte
ADC dims_h ; add dimension size high byte
TAY ; save result high byte
BCS LAB_1F45 ; if overflow go do "Out of memory" error
LAB_1FA8
DEC numbit ; decrement bit count
BNE LAB_1F8F ; loop until all done
RTS
; perform FRE()
LAB_FRE
LDA Dtypef ; get data type flag, $FF=string, $00=numeric
BPL LAB_1FB4 ; branch if numeric
JSR LAB_22B6 ; pop string off descriptor stack, or from top of string
; space returns with A = length, X=$71=pointer low byte,
; Y=$72=pointer high byte
; FRE(n) was numeric so do this
LAB_1FB4
JSR LAB_GARB ; go do garbage collection
SEC ; set carry for subtract
LDA Sstorl ; get bottom of string space low byte
SBC Earryl ; subtract array mem end low byte
TAY ; copy result to Y
LDA Sstorh ; get bottom of string space high byte
SBC Earryh ; subtract array mem end high byte
; save and convert integer AY to FAC1
LAB_AYFC
LSR Dtypef ; clear data type flag, $FF=string, $00=numeric
STA FAC1_1 ; save FAC1 mantissa1
STY FAC1_2 ; save FAC1 mantissa2
LDX #$90 ; set exponent=2^16 (integer)
JMP LAB_27E3 ; set exp=X, clear FAC1_3, normalise and return
; perform POS()
LAB_POS
LDY TPos ; get terminal position
; convert Y to byte in FAC1
LAB_1FD0
LDA #$00 ; clear high byte
BEQ LAB_AYFC ; always save and convert integer AY to FAC1 and return
; check not Direct (used by DEF and INPUT)
LAB_CKRN
LDX Clineh ; get current line high byte
INX ; increment it
BNE LAB_1F7B ; return if can continue not direct mode
; else do illegal direct error
LAB_1FD9
LDX #$16 ; error code $16 ("Illegal direct" error)
LAB_1FDB
JMP LAB_XERR ; go do error #X, then warm start
; perform DEF
LAB_DEF
JSR LAB_200B ; check FNx syntax
STA func_l ; save function pointer low byte
STY func_h ; save function pointer high byte
JSR LAB_CKRN ; check not Direct (back here if ok)
JSR LAB_1BFE ; scan for "(" , else do syntax error then warm start
LDA #$80 ; set flag for FNx
STA Sufnxf ; save subscript/FNx flag
JSR LAB_GVAR ; get (var) address
JSR LAB_CTNM ; check if source is numeric, else do type mismatch
JSR LAB_1BFB ; scan for ")" , else do syntax error then warm start
LDA #TK_EQUAL ; get = token
JSR LAB_SCCA ; scan for CHR$(A), else do syntax error then warm start
LDA Cvarah ; get current var address high byte
PHA ; push it
LDA Cvaral ; get current var address low byte
PHA ; push it
LDA Bpntrh ; get BASIC execute pointer high byte
PHA ; push it
LDA Bpntrl ; get BASIC execute pointer low byte
PHA ; push it
JSR LAB_DATA ; go perform DATA
JMP LAB_207A ; put execute pointer and variable pointer into function
; and return
; check FNx syntax
LAB_200B
LDA #TK_FN ; get FN" token
JSR LAB_SCCA ; scan for CHR$(A) , else do syntax error then warm start
; return character after A
ORA #$80 ; set FN flag bit
STA Sufnxf ; save FN flag so array variable test fails
JSR LAB_1D12 ; search for FN variable
JMP LAB_CTNM ; check if source is numeric and return, else do type
; mismatch
; Evaluate FNx
LAB_201E
JSR LAB_200B ; check FNx syntax
PHA ; push function pointer low byte
TYA ; copy function pointer high byte
PHA ; push function pointer high byte
JSR LAB_1BFE ; scan for "(", else do syntax error then warm start
JSR LAB_EVEX ; evaluate expression
JSR LAB_1BFB ; scan for ")", else do syntax error then warm start
JSR LAB_CTNM ; check if source is numeric, else do type mismatch
PLA ; pop function pointer high byte
STA func_h ; restore it
PLA ; pop function pointer low byte
STA func_l ; restore it
LDX #$20 ; error code $20 ("Undefined function" error)
LDY #$03 ; index to variable pointer high byte
LDA (func_l),Y ; get variable pointer high byte
BEQ LAB_1FDB ; if zero go do undefined function error
STA Cvarah ; save variable address high byte
DEY ; index to variable address low byte
LDA (func_l),Y ; get variable address low byte
STA Cvaral ; save variable address low byte
TAX ; copy address low byte
; now stack the function variable value before use
INY ; index to mantissa_3
LAB_2043
LDA (Cvaral),Y ; get byte from variable
PHA ; stack it
DEY ; decrement index
BPL LAB_2043 ; loop until variable stacked
LDY Cvarah ; get variable address high byte
JSR LAB_2778 ; pack FAC1 (function expression value) into (XY)
; (function variable), return Y=0, always
LDA Bpntrh ; get BASIC execute pointer high byte
PHA ; push it
LDA Bpntrl ; get BASIC execute pointer low byte
PHA ; push it
LDA (func_l),Y ; get function execute pointer low byte
STA Bpntrl ; save as BASIC execute pointer low byte
INY ; index to high byte
LDA (func_l),Y ; get function execute pointer high byte
STA Bpntrh ; save as BASIC execute pointer high byte
LDA Cvarah ; get variable address high byte
PHA ; push it
LDA Cvaral ; get variable address low byte
PHA ; push it
JSR LAB_EVNM ; evaluate expression and check is numeric,
; else do type mismatch
PLA ; pull variable address low byte
STA func_l ; save variable address low byte
PLA ; pull variable address high byte
STA func_h ; save variable address high byte
JSR LAB_GBYT ; scan memory
BEQ LAB_2074 ; branch if null (should be [EOL] marker)
JMP LAB_SNER ; else syntax error then warm start
; restore Bpntrl,Bpntrh and function variable from stack
LAB_2074
PLA ; pull BASIC execute pointer low byte
STA Bpntrl ; restore BASIC execute pointer low byte
PLA ; pull BASIC execute pointer high byte
STA Bpntrh ; restore BASIC execute pointer high byte
; put execute pointer and variable pointer into function
LAB_207A
LDY #$00 ; clear index
PLA ; pull BASIC execute pointer low byte
STA (func_l),Y ; save to function
INY ; increment index
PLA ; pull BASIC execute pointer high byte
STA (func_l),Y ; save to function
INY ; increment index
PLA ; pull current var address low byte
STA (func_l),Y ; save to function
INY ; increment index
PLA ; pull current var address high byte
STA (func_l),Y ; save to function
RTS
; perform STR$()
LAB_STRS
JSR LAB_CTNM ; check if source is numeric, else do type mismatch
JSR LAB_296E ; convert FAC1 to string
LDA #<Decssp1 ; set result string low pointer
LDY #>Decssp1 ; set result string high pointer
BEQ LAB_20AE ; print null terminated string to Sutill/Sutilh
; Do string vector
; copy des_pl/h to des_2l/h and make string space A bytes long
LAB_209C
LDX des_pl ; get descriptor pointer low byte
LDY des_ph ; get descriptor pointer high byte
STX des_2l ; save descriptor pointer low byte
STY des_2h ; save descriptor pointer high byte
; make string space A bytes long
; A=length, X=Sutill=ptr low byte, Y=Sutilh=ptr high byte
LAB_MSSP
JSR LAB_2115 ; make space in string memory for string A long
; return X=Sutill=ptr low byte, Y=Sutilh=ptr high byte
STX str_pl ; save string pointer low byte
STY str_ph ; save string pointer high byte
STA str_ln ; save length
RTS
; Scan, set up string
; print " terminated string to Sutill/Sutilh
LAB_20AE
LDX #$22 ; set terminator to "
STX Srchc ; set search character (terminator 1)
STX Asrch ; set terminator 2
; print [Srchc] or [Asrch] terminated string to Sutill/Sutilh
; source is AY
LAB_20B4
STA ssptr_l ; store string start low byte
STY ssptr_h ; store string start high byte
STA str_pl ; save string pointer low byte
STY str_ph ; save string pointer high byte
LDY #$FF ; set length to -1
LAB_20BE
INY ; increment length
LDA (ssptr_l),Y ; get byte from string
BEQ LAB_20CF ; exit loop if null byte [EOS]
CMP Srchc ; compare with search character (terminator 1)
BEQ LAB_20CB ; branch if terminator
CMP Asrch ; compare with terminator 2
BNE LAB_20BE ; loop if not terminator 2
LAB_20CB
CMP #$22 ; compare with "
BEQ LAB_20D0 ; branch if " (carry set if = !)
LAB_20CF
CLC ; clear carry for add (only if [EOL] terminated string)
LAB_20D0
STY str_ln ; save length in FAC1 exponent
TYA ; copy length to A
ADC ssptr_l ; add string start low byte
STA Sendl ; save string end low byte
LDX ssptr_h ; get string start high byte
BCC LAB_20DC ; branch if no low byte overflow
INX ; else increment high byte
LAB_20DC
STX Sendh ; save string end high byte
LDA ssptr_h ; get string start high byte
; *** begin RAM above code / Ibuff above EhBASIC patch V2 ***
; *** replace
; CMP #>Ram_base ; compare with start of program memory
; BCS LAB_RTST ; branch if not in utility area
; *** with
BEQ LAB_MVST ; fix STR$() using page zero via LAB_296E
CMP #>Ibuffs ; compare with location of input buffer page
BNE LAB_RTST ; branch if not in utility area
LAB_MVST
; *** end RAM above code / Ibuff above EhBASIC patch V2 ***
; string in utility area, move to string memory
TYA ; copy length to A
JSR LAB_209C ; copy des_pl/h to des_2l/h and make string space A bytes
; long
LDX ssptr_l ; get string start low byte
LDY ssptr_h ; get string start high byte
JSR LAB_2298 ; store string A bytes long from XY to (Sutill)
; check for space on descriptor stack then ..
; put string address and length on descriptor stack and update stack pointers
LAB_RTST
LDX next_s ; get string stack pointer
CPX #des_sk+$09 ; compare with max+1
BNE LAB_20F8 ; branch if space on string stack
; else do string too complex error
LDX #$1C ; error code $1C ("String too complex" error)
LAB_20F5
JMP LAB_XERR ; do error #X, then warm start
; put string address and length on descriptor stack and update stack pointers
LAB_20F8
LDA str_ln ; get string length
STA PLUS_0,X ; put on string stack
LDA str_pl ; get string pointer low byte
STA PLUS_1,X ; put on string stack
LDA str_ph ; get string pointer high byte
STA PLUS_2,X ; put on string stack
LDY #$00 ; clear Y
STX des_pl ; save string descriptor pointer low byte
STY des_ph ; save string descriptor pointer high byte (always $00)
DEY ; Y = $FF
STY Dtypef ; save data type flag, $FF=string
STX last_sl ; save old stack pointer (current top item)
INX ; update stack pointer
INX ; update stack pointer
INX ; update stack pointer
STX next_s ; save new top item value
RTS
; Build descriptor
; make space in string memory for string A long
; return X=Sutill=ptr low byte, Y=Sutill=ptr high byte
LAB_2115
LSR Gclctd ; clear garbage collected flag (b7)
; make space for string A long
LAB_2117
PHA ; save string length
EOR #$FF ; complement it
SEC ; set carry for subtract (twos comp add)
ADC Sstorl ; add bottom of string space low byte (subtract length)
LDY Sstorh ; get bottom of string space high byte
BCS LAB_2122 ; skip decrement if no underflow
DEY ; decrement bottom of string space high byte
LAB_2122
CPY Earryh ; compare with array mem end high byte
BCC LAB_2137 ; do out of memory error if less
BNE LAB_212C ; if not = skip next test
CMP Earryl ; compare with array mem end low byte
BCC LAB_2137 ; do out of memory error if less
LAB_212C
STA Sstorl ; save bottom of string space low byte
STY Sstorh ; save bottom of string space high byte
STA Sutill ; save string utility ptr low byte
STY Sutilh ; save string utility ptr high byte
TAX ; copy low byte to X
PLA ; get string length back
RTS
LAB_2137
LDX #$0C ; error code $0C ("Out of memory" error)
LDA Gclctd ; get garbage collected flag
BMI LAB_20F5 ; if set then do error code X
JSR LAB_GARB ; else go do garbage collection
LDA #$80 ; flag for garbage collected
STA Gclctd ; set garbage collected flag
PLA ; pull length
BNE LAB_2117 ; go try again (loop always, length should never be = $00)
; garbage collection routine
LAB_GARB
LDX Ememl ; get end of mem low byte
LDA Ememh ; get end of mem high byte
; re-run routine from last ending
LAB_214B
STX Sstorl ; set string storage low byte
STA Sstorh ; set string storage high byte
LDY #$00 ; clear index
STY garb_h ; clear working pointer high byte (flag no strings to move)
; *** begin patch 2.22p5.5 garbage collection may overlap temporary strings
; *** add
STY garb_l ; clear working pointer low byte (flag no strings to move)
; *** begin patch 2.22p5.5 garbage collection may overlap temporary strings
LDA Earryl ; get array mem end low byte
LDX Earryh ; get array mem end high byte
STA Histrl ; save as highest string low byte
STX Histrh ; save as highest string high byte
LDA #des_sk ; set descriptor stack pointer
STA ut1_pl ; save descriptor stack pointer low byte
STY ut1_ph ; save descriptor stack pointer high byte ($00)
LAB_2161
CMP next_s ; compare with descriptor stack pointer
BEQ LAB_216A ; branch if =
JSR LAB_21D7 ; go garbage collect descriptor stack
BEQ LAB_2161 ; loop always
; done stacked strings, now do string vars
LAB_216A
ASL g_step ; set step size = $06
LDA Svarl ; get start of vars low byte
LDX Svarh ; get start of vars high byte
STA ut1_pl ; save as pointer low byte
STX ut1_ph ; save as pointer high byte
LAB_2176
CPX Sarryh ; compare start of arrays high byte
BNE LAB_217E ; branch if no high byte match
CMP Sarryl ; else compare start of arrays low byte
BEQ LAB_2183 ; branch if = var mem end
LAB_217E
JSR LAB_21D1 ; go garbage collect strings
BEQ LAB_2176 ; loop always
; done string vars, now do string arrays
LAB_2183
STA Nbendl ; save start of arrays low byte as working pointer
STX Nbendh ; save start of arrays high byte as working pointer
LDA #$04 ; set step size
STA g_step ; save step size
LAB_218B
LDA Nbendl ; get pointer low byte
LDX Nbendh ; get pointer high byte
LAB_218F
CPX Earryh ; compare with array mem end high byte
BNE LAB_219A ; branch if not at end
CMP Earryl ; else compare with array mem end low byte
BEQ LAB_2216 ; tidy up and exit if at end
LAB_219A
STA ut1_pl ; save pointer low byte
STX ut1_ph ; save pointer high byte
LDY #$02 ; set index
LDA (ut1_pl),Y ; get array size low byte
ADC Nbendl ; add start of this array low byte
STA Nbendl ; save start of next array low byte
INY ; increment index
LDA (ut1_pl),Y ; get array size high byte
ADC Nbendh ; add start of this array high byte
STA Nbendh ; save start of next array high byte
LDY #$01 ; set index
LDA (ut1_pl),Y ; get name second byte
BPL LAB_218B ; skip if not string array
; was string array so ..
LDY #$04 ; set index
LDA (ut1_pl),Y ; get # of dimensions
ASL ; *2
ADC #$05 ; +5 (array header size)
JSR LAB_2208 ; go set up for first element
LAB_21C4
CPX Nbendh ; compare with start of next array high byte
BNE LAB_21CC ; branch if <> (go do this array)
CMP Nbendl ; else compare element pointer low byte with next array
; low byte
BEQ LAB_218F ; if equal then go do next array
LAB_21CC
JSR LAB_21D7 ; go defrag array strings
BEQ LAB_21C4 ; go do next array string (loop always)
; defrag string variables
; enter with XA = variable pointer
; return with XA = next variable pointer
LAB_21D1
INY ; increment index (Y was $00)
LDA (ut1_pl),Y ; get var name byte 2
BPL LAB_2206 ; if not string, step pointer to next var and return
INY ; else increment index
LAB_21D7
LDA (ut1_pl),Y ; get string length
BEQ LAB_2206 ; if null, step pointer to next string and return
INY ; else increment index
LDA (ut1_pl),Y ; get string pointer low byte
TAX ; copy to X
INY ; increment index
LDA (ut1_pl),Y ; get string pointer high byte
CMP Sstorh ; compare bottom of string space high byte
BCC LAB_21EC ; branch if less
BNE LAB_2206 ; if greater, step pointer to next string and return
; high bytes were = so compare low bytes
CPX Sstorl ; compare bottom of string space low byte
BCS LAB_2206 ; if >=, step pointer to next string and return
; string pointer is < string storage pointer (pos in mem)
LAB_21EC
CMP Histrh ; compare to highest string high byte
BCC LAB_2207 ; if <, step pointer to next string and return
BNE LAB_21F6 ; if > update pointers, step to next and return
; high bytes were = so compare low bytes
CPX Histrl ; compare to highest string low byte
BCC LAB_2207 ; if <, step pointer to next string and return
; string is in string memory space
LAB_21F6
STX Histrl ; save as new highest string low byte
STA Histrh ; save as new highest string high byte
LDA ut1_pl ; get start of vars(descriptors) low byte
LDX ut1_ph ; get start of vars(descriptors) high byte
STA garb_l ; save as working pointer low byte
STX garb_h ; save as working pointer high byte
DEY ; decrement index DIFFERS
DEY ; decrement index (should point to descriptor start)
STY g_indx ; save index pointer
; step pointer to next string
LAB_2206
CLC ; clear carry for add
LAB_2207
LDA g_step ; get step size
LAB_2208
ADC ut1_pl ; add pointer low byte
STA ut1_pl ; save pointer low byte
BCC LAB_2211 ; branch if no overflow
INC ut1_ph ; else increment high byte
LAB_2211
LDX ut1_ph ; get pointer high byte
LDY #$00 ; clear Y
RTS
; search complete, now either exit or set-up and move string
LAB_2216
DEC g_step ; decrement step size (now $03 for descriptor stack)
; *** begin patch 2.22p5.5 garbage collection may overlap temporary strings
; *** replace
; LDX garb_h ; get string to move high byte
; *** with
LDA garb_h ; any string to move?
ORA garb_l
; *** end patch 2.22p5.5 garbage collection may overlap temporary strings
BEQ LAB_2211 ; exit if nothing to move
LDY g_indx ; get index byte back (points to descriptor)
CLC ; clear carry for add
LDA (garb_l),Y ; get string length
ADC Histrl ; add highest string low byte
STA Obendl ; save old block end low pointer
LDA Histrh ; get highest string high byte
ADC #$00 ; add any carry
STA Obendh ; save old block end high byte
LDA Sstorl ; get bottom of string space low byte
LDX Sstorh ; get bottom of string space high byte
STA Nbendl ; save new block end low byte
STX Nbendh ; save new block end high byte
JSR LAB_11D6 ; open up space in memory, don't set array end
LDY g_indx ; get index byte
INY ; point to descriptor low byte
LDA Nbendl ; get string pointer low byte
STA (garb_l),Y ; save new string pointer low byte
TAX ; copy string pointer low byte
INC Nbendh ; correct high byte (move sets high byte -1)
LDA Nbendh ; get new string pointer high byte
INY ; point to descriptor high byte
STA (garb_l),Y ; save new string pointer high byte
JMP LAB_214B ; re-run routine from last ending
; (but don't collect this string)
; concatenate
; add strings, string 1 is in descriptor des_pl, string 2 is in line
LAB_224D
LDA des_ph ; get descriptor pointer high byte
PHA ; put on stack
LDA des_pl ; get descriptor pointer low byte
PHA ; put on stack
; *** begin patch 2.22p5.4 concatenate MINUS or NOT() crashes EhBASIC ***
; *** add extra label to verify originating function
LAB_224Da
; *** end patch 2.22p5.4 concatenate MINUS or NOT() crashes EhBASIC ***
JSR LAB_GVAL ; get value from line
JSR LAB_CTST ; check if source is string, else do type mismatch
PLA ; get descriptor pointer low byte back
STA ssptr_l ; set pointer low byte
PLA ; get descriptor pointer high byte back
STA ssptr_h ; set pointer high byte
LDY #$00 ; clear index
LDA (ssptr_l),Y ; get length_1 from descriptor
CLC ; clear carry for add
ADC (des_pl),Y ; add length_2
BCC LAB_226D ; branch if no overflow
LDX #$1A ; else set error code $1A ("String too long" error)
JMP LAB_XERR ; do error #X, then warm start
LAB_226D
JSR LAB_209C ; copy des_pl/h to des_2l/h and make string space A bytes
; long
JSR LAB_228A ; copy string from descriptor (sdescr) to (Sutill)
LDA des_2l ; get descriptor pointer low byte
LDY des_2h ; get descriptor pointer high byte
JSR LAB_22BA ; pop (YA) descriptor off stack or from top of string space
; returns with A = length, ut1_pl = pointer low byte,
; ut1_ph = pointer high byte
JSR LAB_229C ; store string A bytes long from (ut1_pl) to (Sutill)
LDA ssptr_l ;.set descriptor pointer low byte
LDY ssptr_h ;.set descriptor pointer high byte
JSR LAB_22BA ; pop (YA) descriptor off stack or from top of string space
; returns with A = length, X=ut1_pl=pointer low byte,
; Y=ut1_ph=pointer high byte
JSR LAB_RTST ; check for space on descriptor stack then put string
; address and length on descriptor stack and update stack
; pointers
JMP LAB_1ADB ;.continue evaluation
; copy string from descriptor (sdescr) to (Sutill)
LAB_228A
LDY #$00 ; clear index
LDA (sdescr),Y ; get string length
PHA ; save on stack
INY ; increment index
LDA (sdescr),Y ; get source string pointer low byte
TAX ; copy to X
INY ; increment index
LDA (sdescr),Y ; get source string pointer high byte
TAY ; copy to Y
PLA ; get length back
; store string A bytes long from YX to (Sutill)
LAB_2298
STX ut1_pl ; save source string pointer low byte
STY ut1_ph ; save source string pointer high byte
; store string A bytes long from (ut1_pl) to (Sutill)
LAB_229C
TAX ; copy length to index (don't count with Y)
BEQ LAB_22B2 ; branch if = $0 (null string) no need to add zero length
LDY #$00 ; zero pointer (copy forward)
LAB_22A0
LDA (ut1_pl),Y ; get source byte
STA (Sutill),Y ; save destination byte
INY ; increment index
DEX ; decrement counter
BNE LAB_22A0 ; loop while <> 0
TYA ; restore length from Y
LAB_22A9
CLC ; clear carry for add
ADC Sutill ; add string utility ptr low byte
STA Sutill ; save string utility ptr low byte
BCC LAB_22B2 ; branch if no carry
INC Sutilh ; else increment string utility ptr high byte
LAB_22B2
RTS
; evaluate string
LAB_EVST
JSR LAB_CTST ; check if source is string, else do type mismatch
; pop string off descriptor stack, or from top of string space
; returns with A = length, X=pointer low byte, Y=pointer high byte
LAB_22B6
LDA des_pl ; get descriptor pointer low byte
LDY des_ph ; get descriptor pointer high byte
; pop (YA) descriptor off stack or from top of string space
; returns with A = length, X=ut1_pl=pointer low byte, Y=ut1_ph=pointer high byte
LAB_22BA
STA ut1_pl ; save descriptor pointer low byte
STY ut1_ph ; save descriptor pointer high byte
JSR LAB_22EB ; clean descriptor stack, YA = pointer
PHP ; save status flags
LDY #$00 ; clear index
LDA (ut1_pl),Y ; get length from string descriptor
PHA ; put on stack
INY ; increment index
LDA (ut1_pl),Y ; get string pointer low byte from descriptor
TAX ; copy to X
INY ; increment index
LDA (ut1_pl),Y ; get string pointer high byte from descriptor
TAY ; copy to Y
PLA ; get string length back
PLP ; restore status
BNE LAB_22E6 ; branch if pointer <> last_sl,last_sh
CPY Sstorh ; compare bottom of string space high byte
BNE LAB_22E6 ; branch if <>
CPX Sstorl ; else compare bottom of string space low byte
BNE LAB_22E6 ; branch if <>
PHA ; save string length
CLC ; clear carry for add
ADC Sstorl ; add bottom of string space low byte
STA Sstorl ; save bottom of string space low byte
BCC LAB_22E5 ; skip increment if no overflow
INC Sstorh ; increment bottom of string space high byte
LAB_22E5
PLA ; restore string length
LAB_22E6
STX ut1_pl ; save string pointer low byte
STY ut1_ph ; save string pointer high byte
RTS
; clean descriptor stack, YA = pointer
; checks if AY is on the descriptor stack, if so does a stack discard
LAB_22EB
CPY last_sh ; compare pointer high byte
BNE LAB_22FB ; exit if <>
CMP last_sl ; compare pointer low byte
BNE LAB_22FB ; exit if <>
STA next_s ; save descriptor stack pointer
SBC #$03 ; -3
STA last_sl ; save low byte -3
LDY #$00 ; clear high byte
LAB_22FB
RTS
; perform CHR$()
LAB_CHRS
JSR LAB_EVBY ; evaluate byte expression, result in X
TXA ; copy to A
PHA ; save character
LDA #$01 ; string is single byte
JSR LAB_MSSP ; make string space A bytes long A=$AC=length,
; X=$AD=Sutill=ptr low byte, Y=$AE=Sutilh=ptr high byte
PLA ; get character back
LDY #$00 ; clear index
STA (str_pl),Y ; save byte in string (byte IS string!)
JMP LAB_RTST ; check for space on descriptor stack then put string
; address and length on descriptor stack and update stack
; pointers
; perform LEFT$()
LAB_LEFT
PHA ; push byte parameter
JSR LAB_236F ; pull string data and byte parameter from stack
; return pointer in des_2l/h, byte in A (and X), Y=0
CMP (des_2l),Y ; compare byte parameter with string length
TYA ; clear A
BEQ LAB_2316 ; go do string copy (branch always)
; perform RIGHT$()
LAB_RIGHT
PHA ; push byte parameter
JSR LAB_236F ; pull string data and byte parameter from stack
; return pointer in des_2l/h, byte in A (and X), Y=0
CLC ; clear carry for add-1
SBC (des_2l),Y ; subtract string length
EOR #$FF ; invert it (A=LEN(expression$)-l)
LAB_2316
BCC LAB_231C ; branch if string length > byte parameter
LDA (des_2l),Y ; else make parameter = length
TAX ; copy to byte parameter copy
TYA ; clear string start offset
LAB_231C
PHA ; save string start offset
LAB_231D
TXA ; copy byte parameter (or string length if <)
LAB_231E
PHA ; save string length
JSR LAB_MSSP ; make string space A bytes long A=$AC=length,
; X=$AD=Sutill=ptr low byte, Y=$AE=Sutilh=ptr high byte
LDA des_2l ; get descriptor pointer low byte
LDY des_2h ; get descriptor pointer high byte
JSR LAB_22BA ; pop (YA) descriptor off stack or from top of string space
; returns with A = length, X=ut1_pl=pointer low byte,
; Y=ut1_ph=pointer high byte
PLA ; get string length back
TAY ; copy length to Y
PLA ; get string start offset back
CLC ; clear carry for add
ADC ut1_pl ; add start offset to string start pointer low byte
STA ut1_pl ; save string start pointer low byte
BCC LAB_2335 ; branch if no overflow
INC ut1_ph ; else increment string start pointer high byte
LAB_2335
TYA ; copy length to A
JSR LAB_229C ; store string A bytes long from (ut1_pl) to (Sutill)
JMP LAB_RTST ; check for space on descriptor stack then put string
; address and length on descriptor stack and update stack
; pointers
; perform MID$()
LAB_MIDS
PHA ; push byte parameter
LDA #$FF ; set default length = 255
STA mids_l ; save default length
JSR LAB_GBYT ; scan memory
CMP #')' ; compare with ")"
BEQ LAB_2358 ; branch if = ")" (skip second byte get)
JSR LAB_1C01 ; scan for "," , else do syntax error then warm start
JSR LAB_GTBY ; get byte parameter (use copy in mids_l)
LAB_2358
JSR LAB_236F ; pull string data and byte parameter from stack
; return pointer in des_2l/h, byte in A (and X), Y=0
DEX ; decrement start index
TXA ; copy to A
PHA ; save string start offset
CLC ; clear carry for sub-1
LDX #$00 ; clear output string length
SBC (des_2l),Y ; subtract string length
BCS LAB_231D ; if start>string length go do null string
EOR #$FF ; complement -length
CMP mids_l ; compare byte parameter
BCC LAB_231E ; if length>remaining string go do RIGHT$
LDA mids_l ; get length byte
BCS LAB_231E ; go do string copy (branch always)
; pull string data and byte parameter from stack
; return pointer in des_2l/h, byte in A (and X), Y=0
LAB_236F
JSR LAB_1BFB ; scan for ")" , else do syntax error then warm start
PLA ; pull return address low byte (return address)
STA Fnxjpl ; save functions jump vector low byte
PLA ; pull return address high byte (return address)
STA Fnxjph ; save functions jump vector high byte
PLA ; pull byte parameter
TAX ; copy byte parameter to X
PLA ; pull string pointer low byte
STA des_2l ; save it
PLA ; pull string pointer high byte
STA des_2h ; save it
LDY #$00 ; clear index
TXA ; copy byte parameter
BEQ LAB_23A8 ; if null do function call error then warm start
INC Fnxjpl ; increment function jump vector low byte
; (JSR pushes return addr-1. this is all very nice
; but will go tits up if either call is on a page
; boundary!)
JMP (Fnxjpl) ; in effect, RTS
; perform LCASE$()
LAB_LCASE
JSR LAB_EVST ; evaluate string
STA str_ln ; set string length
TAY ; copy length to Y
BEQ NoString ; branch if null string
JSR LAB_MSSP ; make string space A bytes long A=length,
; X=Sutill=ptr low byte, Y=Sutilh=ptr high byte
STX str_pl ; save string pointer low byte
STY str_ph ; save string pointer high byte
TAY ; get string length back
LC_loop
DEY ; decrement index
LDA (ut1_pl),Y ; get byte from string
JSR LAB_1D82 ; is character "A" to "Z"
BCC NoUcase ; branch if not upper case alpha
ORA #$20 ; convert upper to lower case
NoUcase
STA (Sutill),Y ; save byte back to string
TYA ; test index
BNE LC_loop ; loop if not all done
BEQ NoString ; tidy up and exit, branch always
; perform UCASE$()
LAB_UCASE
JSR LAB_EVST ; evaluate string
STA str_ln ; set string length
TAY ; copy length to Y
BEQ NoString ; branch if null string
JSR LAB_MSSP ; make string space A bytes long A=length,
; X=Sutill=ptr low byte, Y=Sutilh=ptr high byte
STX str_pl ; save string pointer low byte
STY str_ph ; save string pointer high byte
TAY ; get string length back
UC_loop
DEY ; decrement index
LDA (ut1_pl),Y ; get byte from string
JSR LAB_CASC ; is character "a" to "z" (or "A" to "Z")
BCC NoLcase ; branch if not alpha
AND #$DF ; convert lower to upper case
NoLcase
STA (Sutill),Y ; save byte back to string
TYA ; test index
BNE UC_loop ; loop if not all done
NoString
JMP LAB_RTST ; check for space on descriptor stack then put string
; address and length on descriptor stack and update stack
; pointers
; perform SADD()
LAB_SADD
JSR LAB_IGBY ; increment and scan memory
JSR LAB_GVAR ; get var address
JSR LAB_1BFB ; scan for ")", else do syntax error then warm start
JSR LAB_CTST ; check if source is string, else do type mismatch
LDY #$02 ; index to string pointer high byte
LDA (Cvaral),Y ; get string pointer high byte
TAX ; copy string pointer high byte to X
DEY ; index to string pointer low byte
LDA (Cvaral),Y ; get string pointer low byte
TAY ; copy string pointer low byte to Y
TXA ; copy string pointer high byte to A
JMP LAB_AYFC ; save and convert integer AY to FAC1 and return
; perform LEN()
LAB_LENS
JSR LAB_ESGL ; evaluate string, get length in A (and Y)
JMP LAB_1FD0 ; convert Y to byte in FAC1 and return
; evaluate string, get length in Y
LAB_ESGL
JSR LAB_EVST ; evaluate string
TAY ; copy length to Y
RTS
; perform ASC()
LAB_ASC
JSR LAB_ESGL ; evaluate string, get length in A (and Y)
BEQ LAB_23A8 ; if null do function call error then warm start
LDY #$00 ; set index to first character
LDA (ut1_pl),Y ; get byte
TAY ; copy to Y
JMP LAB_1FD0 ; convert Y to byte in FAC1 and return
; do function call error then warm start
LAB_23A8
JMP LAB_FCER ; do function call error then warm start
; scan and get byte parameter
LAB_SGBY
JSR LAB_IGBY ; increment and scan memory
; get byte parameter
LAB_GTBY
JSR LAB_EVNM ; evaluate expression and check is numeric,
; else do type mismatch
; evaluate byte expression, result in X
LAB_EVBY
JSR LAB_EVPI ; evaluate integer expression (no check)
LDY FAC1_2 ; get FAC1 mantissa2
BNE LAB_23A8 ; if top byte <> 0 do function call error then warm start
LDX FAC1_3 ; get FAC1 mantissa3
JMP LAB_GBYT ; scan memory and return
; perform VAL()
LAB_VAL
JSR LAB_ESGL ; evaluate string, get length in A (and Y)
BNE LAB_23C5 ; branch if not null string
; string was null so set result = $00
JMP LAB_24F1 ; clear FAC1 exponent and sign and return
LAB_23C5
; *** begin patch 2.22p5.7 VAL() may cause string variables to be trashed
; *** replace
; LDX Bpntrl ; get BASIC execute pointer low byte
; LDY Bpntrh ; get BASIC execute pointer high byte
; STX Btmpl ; save BASIC execute pointer low byte
; STY Btmph ; save BASIC execute pointer high byte
; LDX ut1_pl ; get string pointer low byte
; STX Bpntrl ; save as BASIC execute pointer low byte
; CLC ; clear carry
; ADC ut1_pl ; add string length
; STA ut2_pl ; save string end low byte
; LDA ut1_ph ; get string pointer high byte
; STA Bpntrh ; save as BASIC execute pointer high byte
; ADC #$00 ; add carry to high byte
; STA ut2_ph ; save string end high byte
; LDY #$00 ; set index to $00
; LDA (ut2_pl),Y ; get string end +1 byte
; PHA ; push it
; TYA ; clear A
; STA (ut2_pl),Y ; terminate string with $00
; JSR LAB_GBYT ; scan memory
; JSR LAB_2887 ; get FAC1 from string
; PLA ; restore string end +1 byte
; LDY #$00 ; set index to zero
; STA (ut2_pl),Y ; put string end byte back
; *** with
PHA ; save length
INY ; string length +1
TYA
JSR LAB_MSSP ; allocate temp string +1 bytes long
PLA ; get length back
JSR LAB_229C ; copy string (ut1_pl) -> (Sutill) for A bytes
LDA #0 ; add delimiter to end of string
TAY
STA (Sutill),Y
LDX Bpntrl ; save BASIC execute pointer low byte
LDY Bpntrh
STX Btmpl
STY Btmph
LDX str_pl ; point to temporary string
LDY str_ph
STX Bpntrl
STY Bpntrh
JSR LAB_GBYT ; scan memory
JSR LAB_2887 ; get FAC1 from string
; *** end patch 2.22p5.7 VAL() may cause string variables to be trashed
; restore BASIC execute pointer from temp (Btmpl/Btmph)
LAB_23F3
LDX Btmpl ; get BASIC execute pointer low byte back
LDY Btmph ; get BASIC execute pointer high byte back
STX Bpntrl ; save BASIC execute pointer low byte
STY Bpntrh ; save BASIC execute pointer high byte
RTS
; get two parameters for POKE or WAIT
LAB_GADB
JSR LAB_EVNM ; evaluate expression and check is numeric,
; else do type mismatch
JSR LAB_F2FX ; save integer part of FAC1 in temporary integer
; scan for "," and get byte, else do Syntax error then warm start
LAB_SCGB
JSR LAB_1C01 ; scan for "," , else do syntax error then warm start
LDA Itemph ; save temporary integer high byte
PHA ; on stack
LDA Itempl ; save temporary integer low byte
PHA ; on stack
JSR LAB_GTBY ; get byte parameter
PLA ; pull low byte
STA Itempl ; restore temporary integer low byte
PLA ; pull high byte
STA Itemph ; restore temporary integer high byte
RTS
; convert float to fixed routine. accepts any value that fits in 24 bits, +ve or
; -ve and converts it into a right truncated integer in Itempl and Itemph
; save unsigned 16 bit integer part of FAC1 in temporary integer
LAB_F2FX
LDA FAC1_e ; get FAC1 exponent
CMP #$98 ; compare with exponent = 2^24
BCS LAB_23A8 ; if >= do function call error then warm start
LAB_F2FU
JSR LAB_2831 ; convert FAC1 floating-to-fixed
LDA FAC1_2 ; get FAC1 mantissa2
LDY FAC1_3 ; get FAC1 mantissa3
STY Itempl ; save temporary integer low byte
STA Itemph ; save temporary integer high byte
RTS
; perform PEEK()
LAB_PEEK
JSR LAB_F2FX ; save integer part of FAC1 in temporary integer
LDX #$00 ; clear index
LDA (Itempl,X) ; get byte via temporary integer (addr)
TAY ; copy byte to Y
JMP LAB_1FD0 ; convert Y to byte in FAC1 and return
; perform POKE
LAB_POKE
JSR LAB_GADB ; get two parameters for POKE or WAIT
TXA ; copy byte argument to A
LDX #$00 ; clear index
STA (Itempl,X) ; save byte via temporary integer (addr)
RTS
; perform DEEK()
LAB_DEEK
JSR LAB_F2FX ; save integer part of FAC1 in temporary integer
LDX #$00 ; clear index
LDA (Itempl,X) ; PEEK low byte
TAY ; copy to Y
INC Itempl ; increment pointer low byte
BNE Deekh ; skip high increment if no rollover
INC Itemph ; increment pointer high byte
Deekh
LDA (Itempl,X) ; PEEK high byte
JMP LAB_AYFC ; save and convert integer AY to FAC1 and return
; perform DOKE
LAB_DOKE
JSR LAB_EVNM ; evaluate expression and check is numeric,
; else do type mismatch
JSR LAB_F2FX ; convert floating-to-fixed
STY Frnxtl ; save pointer low byte (float to fixed returns word in AY)
STA Frnxth ; save pointer high byte
JSR LAB_1C01 ; scan for "," , else do syntax error then warm start
JSR LAB_EVNM ; evaluate expression and check is numeric,
; else do type mismatch
JSR LAB_F2FX ; convert floating-to-fixed
TYA ; copy value low byte (float to fixed returns word in AY)
LDX #$00 ; clear index
STA (Frnxtl,X) ; POKE low byte
INC Frnxtl ; increment pointer low byte
BNE Dokeh ; skip high increment if no rollover
INC Frnxth ; increment pointer high byte
Dokeh
LDA Itemph ; get value high byte
STA (Frnxtl,X) ; POKE high byte
JMP LAB_GBYT ; scan memory and return
; perform SWAP
LAB_SWAP
JSR LAB_GVAR ; get var1 address
STA Lvarpl ; save var1 address low byte
STY Lvarph ; save var1 address high byte
LDA Dtypef ; get data type flag, $FF=string, $00=numeric
PHA ; save data type flag
JSR LAB_1C01 ; scan for "," , else do syntax error then warm start
JSR LAB_GVAR ; get var2 address (pointer in Cvaral/h)
PLA ; pull var1 data type flag
EOR Dtypef ; compare with var2 data type
BPL SwapErr ; exit if not both the same type
LDY #$03 ; four bytes to swap (either value or descriptor+1)
SwapLp
LDA (Lvarpl),Y ; get byte from var1
TAX ; save var1 byte
LDA (Cvaral),Y ; get byte from var2
STA (Lvarpl),Y ; save byte to var1
TXA ; restore var1 byte
STA (Cvaral),Y ; save byte to var2
DEY ; decrement index
BPL SwapLp ; loop until done
RTS
SwapErr
JMP LAB_1ABC ; do "Type mismatch" error then warm start
; perform CALL
LAB_CALL
JSR LAB_EVNM ; evaluate expression and check is numeric,
; else do type mismatch
JSR LAB_F2FX ; convert floating-to-fixed
LDA #>CallExit ; set return address high byte
PHA ; put on stack
LDA #<CallExit-1 ; set return address low byte
PHA ; put on stack
JMP (Itempl) ; do indirect jump to user routine
; if the called routine exits correctly then it will return to here. this will then get
; the next byte for the interpreter and return
CallExit
JMP LAB_GBYT ; scan memory and return
; perform WAIT
LAB_WAIT
JSR LAB_GADB ; get two parameters for POKE or WAIT
STX Frnxtl ; save byte
LDX #$00 ; clear mask
JSR LAB_GBYT ; scan memory
BEQ LAB_2441 ; skip if no third argument
JSR LAB_SCGB ; scan for "," and get byte, else SN error then warm start
LAB_2441
STX Frnxth ; save EOR argument
LAB_2445
LDA (Itempl),Y ; get byte via temporary integer (addr)
EOR Frnxth ; EOR with second argument (mask)
AND Frnxtl ; AND with first argument (byte)
BEQ LAB_2445 ; loop if result is zero
LAB_244D
RTS
; perform subtraction, FAC1 from (AY)
LAB_2455
JSR LAB_264D ; unpack memory (AY) into FAC2
; perform subtraction, FAC1 from FAC2
LAB_SUBTRACT
LDA FAC1_s ; get FAC1 sign (b7)
EOR #$FF ; complement it
STA FAC1_s ; save FAC1 sign (b7)
EOR FAC2_s ; EOR with FAC2 sign (b7)
STA FAC_sc ; save sign compare (FAC1 EOR FAC2)
LDA FAC1_e ; get FAC1 exponent
JMP LAB_ADD ; go add FAC2 to FAC1
; perform addition
LAB_2467
JSR LAB_257B ; shift FACX A times right (>8 shifts)
BCC LAB_24A8 ;.go subtract mantissas
; add 0.5 to FAC1
LAB_244E
LDA #<LAB_2A96 ; set 0.5 pointer low byte
LDY #>LAB_2A96 ; set 0.5 pointer high byte
; add (AY) to FAC1
LAB_246C
JSR LAB_264D ; unpack memory (AY) into FAC2
; add FAC2 to FAC1
LAB_ADD
BNE LAB_2474 ; branch if FAC1 was not zero
; copy FAC2 to FAC1
LAB_279B
LDA FAC2_s ; get FAC2 sign (b7)
; save FAC1 sign and copy ABS(FAC2) to FAC1
LAB_279D
STA FAC1_s ; save FAC1 sign (b7)
LDX #$04 ; 4 bytes to copy
LAB_27A1
LDA FAC1_o,X ; get byte from FAC2,X
STA FAC1_e-1,X ; save byte at FAC1,X
DEX ; decrement count
BNE LAB_27A1 ; loop if not all done
STX FAC1_r ; clear FAC1 rounding byte
RTS
; FAC1 is non zero
LAB_2474
LDX FAC1_r ; get FAC1 rounding byte
STX FAC2_r ; save as FAC2 rounding byte
LDX #FAC2_e ; set index to FAC2 exponent addr
LDA FAC2_e ; get FAC2 exponent
LAB_247C
TAY ; copy exponent
BEQ LAB_244D ; exit if zero
SEC ; set carry for subtract
SBC FAC1_e ; subtract FAC1 exponent
BEQ LAB_24A8 ; branch if = (go add mantissa)
BCC LAB_2498 ; branch if <
; FAC2>FAC1
STY FAC1_e ; save FAC1 exponent
LDY FAC2_s ; get FAC2 sign (b7)
STY FAC1_s ; save FAC1 sign (b7)
EOR #$FF ; complement A
ADC #$00 ; +1 (twos complement, carry is set)
LDY #$00 ; clear Y
STY FAC2_r ; clear FAC2 rounding byte
LDX #FAC1_e ; set index to FAC1 exponent addr
BNE LAB_249C ; branch always
LAB_2498
LDY #$00 ; clear Y
STY FAC1_r ; clear FAC1 rounding byte
LAB_249C
CMP #$F9 ; compare exponent diff with $F9
BMI LAB_2467 ; branch if range $79-$F8
TAY ; copy exponent difference to Y
LDA FAC1_r ; get FAC1 rounding byte
LSR PLUS_1,X ; shift FAC? mantissa1
JSR LAB_2592 ; shift FACX Y times right
; exponents are equal now do mantissa subtract
LAB_24A8
BIT FAC_sc ; test sign compare (FAC1 EOR FAC2)
BPL LAB_24F8 ; if = add FAC2 mantissa to FAC1 mantissa and return
LDY #FAC1_e ; set index to FAC1 exponent addr
CPX #FAC2_e ; compare X to FAC2 exponent addr
BEQ LAB_24B4 ; branch if =
LDY #FAC2_e ; else set index to FAC2 exponent addr
; subtract smaller from bigger (take sign of bigger)
LAB_24B4
SEC ; set carry for subtract
EOR #$FF ; ones complement A
ADC FAC2_r ; add FAC2 rounding byte
STA FAC1_r ; save FAC1 rounding byte
LDA PLUS_3,Y ; get FACY mantissa3
SBC PLUS_3,X ; subtract FACX mantissa3
STA FAC1_3 ; save FAC1 mantissa3
LDA PLUS_2,Y ; get FACY mantissa2
SBC PLUS_2,X ; subtract FACX mantissa2
STA FAC1_2 ; save FAC1 mantissa2
LDA PLUS_1,Y ; get FACY mantissa1
SBC PLUS_1,X ; subtract FACX mantissa1
STA FAC1_1 ; save FAC1 mantissa1
; do ABS and normalise FAC1
LAB_24D0
BCS LAB_24D5 ; branch if number is +ve
JSR LAB_2537 ; negate FAC1
; normalise FAC1
LAB_24D5
LDY #$00 ; clear Y
TYA ; clear A
CLC ; clear carry for add
LAB_24D9
LDX FAC1_1 ; get FAC1 mantissa1
BNE LAB_251B ; if not zero normalise FAC1
LDX FAC1_2 ; get FAC1 mantissa2
STX FAC1_1 ; save FAC1 mantissa1
LDX FAC1_3 ; get FAC1 mantissa3
STX FAC1_2 ; save FAC1 mantissa2
LDX FAC1_r ; get FAC1 rounding byte
STX FAC1_3 ; save FAC1 mantissa3
STY FAC1_r ; clear FAC1 rounding byte
ADC #$08 ; add x to exponent offset
CMP #$18 ; compare with $18 (max offset, all bits would be =0)
BNE LAB_24D9 ; loop if not max
; clear FAC1 exponent and sign
LAB_24F1
LDA #$00 ; clear A
LAB_24F3
STA FAC1_e ; set FAC1 exponent
; save FAC1 sign
LAB_24F5
STA FAC1_s ; save FAC1 sign (b7)
RTS
; add FAC2 mantissa to FAC1 mantissa
LAB_24F8
ADC FAC2_r ; add FAC2 rounding byte
STA FAC1_r ; save FAC1 rounding byte
LDA FAC1_3 ; get FAC1 mantissa3
ADC FAC2_3 ; add FAC2 mantissa3
STA FAC1_3 ; save FAC1 mantissa3
LDA FAC1_2 ; get FAC1 mantissa2
ADC FAC2_2 ; add FAC2 mantissa2
STA FAC1_2 ; save FAC1 mantissa2
LDA FAC1_1 ; get FAC1 mantissa1
ADC FAC2_1 ; add FAC2 mantissa1
STA FAC1_1 ; save FAC1 mantissa1
BCS LAB_252A ; if carry then normalise FAC1 for C=1
RTS ; else just exit
LAB_2511
ADC #$01 ; add 1 to exponent offset
ASL FAC1_r ; shift FAC1 rounding byte
ROL FAC1_3 ; shift FAC1 mantissa3
ROL FAC1_2 ; shift FAC1 mantissa2
ROL FAC1_1 ; shift FAC1 mantissa1
; normalise FAC1
LAB_251B
BPL LAB_2511 ; loop if not normalised
SEC ; set carry for subtract
SBC FAC1_e ; subtract FAC1 exponent
BCS LAB_24F1 ; branch if underflow (set result = $0)
EOR #$FF ; complement exponent
ADC #$01 ; +1 (twos complement)
STA FAC1_e ; save FAC1 exponent
; test and normalise FAC1 for C=0/1
LAB_2528
BCC LAB_2536 ; exit if no overflow
; normalise FAC1 for C=1
LAB_252A
INC FAC1_e ; increment FAC1 exponent
BEQ LAB_2564 ; if zero do overflow error and warm start
ROR FAC1_1 ; shift FAC1 mantissa1
ROR FAC1_2 ; shift FAC1 mantissa2
ROR FAC1_3 ; shift FAC1 mantissa3
ROR FAC1_r ; shift FAC1 rounding byte
LAB_2536
RTS
; negate FAC1
LAB_2537
LDA FAC1_s ; get FAC1 sign (b7)
EOR #$FF ; complement it
STA FAC1_s ; save FAC1 sign (b7)
; twos complement FAC1 mantissa
LAB_253D
LDA FAC1_1 ; get FAC1 mantissa1
EOR #$FF ; complement it
STA FAC1_1 ; save FAC1 mantissa1
LDA FAC1_2 ; get FAC1 mantissa2
EOR #$FF ; complement it
STA FAC1_2 ; save FAC1 mantissa2
LDA FAC1_3 ; get FAC1 mantissa3
EOR #$FF ; complement it
STA FAC1_3 ; save FAC1 mantissa3
LDA FAC1_r ; get FAC1 rounding byte
EOR #$FF ; complement it
STA FAC1_r ; save FAC1 rounding byte
INC FAC1_r ; increment FAC1 rounding byte
BNE LAB_2563 ; exit if no overflow
; increment FAC1 mantissa
LAB_2559
INC FAC1_3 ; increment FAC1 mantissa3
BNE LAB_2563 ; finished if no rollover
INC FAC1_2 ; increment FAC1 mantissa2
BNE LAB_2563 ; finished if no rollover
INC FAC1_1 ; increment FAC1 mantissa1
LAB_2563
RTS
; do overflow error (overflow exit)
LAB_2564
LDX #$0A ; error code $0A ("Overflow" error)
JMP LAB_XERR ; do error #X, then warm start
; shift FCAtemp << A+8 times
LAB_2569
LDX #FACt_1-1 ; set offset to FACtemp
LAB_256B
LDY PLUS_3,X ; get FACX mantissa3
STY FAC1_r ; save as FAC1 rounding byte
LDY PLUS_2,X ; get FACX mantissa2
STY PLUS_3,X ; save FACX mantissa3
LDY PLUS_1,X ; get FACX mantissa1
STY PLUS_2,X ; save FACX mantissa2
LDY FAC1_o ; get FAC1 overflow byte
STY PLUS_1,X ; save FACX mantissa1
; shift FACX -A times right (> 8 shifts)
LAB_257B
ADC #$08 ; add 8 to shift count
BMI LAB_256B ; go do 8 shift if still -ve
BEQ LAB_256B ; go do 8 shift if zero
SBC #$08 ; else subtract 8 again
TAY ; save count to Y
LDA FAC1_r ; get FAC1 rounding byte
BCS LAB_259A ;.
LAB_2588
ASL PLUS_1,X ; shift FACX mantissa1
BCC LAB_258E ; branch if +ve
INC PLUS_1,X ; this sets b7 eventually
LAB_258E
ROR PLUS_1,X ; shift FACX mantissa1 (correct for ASL)
ROR PLUS_1,X ; shift FACX mantissa1 (put carry in b7)
; shift FACX Y times right
LAB_2592
ROR PLUS_2,X ; shift FACX mantissa2
ROR PLUS_3,X ; shift FACX mantissa3
ROR ; shift FACX rounding byte
INY ; increment exponent diff
BNE LAB_2588 ; branch if range adjust not complete
LAB_259A
CLC ; just clear it
RTS
; perform LOG()
LAB_LOG
JSR LAB_27CA ; test sign and zero
BEQ LAB_25C4 ; if zero do function call error then warm start
BPL LAB_25C7 ; skip error if +ve
LAB_25C4
JMP LAB_FCER ; do function call error then warm start (-ve)
LAB_25C7
LDA FAC1_e ; get FAC1 exponent
SBC #$7F ; normalise it
PHA ; save it
LDA #$80 ; set exponent to zero
STA FAC1_e ; save FAC1 exponent
LDA #<LAB_25AD ; set 1/root2 pointer low byte
LDY #>LAB_25AD ; set 1/root2 pointer high byte
JSR LAB_246C ; add (AY) to FAC1 (1/root2)
LDA #<LAB_25B1 ; set root2 pointer low byte
LDY #>LAB_25B1 ; set root2 pointer high byte
JSR LAB_26CA ; convert AY and do (AY)/FAC1 (root2/(x+(1/root2)))
LDA #<LAB_259C ; set 1 pointer low byte
LDY #>LAB_259C ; set 1 pointer high byte
JSR LAB_2455 ; subtract (AY) from FAC1 ((root2/(x+(1/root2)))-1)
LDA #<LAB_25A0 ; set pointer low byte to counter
LDY #>LAB_25A0 ; set pointer high byte to counter
JSR LAB_2B6E ; ^2 then series evaluation
LDA #<LAB_25B5 ; set -0.5 pointer low byte
LDY #>LAB_25B5 ; set -0.5 pointer high byte
JSR LAB_246C ; add (AY) to FAC1
PLA ; restore FAC1 exponent
JSR LAB_2912 ; evaluate new ASCII digit
LDA #<LAB_25B9 ; set LOG(2) pointer low byte
LDY #>LAB_25B9 ; set LOG(2) pointer high byte
; do convert AY, FCA1*(AY)
LAB_25FB
JSR LAB_264D ; unpack memory (AY) into FAC2
LAB_MULTIPLY
BEQ LAB_264C ; exit if zero
JSR LAB_2673 ; test and adjust accumulators
LDA #$00 ; clear A
STA FACt_1 ; clear temp mantissa1
STA FACt_2 ; clear temp mantissa2
STA FACt_3 ; clear temp mantissa3
LDA FAC1_r ; get FAC1 rounding byte
JSR LAB_2622 ; go do shift/add FAC2
LDA FAC1_3 ; get FAC1 mantissa3
JSR LAB_2622 ; go do shift/add FAC2
LDA FAC1_2 ; get FAC1 mantissa2
JSR LAB_2622 ; go do shift/add FAC2
LDA FAC1_1 ; get FAC1 mantissa1
JSR LAB_2627 ; go do shift/add FAC2
JMP LAB_273C ; copy temp to FAC1, normalise and return
LAB_2622
BNE LAB_2627 ; branch if byte <> zero
; *** begin patch 2.22p5.6 floating point multiply rounding bug
; *** replace
; JMP LAB_2569 ; shift FCAtemp << A+8 times
;
; ; else do shift and add
;LAB_2627
; LSR ; shift byte
; ORA #$80 ; set top bit (mark for 8 times)
; *** with
SEC
JMP LAB_2569 ; shift FACtemp << A+8 times
; else do shift and add
LAB_2627
SEC ; set top bit (mark for 8 times)
ROR
; *** end patch 2.22p5.6 floating point multiply rounding bug
LAB_262A
TAY ; copy result
BCC LAB_2640 ; skip next if bit was zero
CLC ; clear carry for add
LDA FACt_3 ; get temp mantissa3
ADC FAC2_3 ; add FAC2 mantissa3
STA FACt_3 ; save temp mantissa3
LDA FACt_2 ; get temp mantissa2
ADC FAC2_2 ; add FAC2 mantissa2
STA FACt_2 ; save temp mantissa2
LDA FACt_1 ; get temp mantissa1
ADC FAC2_1 ; add FAC2 mantissa1
STA FACt_1 ; save temp mantissa1
LAB_2640
ROR FACt_1 ; shift temp mantissa1
ROR FACt_2 ; shift temp mantissa2
ROR FACt_3 ; shift temp mantissa3
ROR FAC1_r ; shift temp rounding byte
TYA ; get byte back
LSR ; shift byte
BNE LAB_262A ; loop if all bits not done
LAB_264C
RTS
; unpack memory (AY) into FAC2
LAB_264D
STA ut1_pl ; save pointer low byte
STY ut1_ph ; save pointer high byte
LDY #$03 ; 4 bytes to get (0-3)
LDA (ut1_pl),Y ; get mantissa3
STA FAC2_3 ; save FAC2 mantissa3
DEY ; decrement index
LDA (ut1_pl),Y ; get mantissa2
STA FAC2_2 ; save FAC2 mantissa2
DEY ; decrement index
LDA (ut1_pl),Y ; get mantissa1+sign
STA FAC2_s ; save FAC2 sign (b7)
EOR FAC1_s ; EOR with FAC1 sign (b7)
STA FAC_sc ; save sign compare (FAC1 EOR FAC2)
LDA FAC2_s ; recover FAC2 sign (b7)
ORA #$80 ; set 1xxx xxx (set normal bit)
STA FAC2_1 ; save FAC2 mantissa1
DEY ; decrement index
LDA (ut1_pl),Y ; get exponent byte
STA FAC2_e ; save FAC2 exponent
LDA FAC1_e ; get FAC1 exponent
RTS
; test and adjust accumulators
LAB_2673
LDA FAC2_e ; get FAC2 exponent
LAB_2675
BEQ LAB_2696 ; branch if FAC2 = $00 (handle underflow)
CLC ; clear carry for add
ADC FAC1_e ; add FAC1 exponent
BCC LAB_2680 ; branch if sum of exponents <$0100
BMI LAB_269B ; do overflow error
CLC ; clear carry for the add
.byte $2C ; makes next line BIT $1410
LAB_2680
BPL LAB_2696 ; if +ve go handle underflow
ADC #$80 ; adjust exponent
STA FAC1_e ; save FAC1 exponent
BNE LAB_268B ; branch if not zero
JMP LAB_24F5 ; save FAC1 sign and return
LAB_268B
LDA FAC_sc ; get sign compare (FAC1 EOR FAC2)
STA FAC1_s ; save FAC1 sign (b7)
LAB_268F
RTS
; handle overflow and underflow
LAB_2690
LDA FAC1_s ; get FAC1 sign (b7)
BPL LAB_269B ; do overflow error
; handle underflow
LAB_2696
PLA ; pop return address low byte
PLA ; pop return address high byte
JMP LAB_24F1 ; clear FAC1 exponent and sign and return
; multiply by 10
LAB_269E
JSR LAB_27AB ; round and copy FAC1 to FAC2
TAX ; copy exponent (set the flags)
BEQ LAB_268F ; exit if zero
CLC ; clear carry for add
ADC #$02 ; add two to exponent (*4)
BCS LAB_269B ; do overflow error if > $FF
LDX #$00 ; clear byte
STX FAC_sc ; clear sign compare (FAC1 EOR FAC2)
JSR LAB_247C ; add FAC2 to FAC1 (*5)
INC FAC1_e ; increment FAC1 exponent (*10)
BNE LAB_268F ; if non zero just do RTS
LAB_269B
JMP LAB_2564 ; do overflow error and warm start
; divide by 10
LAB_26B9
JSR LAB_27AB ; round and copy FAC1 to FAC2
LDA #<LAB_26B5 ; set pointer to 10d low addr
LDY #>LAB_26B5 ; set pointer to 10d high addr
LDX #$00 ; clear sign
; divide by (AY) (X=sign)
LAB_26C2
STX FAC_sc ; save sign compare (FAC1 EOR FAC2)
JSR LAB_UFAC ; unpack memory (AY) into FAC1
JMP LAB_DIVIDE ; do FAC2/FAC1
; Perform divide-by
; convert AY and do (AY)/FAC1
LAB_26CA
JSR LAB_264D ; unpack memory (AY) into FAC2
; Perform divide-into
LAB_DIVIDE
BEQ LAB_2737 ; if zero go do /0 error
JSR LAB_27BA ; round FAC1
LDA #$00 ; clear A
SEC ; set carry for subtract
SBC FAC1_e ; subtract FAC1 exponent (2s complement)
STA FAC1_e ; save FAC1 exponent
JSR LAB_2673 ; test and adjust accumulators
INC FAC1_e ; increment FAC1 exponent
BEQ LAB_269B ; if zero do overflow error
LDX #$FF ; set index for pre increment
LDA #$01 ; set bit to flag byte save
LAB_26E4
LDY FAC2_1 ; get FAC2 mantissa1
CPY FAC1_1 ; compare FAC1 mantissa1
BNE LAB_26F4 ; branch if <>
LDY FAC2_2 ; get FAC2 mantissa2
CPY FAC1_2 ; compare FAC1 mantissa2
BNE LAB_26F4 ; branch if <>
LDY FAC2_3 ; get FAC2 mantissa3
CPY FAC1_3 ; compare FAC1 mantissa3
LAB_26F4
PHP ; save FAC2-FAC1 compare status
ROL ; shift the result byte
BCC LAB_2702 ; if no carry skip the byte save
LDY #$01 ; set bit to flag byte save
INX ; else increment the index to FACt
CPX #$02 ; compare with the index to FACt_3
BMI LAB_2701 ; if not last byte just go save it
BNE LAB_272B ; if all done go save FAC1 rounding byte, normalise and
; return
LDY #$40 ; set bit to flag byte save for the rounding byte
LAB_2701
STA FACt_1,X ; write result byte to FACt_1 + index
TYA ; copy the next save byte flag
LAB_2702
PLP ; restore FAC2-FAC1 compare status
BCC LAB_2704 ; if FAC2 < FAC1 then skip the subtract
TAY ; save FAC2-FAC1 compare status
LDA FAC2_3 ; get FAC2 mantissa3
SBC FAC1_3 ; subtract FAC1 mantissa3
STA FAC2_3 ; save FAC2 mantissa3
LDA FAC2_2 ; get FAC2 mantissa2
SBC FAC1_2 ; subtract FAC1 mantissa2
STA FAC2_2 ; save FAC2 mantissa2
LDA FAC2_1 ; get FAC2 mantissa1
SBC FAC1_1 ; subtract FAC1 mantissa1
STA FAC2_1 ; save FAC2 mantissa1
TYA ; restore FAC2-FAC1 compare status
; FAC2 = FAC2*2
LAB_2704
ASL FAC2_3 ; shift FAC2 mantissa3
ROL FAC2_2 ; shift FAC2 mantissa2
ROL FAC2_1 ; shift FAC2 mantissa1
BCS LAB_26F4 ; loop with no compare
BMI LAB_26E4 ; loop with compare
BPL LAB_26F4 ; loop always with no compare
; do A<<6, save as FAC1 rounding byte, normalise and return
LAB_272B
LSR ; shift b1 - b0 ..
ROR ; ..
ROR ; .. to b7 - b6
STA FAC1_r ; save FAC1 rounding byte
PLP ; dump FAC2-FAC1 compare status
JMP LAB_273C ; copy temp to FAC1, normalise and return
; do "Divide by zero" error
LAB_2737
LDX #$14 ; error code $14 ("Divide by zero" error)
JMP LAB_XERR ; do error #X, then warm start
; copy temp to FAC1 and normalise
LAB_273C
LDA FACt_1 ; get temp mantissa1
STA FAC1_1 ; save FAC1 mantissa1
LDA FACt_2 ; get temp mantissa2
STA FAC1_2 ; save FAC1 mantissa2
LDA FACt_3 ; get temp mantissa3
STA FAC1_3 ; save FAC1 mantissa3
JMP LAB_24D5 ; normalise FAC1 and return
; unpack memory (AY) into FAC1
LAB_UFAC
STA ut1_pl ; save pointer low byte
STY ut1_ph ; save pointer high byte
LDY #$03 ; 4 bytes to do
LDA (ut1_pl),Y ; get last byte
STA FAC1_3 ; save FAC1 mantissa3
DEY ; decrement index
LDA (ut1_pl),Y ; get last-1 byte
STA FAC1_2 ; save FAC1 mantissa2
DEY ; decrement index
LDA (ut1_pl),Y ; get second byte
STA FAC1_s ; save FAC1 sign (b7)
ORA #$80 ; set 1xxx xxxx (add normal bit)
STA FAC1_1 ; save FAC1 mantissa1
DEY ; decrement index
LDA (ut1_pl),Y ; get first byte (exponent)
STA FAC1_e ; save FAC1 exponent
STY FAC1_r ; clear FAC1 rounding byte
RTS
; pack FAC1 into Adatal
LAB_276E
LDX #<Adatal ; set pointer low byte
LAB_2770
LDY #>Adatal ; set pointer high byte
BEQ LAB_2778 ; pack FAC1 into (XY) and return
; pack FAC1 into (Lvarpl)
LAB_PFAC
LDX Lvarpl ; get destination pointer low byte
LDY Lvarph ; get destination pointer high byte
; pack FAC1 into (XY)
LAB_2778
JSR LAB_27BA ; round FAC1
STX ut1_pl ; save pointer low byte
STY ut1_ph ; save pointer high byte
LDY #$03 ; set index
LDA FAC1_3 ; get FAC1 mantissa3
STA (ut1_pl),Y ; store in destination
DEY ; decrement index
LDA FAC1_2 ; get FAC1 mantissa2
STA (ut1_pl),Y ; store in destination
DEY ; decrement index
LDA FAC1_s ; get FAC1 sign (b7)
ORA #$7F ; set bits x111 1111
AND FAC1_1 ; AND in FAC1 mantissa1
STA (ut1_pl),Y ; store in destination
DEY ; decrement index
LDA FAC1_e ; get FAC1 exponent
STA (ut1_pl),Y ; store in destination
STY FAC1_r ; clear FAC1 rounding byte
RTS
; round and copy FAC1 to FAC2
LAB_27AB
JSR LAB_27BA ; round FAC1
; copy FAC1 to FAC2
LAB_27AE
LDX #$05 ; 5 bytes to copy
LAB_27B0
LDA FAC1_e-1,X ; get byte from FAC1,X
STA FAC1_o,X ; save byte at FAC2,X
DEX ; decrement count
BNE LAB_27B0 ; loop if not all done
STX FAC1_r ; clear FAC1 rounding byte
LAB_27B9
RTS
; round FAC1
LAB_27BA
LDA FAC1_e ; get FAC1 exponent
BEQ LAB_27B9 ; exit if zero
ASL FAC1_r ; shift FAC1 rounding byte
BCC LAB_27B9 ; exit if no overflow
; round FAC1 (no check)
LAB_27C2
JSR LAB_2559 ; increment FAC1 mantissa
BNE LAB_27B9 ; branch if no overflow
JMP LAB_252A ; normalise FAC1 for C=1 and return
; get FAC1 sign
; return A=FF,C=1/-ve A=01,C=0/+ve
LAB_27CA
LDA FAC1_e ; get FAC1 exponent
BEQ LAB_27D7 ; exit if zero (already correct SGN(0)=0)
; return A=FF,C=1/-ve A=01,C=0/+ve
; no = 0 check
LAB_27CE
LDA FAC1_s ; else get FAC1 sign (b7)
; return A=FF,C=1/-ve A=01,C=0/+ve
; no = 0 check, sign in A
LAB_27D0
ROL ; move sign bit to carry
LDA #$FF ; set byte for -ve result
BCS LAB_27D7 ; return if sign was set (-ve)
LDA #$01 ; else set byte for +ve result
LAB_27D7
RTS
; perform SGN()
LAB_SGN
JSR LAB_27CA ; get FAC1 sign
; return A=$FF/-ve A=$01/+ve
; save A as integer byte
LAB_27DB
STA FAC1_1 ; save FAC1 mantissa1
LDA #$00 ; clear A
STA FAC1_2 ; clear FAC1 mantissa2
LDX #$88 ; set exponent
; set exp=X, clearFAC1 mantissa3 and normalise
LAB_27E3
LDA FAC1_1 ; get FAC1 mantissa1
EOR #$FF ; complement it
ROL ; sign bit into carry
; set exp=X, clearFAC1 mantissa3 and normalise
LAB_STFA
LDA #$00 ; clear A
STA FAC1_3 ; clear FAC1 mantissa3
STX FAC1_e ; set FAC1 exponent
STA FAC1_r ; clear FAC1 rounding byte
STA FAC1_s ; clear FAC1 sign (b7)
JMP LAB_24D0 ; do ABS and normalise FAC1
; perform ABS()
LAB_ABS
LSR FAC1_s ; clear FAC1 sign (put zero in b7)
RTS
; compare FAC1 with (AY)
; returns A=$00 if FAC1 = (AY)
; returns A=$01 if FAC1 > (AY)
; returns A=$FF if FAC1 < (AY)
LAB_27F8
STA ut2_pl ; save pointer low byte
LAB_27FA
STY ut2_ph ; save pointer high byte
LDY #$00 ; clear index
LDA (ut2_pl),Y ; get exponent
INY ; increment index
TAX ; copy (AY) exponent to X
BEQ LAB_27CA ; branch if (AY) exponent=0 and get FAC1 sign
; A=FF,C=1/-ve A=01,C=0/+ve
LDA (ut2_pl),Y ; get (AY) mantissa1 (with sign)
EOR FAC1_s ; EOR FAC1 sign (b7)
BMI LAB_27CE ; if signs <> do return A=FF,C=1/-ve
; A=01,C=0/+ve and return
CPX FAC1_e ; compare (AY) exponent with FAC1 exponent
BNE LAB_2828 ; branch if different
LDA (ut2_pl),Y ; get (AY) mantissa1 (with sign)
ORA #$80 ; normalise top bit
CMP FAC1_1 ; compare with FAC1 mantissa1
BNE LAB_2828 ; branch if different
INY ; increment index
LDA (ut2_pl),Y ; get mantissa2
CMP FAC1_2 ; compare with FAC1 mantissa2
BNE LAB_2828 ; branch if different
INY ; increment index
LDA #$7F ; set for 1/2 value rounding byte
CMP FAC1_r ; compare with FAC1 rounding byte (set carry)
LDA (ut2_pl),Y ; get mantissa3
SBC FAC1_3 ; subtract FAC1 mantissa3
BEQ LAB_2850 ; exit if mantissa3 equal
; gets here if number <> FAC1
LAB_2828
LDA FAC1_s ; get FAC1 sign (b7)
BCC LAB_282E ; branch if FAC1 > (AY)
EOR #$FF ; else toggle FAC1 sign
LAB_282E
JMP LAB_27D0 ; return A=FF,C=1/-ve A=01,C=0/+ve
; convert FAC1 floating-to-fixed
LAB_2831
LDA FAC1_e ; get FAC1 exponent
BEQ LAB_287F ; if zero go clear FAC1 and return
SEC ; set carry for subtract
SBC #$98 ; subtract maximum integer range exponent
BIT FAC1_s ; test FAC1 sign (b7)
BPL LAB_2845 ; branch if FAC1 +ve
; FAC1 was -ve
TAX ; copy subtracted exponent
LDA #$FF ; overflow for -ve number
STA FAC1_o ; set FAC1 overflow byte
JSR LAB_253D ; twos complement FAC1 mantissa
TXA ; restore subtracted exponent
LAB_2845
LDX #FAC1_e ; set index to FAC1
CMP #$F9 ; compare exponent result
BPL LAB_2851 ; if < 8 shifts shift FAC1 A times right and return
JSR LAB_257B ; shift FAC1 A times right (> 8 shifts)
STY FAC1_o ; clear FAC1 overflow byte
LAB_2850
RTS
; shift FAC1 A times right
LAB_2851
TAY ; copy shift count
LDA FAC1_s ; get FAC1 sign (b7)
AND #$80 ; mask sign bit only (x000 0000)
LSR FAC1_1 ; shift FAC1 mantissa1
ORA FAC1_1 ; OR sign in b7 FAC1 mantissa1
STA FAC1_1 ; save FAC1 mantissa1
JSR LAB_2592 ; shift FAC1 Y times right
STY FAC1_o ; clear FAC1 overflow byte
RTS
; perform INT()
LAB_INT
LDA FAC1_e ; get FAC1 exponent
CMP #$98 ; compare with max int
BCS LAB_2886 ; exit if >= (already int, too big for fractional part!)
JSR LAB_2831 ; convert FAC1 floating-to-fixed
STY FAC1_r ; save FAC1 rounding byte
LDA FAC1_s ; get FAC1 sign (b7)
STY FAC1_s ; save FAC1 sign (b7)
EOR #$80 ; toggle FAC1 sign
ROL ; shift into carry
LDA #$98 ; set new exponent
STA FAC1_e ; save FAC1 exponent
LDA FAC1_3 ; get FAC1 mantissa3
STA Temp3 ; save for EXP() function
JMP LAB_24D0 ; do ABS and normalise FAC1
; clear FAC1 and return
LAB_287F
STA FAC1_1 ; clear FAC1 mantissa1
STA FAC1_2 ; clear FAC1 mantissa2
STA FAC1_3 ; clear FAC1 mantissa3
TAY ; clear Y
LAB_2886
RTS
; get FAC1 from string
; this routine now handles hex and binary values from strings
; starting with "$" and "%" respectively
LAB_2887
LDY #$00 ; clear Y
STY Dtypef ; clear data type flag, $FF=string, $00=numeric
LDX #$09 ; set index
LAB_288B
STY numexp,X ; clear byte
DEX ; decrement index
BPL LAB_288B ; loop until numexp to negnum (and FAC1) = $00
BCC LAB_28FE ; branch if 1st character numeric
; get FAC1 from string .. first character wasn't numeric
CMP #'-' ; else compare with "-"
BNE LAB_289A ; branch if not "-"
STX negnum ; set flag for -ve number (X = $FF)
BEQ LAB_289C ; branch always (go scan and check for hex/bin)
; get FAC1 from string .. first character wasn't numeric or -
LAB_289A
CMP #'+' ; else compare with "+"
BNE LAB_289D ; branch if not "+" (go check for hex/bin)
; was "+" or "-" to start, so get next character
LAB_289C
JSR LAB_IGBY ; increment and scan memory
BCC LAB_28FE ; branch if numeric character
; code here for hex and binary numbers
LAB_289D
CMP #'$' ; else compare with "$"
BNE LAB_NHEX ; branch if not "$"
JMP LAB_CHEX ; branch if "$"
LAB_NHEX
CMP #'%' ; else compare with "%"
BNE LAB_28A3 ; branch if not "%" (continue original code)
JMP LAB_CBIN ; branch if "%"
LAB_289E
JSR LAB_IGBY ; increment and scan memory (ignore + or get next number)
LAB_28A1
BCC LAB_28FE ; branch if numeric character
; get FAC1 from string .. character wasn't numeric, -, +, hex or binary
LAB_28A3
CMP #'.' ; else compare with "."
BEQ LAB_28D5 ; branch if "."
; get FAC1 from string .. character wasn't numeric, -, + or .
CMP #'E' ; else compare with "E"
BNE LAB_28DB ; branch if not "E"
; was "E" so evaluate exponential part
JSR LAB_IGBY ; increment and scan memory
BCC LAB_28C7 ; branch if numeric character
CMP #TK_MINUS ; else compare with token for -
BEQ LAB_28C2 ; branch if token for -
CMP #'-' ; else compare with "-"
BEQ LAB_28C2 ; branch if "-"
CMP #TK_PLUS ; else compare with token for +
BEQ LAB_28C4 ; branch if token for +
CMP #'+' ; else compare with "+"
BEQ LAB_28C4 ; branch if "+"
BNE LAB_28C9 ; branch always
LAB_28C2
ROR expneg ; set exponent -ve flag (C, which=1, into b7)
LAB_28C4
JSR LAB_IGBY ; increment and scan memory
LAB_28C7
BCC LAB_2925 ; branch if numeric character
LAB_28C9
BIT expneg ; test exponent -ve flag
BPL LAB_28DB ; if +ve go evaluate exponent
; else do exponent = -exponent
LDA #$00 ; clear result
SEC ; set carry for subtract
SBC expcnt ; subtract exponent byte
JMP LAB_28DD ; go evaluate exponent
LAB_28D5
ROR numdpf ; set decimal point flag
BIT numdpf ; test decimal point flag
BVC LAB_289E ; branch if only one decimal point so far
; evaluate exponent
LAB_28DB
LDA expcnt ; get exponent count byte
LAB_28DD
SEC ; set carry for subtract
SBC numexp ; subtract numerator exponent
STA expcnt ; save exponent count byte
BEQ LAB_28F6 ; branch if no adjustment
BPL LAB_28EF ; else if +ve go do FAC1*10^expcnt
; else go do FAC1/10^(0-expcnt)
LAB_28E6
JSR LAB_26B9 ; divide by 10
INC expcnt ; increment exponent count byte
BNE LAB_28E6 ; loop until all done
BEQ LAB_28F6 ; branch always
LAB_28EF
JSR LAB_269E ; multiply by 10
DEC expcnt ; decrement exponent count byte
BNE LAB_28EF ; loop until all done
LAB_28F6
LDA negnum ; get -ve flag
BMI LAB_28FB ; if -ve do - FAC1 and return
RTS
; do - FAC1 and return
LAB_28FB
JMP LAB_GTHAN ; do - FAC1 and return
; do unsigned FAC1*10+number
LAB_28FE
PHA ; save character
BIT numdpf ; test decimal point flag
BPL LAB_2905 ; skip exponent increment if not set
INC numexp ; else increment number exponent
LAB_2905
JSR LAB_269E ; multiply FAC1 by 10
PLA ; restore character
AND #$0F ; convert to binary
JSR LAB_2912 ; evaluate new ASCII digit
JMP LAB_289E ; go do next character
; evaluate new ASCII digit
LAB_2912
PHA ; save digit
JSR LAB_27AB ; round and copy FAC1 to FAC2
PLA ; restore digit
JSR LAB_27DB ; save A as integer byte
LDA FAC2_s ; get FAC2 sign (b7)
EOR FAC1_s ; toggle with FAC1 sign (b7)
STA FAC_sc ; save sign compare (FAC1 EOR FAC2)
LDX FAC1_e ; get FAC1 exponent
JMP LAB_ADD ; add FAC2 to FAC1 and return
; evaluate next character of exponential part of number
LAB_2925
LDA expcnt ; get exponent count byte
CMP #$0A ; compare with 10 decimal
BCC LAB_2934 ; branch if less
LDA #$64 ; make all -ve exponents = -100 decimal (causes underflow)
BIT expneg ; test exponent -ve flag
BMI LAB_2942 ; branch if -ve
JMP LAB_2564 ; else do overflow error
LAB_2934
ASL ; * 2
ASL ; * 4
ADC expcnt ; * 5
ASL ; * 10
LDY #$00 ; set index
ADC (Bpntrl),Y ; add character (will be $30 too much!)
SBC #'0'-1 ; convert character to binary
LAB_2942
STA expcnt ; save exponent count byte
JMP LAB_28C4 ; go get next character
; print " in line [LINE #]"
LAB_2953
LDA #<LAB_LMSG ; point to " in line " message low byte
LDY #>LAB_LMSG ; point to " in line " message high byte
JSR LAB_18C3 ; print null terminated string from memory
; print Basic line #
LDA Clineh ; get current line high byte
LDX Clinel ; get current line low byte
; print XA as unsigned integer
LAB_295E
STA FAC1_1 ; save low byte as FAC1 mantissa1
STX FAC1_2 ; save high byte as FAC1 mantissa2
LDX #$90 ; set exponent to 16d bits
SEC ; set integer is +ve flag
JSR LAB_STFA ; set exp=X, clearFAC1 mantissa3 and normalise
LDY #$00 ; clear index
TYA ; clear A
JSR LAB_297B ; convert FAC1 to string, skip sign character save
JMP LAB_18C3 ; print null terminated string from memory and return
; convert FAC1 to ASCII string result in (AY)
; not any more, moved scratchpad to page 0
LAB_296E
LDY #$01 ; set index = 1
LDA #$20 ; character = " " (assume +ve)
BIT FAC1_s ; test FAC1 sign (b7)
BPL LAB_2978 ; branch if +ve
LDA #$2D ; else character = "-"
LAB_2978
STA Decss,Y ; save leading character (" " or "-")
LAB_297B
STA FAC1_s ; clear FAC1 sign (b7)
STY Sendl ; save index
INY ; increment index
LDX FAC1_e ; get FAC1 exponent
BNE LAB_2989 ; branch if FAC1<>0
; exponent was $00 so FAC1 is 0
LDA #'0' ; set character = "0"
JMP LAB_2A89 ; save last character, [EOT] and exit
; FAC1 is some non zero value
LAB_2989
LDA #$00 ; clear (number exponent count)
CPX #$81 ; compare FAC1 exponent with $81 (>1.00000)
BCS LAB_299A ; branch if FAC1=>1
; FAC1<1
LDA #<LAB_294F ; set pointer low byte to 1,000,000
LDY #>LAB_294F ; set pointer high byte to 1,000,000
JSR LAB_25FB ; do convert AY, FCA1*(AY)
LDA #$FA ; set number exponent count (-6)
LAB_299A
STA numexp ; save number exponent count
LAB_299C
LDA #<LAB_294B ; set pointer low byte to 999999.4375 (max before sci note)
LDY #>LAB_294B ; set pointer high byte to 999999.4375
JSR LAB_27F8 ; compare FAC1 with (AY)
BEQ LAB_29C3 ; exit if FAC1 = (AY)
BPL LAB_29B9 ; go do /10 if FAC1 > (AY)
; FAC1 < (AY)
LAB_29A7
LDA #<LAB_2947 ; set pointer low byte to 99999.9375
LDY #>LAB_2947 ; set pointer high byte to 99999.9375
JSR LAB_27F8 ; compare FAC1 with (AY)
BEQ LAB_29B2 ; branch if FAC1 = (AY) (allow decimal places)
BPL LAB_29C0 ; branch if FAC1 > (AY) (no decimal places)
; FAC1 <= (AY)
LAB_29B2
JSR LAB_269E ; multiply by 10
DEC numexp ; decrement number exponent count
BNE LAB_29A7 ; go test again (branch always)
LAB_29B9
JSR LAB_26B9 ; divide by 10
INC numexp ; increment number exponent count
BNE LAB_299C ; go test again (branch always)
; now we have just the digits to do
LAB_29C0
JSR LAB_244E ; add 0.5 to FAC1 (round FAC1)
LAB_29C3
JSR LAB_2831 ; convert FAC1 floating-to-fixed
LDX #$01 ; set default digits before dp = 1
LDA numexp ; get number exponent count
CLC ; clear carry for add
ADC #$07 ; up to 6 digits before point
BMI LAB_29D8 ; if -ve then 1 digit before dp
CMP #$08 ; A>=8 if n>=1E6
BCS LAB_29D9 ; branch if >= $08
; carry is clear
ADC #$FF ; take 1 from digit count
TAX ; copy to A
LDA #$02 ;.set exponent adjust
LAB_29D8
SEC ; set carry for subtract
LAB_29D9
SBC #$02 ; -2
STA expcnt ;.save exponent adjust
STX numexp ; save digits before dp count
TXA ; copy to A
BEQ LAB_29E4 ; branch if no digits before dp
BPL LAB_29F7 ; branch if digits before dp
LAB_29E4
LDY Sendl ; get output string index
LDA #$2E ; character "."
INY ; increment index
STA Decss,Y ; save to output string
TXA ;.
BEQ LAB_29F5 ;.
LDA #'0' ; character "0"
INY ; increment index
STA Decss,Y ; save to output string
LAB_29F5
STY Sendl ; save output string index
LAB_29F7
LDY #$00 ; clear index (point to 100,000)
LDX #$80 ;
LAB_29FB
LDA FAC1_3 ; get FAC1 mantissa3
CLC ; clear carry for add
ADC LAB_2A9C,Y ; add -ve LSB
STA FAC1_3 ; save FAC1 mantissa3
LDA FAC1_2 ; get FAC1 mantissa2
ADC LAB_2A9B,Y ; add -ve NMSB
STA FAC1_2 ; save FAC1 mantissa2
LDA FAC1_1 ; get FAC1 mantissa1
ADC LAB_2A9A,Y ; add -ve MSB
STA FAC1_1 ; save FAC1 mantissa1
INX ;
BCS LAB_2A18 ;
BPL LAB_29FB ; not -ve so try again
BMI LAB_2A1A ;
LAB_2A18
BMI LAB_29FB ;
LAB_2A1A
TXA ;
BCC LAB_2A21 ;
EOR #$FF ;
ADC #$0A ;
LAB_2A21
ADC #'0'-1 ; add "0"-1 to result
INY ; increment index ..
INY ; .. to next less ..
INY ; .. power of ten
STY Cvaral ; save as current var address low byte
LDY Sendl ; get output string index
INY ; increment output string index
TAX ; copy character to X
AND #$7F ; mask out top bit
STA Decss,Y ; save to output string
DEC numexp ; decrement # of characters before the dp
BNE LAB_2A3B ; branch if still characters to do
; else output the point
LDA #$2E ; character "."
INY ; increment output string index
STA Decss,Y ; save to output string
LAB_2A3B
STY Sendl ; save output string index
LDY Cvaral ; get current var address low byte
TXA ; get character back
EOR #$FF ;
AND #$80 ;
TAX ;
CPY #$12 ; compare index with max
BNE LAB_29FB ; loop if not max
; now remove trailing zeroes
LDY Sendl ; get output string index
LAB_2A4B
LDA Decss,Y ; get character from output string
DEY ; decrement output string index
CMP #'0' ; compare with "0"
BEQ LAB_2A4B ; loop until non "0" character found
CMP #'.' ; compare with "."
BEQ LAB_2A58 ; branch if was dp
; restore last character
INY ; increment output string index
LAB_2A58
LDA #$2B ; character "+"
LDX expcnt ; get exponent count
BEQ LAB_2A8C ; if zero go set null terminator and exit
; exponent isn't zero so write exponent
BPL LAB_2A68 ; branch if exponent count +ve
LDA #$00 ; clear A
SEC ; set carry for subtract
SBC expcnt ; subtract exponent count adjust (convert -ve to +ve)
TAX ; copy exponent count to X
LDA #'-' ; character "-"
LAB_2A68
STA Decss+2,Y ; save to output string
LDA #$45 ; character "E"
STA Decss+1,Y ; save exponent sign to output string
TXA ; get exponent count back
LDX #'0'-1 ; one less than "0" character
SEC ; set carry for subtract
LAB_2A74
INX ; increment 10's character
SBC #$0A ;.subtract 10 from exponent count
BCS LAB_2A74 ; loop while still >= 0
ADC #':' ; add character ":" ($30+$0A, result is 10 less that value)
STA Decss+4,Y ; save to output string
TXA ; copy 10's character
STA Decss+3,Y ; save to output string
LDA #$00 ; set null terminator
STA Decss+5,Y ; save to output string
BEQ LAB_2A91 ; go set string pointer (AY) and exit (branch always)
; save last character, [EOT] and exit
LAB_2A89
STA Decss,Y ; save last character to output string
; set null terminator and exit
LAB_2A8C
LDA #$00 ; set null terminator
STA Decss+1,Y ; save after last character
; set string pointer (AY) and exit
LAB_2A91
LDA #<Decssp1 ; set result string low pointer
LDY #>Decssp1 ; set result string high pointer
RTS
; perform power function
LAB_POWER
BEQ LAB_EXP ; go do EXP()
LDA FAC2_e ; get FAC2 exponent
BNE LAB_2ABF ; branch if FAC2<>0
JMP LAB_24F3 ; clear FAC1 exponent and sign and return
LAB_2ABF
LDX #<func_l ; set destination pointer low byte
LDY #>func_l ; set destination pointer high byte
JSR LAB_2778 ; pack FAC1 into (XY)
LDA FAC2_s ; get FAC2 sign (b7)
BPL LAB_2AD9 ; branch if FAC2>0
; else FAC2 is -ve and can only be raised to an
; integer power which gives an x +j0 result
JSR LAB_INT ; perform INT
LDA #<func_l ; set source pointer low byte
LDY #>func_l ; set source pointer high byte
JSR LAB_27F8 ; compare FAC1 with (AY)
BNE LAB_2AD9 ; branch if FAC1 <> (AY) to allow Function Call error
; this will leave FAC1 -ve and cause a Function Call
; error when LOG() is called
TYA ; clear sign b7
LDY Temp3 ; save mantissa 3 from INT() function as sign in Y
; for possible later negation, b0
LAB_2AD9
JSR LAB_279D ; save FAC1 sign and copy ABS(FAC2) to FAC1
TYA ; copy sign back ..
PHA ; .. and save it
JSR LAB_LOG ; do LOG(n)
LDA #<garb_l ; set pointer low byte
LDY #>garb_l ; set pointer high byte
JSR LAB_25FB ; do convert AY, FCA1*(AY) (square the value)
JSR LAB_EXP ; go do EXP(n)
PLA ; pull sign from stack
LSR ; b0 is to be tested, shift to Cb
BCC LAB_2AF9 ; if no bit then exit
; Perform negation
; do - FAC1
LAB_GTHAN
LDA FAC1_e ; get FAC1 exponent
BEQ LAB_2AF9 ; exit if FAC1_e = $00
LDA FAC1_s ; get FAC1 sign (b7)
EOR #$FF ; complement it
STA FAC1_s ; save FAC1 sign (b7)
LAB_2AF9
RTS
; perform EXP() (x^e)
LAB_EXP
LDA #<LAB_2AFA ; set 1.443 pointer low byte
LDY #>LAB_2AFA ; set 1.443 pointer high byte
JSR LAB_25FB ; do convert AY, FCA1*(AY)
LDA FAC1_r ; get FAC1 rounding byte
ADC #$50 ; +$50/$100
BCC LAB_2B2B ; skip rounding if no carry
JSR LAB_27C2 ; round FAC1 (no check)
LAB_2B2B
STA FAC2_r ; save FAC2 rounding byte
JSR LAB_27AE ; copy FAC1 to FAC2
LDA FAC1_e ; get FAC1 exponent
CMP #$88 ; compare with EXP limit (256d)
BCC LAB_2B39 ; branch if less
LAB_2B36
JSR LAB_2690 ; handle overflow and underflow
LAB_2B39
JSR LAB_INT ; perform INT
LDA Temp3 ; get mantissa 3 from INT() function
CLC ; clear carry for add
ADC #$81 ; normalise +1
BEQ LAB_2B36 ; if $00 go handle overflow
SEC ; set carry for subtract
SBC #$01 ; now correct for exponent
PHA ; save FAC2 exponent
; swap FAC1 and FAC2
LDX #$04 ; 4 bytes to do
LAB_2B49
LDA FAC2_e,X ; get FAC2,X
LDY FAC1_e,X ; get FAC1,X
STA FAC1_e,X ; save FAC1,X
STY FAC2_e,X ; save FAC2,X
DEX ; decrement count/index
BPL LAB_2B49 ; loop if not all done
LDA FAC2_r ; get FAC2 rounding byte
STA FAC1_r ; save as FAC1 rounding byte
JSR LAB_SUBTRACT ; perform subtraction, FAC2 from FAC1
JSR LAB_GTHAN ; do - FAC1
LDA #<LAB_2AFE ; set counter pointer low byte
LDY #>LAB_2AFE ; set counter pointer high byte
JSR LAB_2B84 ; go do series evaluation
LDA #$00 ; clear A
STA FAC_sc ; clear sign compare (FAC1 EOR FAC2)
PLA ;.get saved FAC2 exponent
JMP LAB_2675 ; test and adjust accumulators and return
; ^2 then series evaluation
LAB_2B6E
STA Cptrl ; save count pointer low byte
STY Cptrh ; save count pointer high byte
JSR LAB_276E ; pack FAC1 into Adatal
LDA #<Adatal ; set pointer low byte (Y already $00)
JSR LAB_25FB ; do convert AY, FCA1*(AY)
JSR LAB_2B88 ; go do series evaluation
LDA #<Adatal ; pointer to original # low byte
LDY #>Adatal ; pointer to original # high byte
JMP LAB_25FB ; do convert AY, FCA1*(AY) and return
; series evaluation
LAB_2B84
STA Cptrl ; save count pointer low byte
STY Cptrh ; save count pointer high byte
LAB_2B88
LDX #<numexp ; set pointer low byte
JSR LAB_2770 ; set pointer high byte and pack FAC1 into numexp
LDA (Cptrl),Y ; get constants count
STA numcon ; save constants count
LDY Cptrl ; get count pointer low byte
INY ; increment it (now constants pointer)
TYA ; copy it
BNE LAB_2B97 ; skip next if no overflow
INC Cptrh ; else increment high byte
LAB_2B97
STA Cptrl ; save low byte
LDY Cptrh ; get high byte
LAB_2B9B
JSR LAB_25FB ; do convert AY, FCA1*(AY)
LDA Cptrl ; get constants pointer low byte
LDY Cptrh ; get constants pointer high byte
CLC ; clear carry for add
ADC #$04 ; +4 to low pointer (4 bytes per constant)
BCC LAB_2BA8 ; skip next if no overflow
INY ; increment high byte
LAB_2BA8
STA Cptrl ; save pointer low byte
STY Cptrh ; save pointer high byte
JSR LAB_246C ; add (AY) to FAC1
LDA #<numexp ; set pointer low byte to partial @ numexp
LDY #>numexp ; set pointer high byte to partial @ numexp
DEC numcon ; decrement constants count
BNE LAB_2B9B ; loop until all done
RTS
; RND(n), 32 bit Galoise version. make n=0 for 19th next number in sequence or n<>0
; to get 19th next number in sequence after seed n. This version of the PRNG uses
; the Galois method and a sample of 65536 bytes produced gives the following values.
; Entropy = 7.997442 bits per byte
; Optimum compression would reduce these 65536 bytes by 0 percent
; Chi square distribution for 65536 samples is 232.01, and
; randomly would exceed this value 75.00 percent of the time
; Arithmetic mean value of data bytes is 127.6724, 127.5 would be random
; Monte Carlo value for Pi is 3.122871269, error 0.60 percent
; Serial correlation coefficient is -0.000370, totally uncorrelated would be 0.0
LAB_RND
LDA FAC1_e ; get FAC1 exponent
BEQ NextPRN ; do next random # if zero
; else get seed into random number store
LDX #Rbyte4 ; set PRNG pointer low byte
LDY #$00 ; set PRNG pointer high byte
JSR LAB_2778 ; pack FAC1 into (XY)
NextPRN
LDX #$AF ; set EOR byte
LDY #$13 ; do this nineteen times
LoopPRN
ASL Rbyte1 ; shift PRNG most significant byte
ROL Rbyte2 ; shift PRNG middle byte
ROL Rbyte3 ; shift PRNG least significant byte
ROL Rbyte4 ; shift PRNG extra byte
BCC Ninc1 ; branch if bit 32 clear
TXA ; set EOR byte
EOR Rbyte1 ; EOR PRNG extra byte
STA Rbyte1 ; save new PRNG extra byte
Ninc1
DEY ; decrement loop count
BNE LoopPRN ; loop if not all done
LDX #$02 ; three bytes to copy
CopyPRNG
LDA Rbyte1,X ; get PRNG byte
STA FAC1_1,X ; save FAC1 byte
DEX
BPL CopyPRNG ; loop if not complete
LDA #$80 ; set the exponent
STA FAC1_e ; save FAC1 exponent
ASL ; clear A
STA FAC1_s ; save FAC1 sign
JMP LAB_24D5 ; normalise FAC1 and return
; perform COS()
LAB_COS
LDA #<LAB_2C78 ; set (pi/2) pointer low byte
LDY #>LAB_2C78 ; set (pi/2) pointer high byte
JSR LAB_246C ; add (AY) to FAC1
; perform SIN()
LAB_SIN
JSR LAB_27AB ; round and copy FAC1 to FAC2
LDA #<LAB_2C7C ; set (2*pi) pointer low byte
LDY #>LAB_2C7C ; set (2*pi) pointer high byte
LDX FAC2_s ; get FAC2 sign (b7)
JSR LAB_26C2 ; divide by (AY) (X=sign)
JSR LAB_27AB ; round and copy FAC1 to FAC2
JSR LAB_INT ; perform INT
LDA #$00 ; clear byte
STA FAC_sc ; clear sign compare (FAC1 EOR FAC2)
JSR LAB_SUBTRACT ; perform subtraction, FAC2 from FAC1
LDA #<LAB_2C80 ; set 0.25 pointer low byte
LDY #>LAB_2C80 ; set 0.25 pointer high byte
JSR LAB_2455 ; perform subtraction, (AY) from FAC1
LDA FAC1_s ; get FAC1 sign (b7)
PHA ; save FAC1 sign
BPL LAB_2C35 ; branch if +ve
; FAC1 sign was -ve
JSR LAB_244E ; add 0.5 to FAC1
LDA FAC1_s ; get FAC1 sign (b7)
BMI LAB_2C38 ; branch if -ve
LDA Cflag ; get comparison evaluation flag
EOR #$FF ; toggle flag
STA Cflag ; save comparison evaluation flag
LAB_2C35
JSR LAB_GTHAN ; do - FAC1
LAB_2C38
LDA #<LAB_2C80 ; set 0.25 pointer low byte
LDY #>LAB_2C80 ; set 0.25 pointer high byte
JSR LAB_246C ; add (AY) to FAC1
PLA ; restore FAC1 sign
BPL LAB_2C45 ; branch if was +ve
; else correct FAC1
JSR LAB_GTHAN ; do - FAC1
LAB_2C45
LDA #<LAB_2C84 ; set pointer low byte to counter
LDY #>LAB_2C84 ; set pointer high byte to counter
JMP LAB_2B6E ; ^2 then series evaluation and return
; perform TAN()
LAB_TAN
JSR LAB_276E ; pack FAC1 into Adatal
LDA #$00 ; clear byte
STA Cflag ; clear comparison evaluation flag
JSR LAB_SIN ; go do SIN(n)
LDX #<func_l ; set sin(n) pointer low byte
LDY #>func_l ; set sin(n) pointer high byte
JSR LAB_2778 ; pack FAC1 into (XY)
LDA #<Adatal ; set n pointer low addr
LDY #>Adatal ; set n pointer high addr
JSR LAB_UFAC ; unpack memory (AY) into FAC1
LDA #$00 ; clear byte
STA FAC1_s ; clear FAC1 sign (b7)
LDA Cflag ; get comparison evaluation flag
JSR LAB_2C74 ; save flag and go do series evaluation
LDA #<func_l ; set sin(n) pointer low byte
LDY #>func_l ; set sin(n) pointer high byte
JMP LAB_26CA ; convert AY and do (AY)/FAC1
LAB_2C74
PHA ; save comparison evaluation flag
JMP LAB_2C35 ; go do series evaluation
; perform USR()
LAB_USR
JSR Usrjmp ; call user code
JMP LAB_1BFB ; scan for ")", else do syntax error then warm start
; perform ATN()
LAB_ATN
LDA FAC1_s ; get FAC1 sign (b7)
PHA ; save sign
BPL LAB_2CA1 ; branch if +ve
JSR LAB_GTHAN ; else do - FAC1
LAB_2CA1
LDA FAC1_e ; get FAC1 exponent
PHA ; push exponent
CMP #$81 ; compare with 1
BCC LAB_2CAF ; branch if FAC1<1
LDA #<LAB_259C ; set 1 pointer low byte
LDY #>LAB_259C ; set 1 pointer high byte
JSR LAB_26CA ; convert AY and do (AY)/FAC1
LAB_2CAF
LDA #<LAB_2CC9 ; set pointer low byte to counter
LDY #>LAB_2CC9 ; set pointer high byte to counter
JSR LAB_2B6E ; ^2 then series evaluation
PLA ; restore old FAC1 exponent
CMP #$81 ; compare with 1
BCC LAB_2CC2 ; branch if FAC1<1
LDA #<LAB_2C78 ; set (pi/2) pointer low byte
LDY #>LAB_2C78 ; set (pi/2) pointer high byte
JSR LAB_2455 ; perform subtraction, (AY) from FAC1
LAB_2CC2
PLA ; restore FAC1 sign
BPL LAB_2D04 ; exit if was +ve
JMP LAB_GTHAN ; else do - FAC1 and return
; perform BITSET
LAB_BITSET
JSR LAB_GADB ; get two parameters for POKE or WAIT
CPX #$08 ; only 0 to 7 are allowed
BCS FCError ; branch if > 7
LDA #$00 ; clear A
SEC ; set the carry
S_Bits
ROL ; shift bit
DEX ; decrement bit number
BPL S_Bits ; loop if still +ve
INX ; make X = $00
ORA (Itempl,X) ; or with byte via temporary integer (addr)
STA (Itempl,X) ; save byte via temporary integer (addr)
LAB_2D04
RTS
; perform BITCLR
LAB_BITCLR
JSR LAB_GADB ; get two parameters for POKE or WAIT
CPX #$08 ; only 0 to 7 are allowed
BCS FCError ; branch if > 7
LDA #$FF ; set A
S_Bitc
ROL ; shift bit
DEX ; decrement bit number
BPL S_Bitc ; loop if still +ve
INX ; make X = $00
AND (Itempl,X) ; and with byte via temporary integer (addr)
STA (Itempl,X) ; save byte via temporary integer (addr)
RTS
FCError
JMP LAB_FCER ; do function call error then warm start
; perform BITTST()
LAB_BTST
JSR LAB_IGBY ; increment BASIC pointer
JSR LAB_GADB ; get two parameters for POKE or WAIT
CPX #$08 ; only 0 to 7 are allowed
BCS FCError ; branch if > 7
JSR LAB_GBYT ; get next BASIC byte
CMP #')' ; is next character ")"
BEQ TST_OK ; if ")" go do rest of function
JMP LAB_SNER ; do syntax error then warm start
TST_OK
JSR LAB_IGBY ; update BASIC execute pointer (to character past ")")
LDA #$00 ; clear A
SEC ; set the carry
T_Bits
ROL ; shift bit
DEX ; decrement bit number
BPL T_Bits ; loop if still +ve
INX ; make X = $00
AND (Itempl,X) ; AND with byte via temporary integer (addr)
BEQ LAB_NOTT ; branch if zero (already correct)
LDA #$FF ; set for -1 result
LAB_NOTT
JMP LAB_27DB ; go do SGN tail
; perform BIN$()
LAB_BINS
CPX #$19 ; max + 1
BCS BinFErr ; exit if too big ( > or = )
STX TempB ; save # of characters ($00 = leading zero remove)
LDA #$18 ; need A byte long space
JSR LAB_MSSP ; make string space A bytes long
LDY #$17 ; set index
LDX #$18 ; character count
NextB1
LSR nums_1 ; shift highest byte
ROR nums_2 ; shift middle byte
ROR nums_3 ; shift lowest byte bit 0 to carry
TXA ; load with "0"/2
ROL ; shift in carry
STA (str_pl),Y ; save to temp string + index
DEY ; decrement index
BPL NextB1 ; loop if not done
LDA TempB ; get # of characters
BEQ EndBHS ; branch if truncate
TAX ; copy length to X
SEC ; set carry for add !
EOR #$FF ; 1's complement
ADC #$18 ; add 24d
BEQ GoPr2 ; if zero print whole string
BNE GoPr1 ; else go make output string
; this is the exit code and is also used by HEX$()
; truncate string to remove leading "0"s
EndBHS
TAY ; clear index (A=0, X=length here)
NextB2
LDA (str_pl),Y ; get character from string
CMP #'0' ; compare with "0"
BNE GoPr ; if not "0" then go print string from here
DEX ; decrement character count
BEQ GoPr3 ; if zero then end of string so go print it
INY ; else increment index
BPL NextB2 ; loop always
; make fixed length output string - ignore overflows!
GoPr3
INX ; need at least 1 character
GoPr
TYA ; copy result
GoPr1
CLC ; clear carry for add
ADC str_pl ; add low address
STA str_pl ; save low address
LDA #$00 ; do high byte
ADC str_ph ; add high address
STA str_ph ; save high address
GoPr2
STX str_ln ; X holds string length
JSR LAB_IGBY ; update BASIC execute pointer (to character past ")")
JMP LAB_RTST ; check for space on descriptor stack then put address
; and length on descriptor stack and update stack pointers
BinFErr
JMP LAB_FCER ; do function call error then warm start
; perform HEX$()
LAB_HEXS
CPX #$07 ; max + 1
BCS BinFErr ; exit if too big ( > or = )
STX TempB ; save # of characters
LDA #$06 ; need 6 bytes for string
JSR LAB_MSSP ; make string space A bytes long
LDY #$05 ; set string index
; *** disable decimal mode patch - comment next line ***
; SED ; need decimal mode for nibble convert
LDA nums_3 ; get lowest byte
JSR LAB_A2HX ; convert A to ASCII hex byte and output
LDA nums_2 ; get middle byte
JSR LAB_A2HX ; convert A to ASCII hex byte and output
LDA nums_1 ; get highest byte
JSR LAB_A2HX ; convert A to ASCII hex byte and output
; *** disable decimal mode patch - comment next line ***
; CLD ; back to binary
LDX #$06 ; character count
LDA TempB ; get # of characters
BEQ EndBHS ; branch if truncate
TAX ; copy length to X
SEC ; set carry for add !
EOR #$FF ; 1's complement
ADC #$06 ; add 6d
BEQ GoPr2 ; if zero print whole string
BNE GoPr1 ; else go make output string (branch always)
; convert A to ASCII hex byte and output .. note set decimal mode before calling
LAB_A2HX
TAX ; save byte
AND #$0F ; mask off top bits
JSR LAB_AL2X ; convert low nibble to ASCII and output
TXA ; get byte back
LSR ; /2 shift high nibble to low nibble
LSR ; /4
LSR ; /8
LSR ; /16
LAB_AL2X
CMP #$0A ; set carry for +1 if >9
; *** begin disable decimal mode patch ***
; *** insert
BCC LAB_AL20 ; skip adjust if <= 9
ADC #$06 ; adjust for A to F
LAB_AL20
; *** end disable decimal mode patch ***
ADC #'0' ; add ASCII "0"
STA (str_pl),Y ; save to temp string
DEY ; decrement counter
RTS
LAB_NLTO
STA FAC1_e ; save FAC1 exponent
LDA #$00 ; clear sign compare
LAB_MLTE
STA FAC_sc ; save sign compare (FAC1 EOR FAC2)
TXA ; restore character
JSR LAB_2912 ; evaluate new ASCII digit
; gets here if the first character was "$" for hex
; get hex number
LAB_CHEX
JSR LAB_IGBY ; increment and scan memory
BCC LAB_ISHN ; branch if numeric character
ORA #$20 ; case convert, allow "A" to "F" and "a" to "f"
SBC #'a' ; subtract "a" (carry set here)
CMP #$06 ; compare normalised with $06 (max+1)
BCS LAB_EXCH ; exit if >"f" or <"0"
ADC #$0A ; convert to nibble
LAB_ISHN
AND #$0F ; convert to binary
TAX ; save nibble
LDA FAC1_e ; get FAC1 exponent
BEQ LAB_MLTE ; skip multiply if zero
ADC #$04 ; add four to exponent (*16 - carry clear here)
BCC LAB_NLTO ; if no overflow do evaluate digit
LAB_MLTO
JMP LAB_2564 ; do overflow error and warm start
LAB_NXCH
TAX ; save bit
LDA FAC1_e ; get FAC1 exponent
BEQ LAB_MLBT ; skip multiply if zero
INC FAC1_e ; increment FAC1 exponent (*2)
BEQ LAB_MLTO ; do overflow error if = $00
LDA #$00 ; clear sign compare
LAB_MLBT
STA FAC_sc ; save sign compare (FAC1 EOR FAC2)
TXA ; restore bit
JSR LAB_2912 ; evaluate new ASCII digit
; gets here if the first character was "%" for binary
; get binary number
LAB_CBIN
JSR LAB_IGBY ; increment and scan memory
EOR #'0' ; convert "0" to 0 etc.
CMP #$02 ; compare with max+1
BCC LAB_NXCH ; branch exit if < 2
LAB_EXCH
JMP LAB_28F6 ; evaluate -ve flag and return
; ctrl-c check routine. includes limited "life" byte save for INGET routine
; now also the code that checks to see if an interrupt has occurred
CTRLC
LDA ccflag ; get [CTRL-C] check flag
BNE LAB_FBA2 ; exit if inhibited
JSR V_INPT ; scan input device
BCC LAB_FBA0 ; exit if buffer empty
STA ccbyte ; save received byte
LDX #$20 ; "life" timer for bytes
STX ccnull ; set countdown
JMP LAB_1636 ; return to BASIC
LAB_FBA0
LDX ccnull ; get countdown byte
BEQ LAB_FBA2 ; exit if finished
DEC ccnull ; else decrement countdown
LAB_FBA2
LDX #NmiBase ; set pointer to NMI values
JSR LAB_CKIN ; go check interrupt
LDX #IrqBase ; set pointer to IRQ values
JSR LAB_CKIN ; go check interrupt
LAB_CRTS
RTS
; check whichever interrupt is indexed by X
LAB_CKIN
LDA PLUS_0,X ; get interrupt flag byte
BPL LAB_CRTS ; branch if interrupt not enabled
; we disable the interrupt here and make two new commands RETIRQ and RETNMI to
; automatically enable the interrupt when we exit
ASL ; move happened bit to setup bit
AND #$40 ; mask happened bits
BEQ LAB_CRTS ; if no interrupt then exit
STA PLUS_0,X ; save interrupt flag byte
TXA ; copy index ..
TAY ; .. to Y
PLA ; dump return address low byte, call from CTRL-C
PLA ; dump return address high byte
LDA #$05 ; need 5 bytes for GOSUB
JSR LAB_1212 ; check room on stack for A bytes
LDA Bpntrh ; get BASIC execute pointer high byte
PHA ; push on stack
LDA Bpntrl ; get BASIC execute pointer low byte
PHA ; push on stack
LDA Clineh ; get current line high byte
PHA ; push on stack
LDA Clinel ; get current line low byte
PHA ; push on stack
LDA #TK_GOSUB ; token for GOSUB
PHA ; push on stack
LDA PLUS_1,Y ; get interrupt code pointer low byte
STA Bpntrl ; save as BASIC execute pointer low byte
LDA PLUS_2,Y ; get interrupt code pointer high byte
STA Bpntrh ; save as BASIC execute pointer high byte
JMP LAB_15C2 ; go do interpreter inner loop
; can't RTS, we used the stack! the RTS from the ctrl-c
; check will be taken when the RETIRQ/RETNMI/RETURN is
; executed at the end of the subroutine
; get byte from input device, no waiting
; returns with carry set if byte in A
INGET
JSR V_INPT ; call scan input device
BCS LAB_FB95 ; if byte go reset timer
LDA ccnull ; get countdown
BEQ LAB_FB96 ; exit if empty
LDA ccbyte ; get last received byte
SEC ; flag we got a byte
LAB_FB95
LDX #$00 ; clear X
STX ccnull ; clear timer because we got a byte
LAB_FB96
RTS
; these routines only enable the interrupts if the set-up flag is set
; if not they have no effect
; perform IRQ {ON|OFF|CLEAR}
LAB_IRQ
LDX #IrqBase ; set pointer to IRQ values
.byte $2C ; make next line BIT abs.
; perform NMI {ON|OFF|CLEAR}
LAB_NMI
LDX #NmiBase ; set pointer to NMI values
CMP #TK_ON ; compare with token for ON
BEQ LAB_INON ; go turn on interrupt
CMP #TK_OFF ; compare with token for OFF
BEQ LAB_IOFF ; go turn off interrupt
EOR #TK_CLEAR ; compare with token for CLEAR, A = $00 if = TK_CLEAR
BEQ LAB_INEX ; go clear interrupt flags and return
JMP LAB_SNER ; do syntax error then warm start
LAB_IOFF
LDA #$7F ; clear A
AND PLUS_0,X ; AND with interrupt setup flag
BPL LAB_INEX ; go clear interrupt enabled flag and return
LAB_INON
LDA PLUS_0,X ; get interrupt setup flag
ASL ; Shift bit to enabled flag
ORA PLUS_0,X ; OR with flag byte
LAB_INEX
STA PLUS_0,X ; save interrupt flag byte
JMP LAB_IGBY ; update BASIC execute pointer and return
; these routines set up the pointers and flags for the interrupt routines
; note that the interrupts are also enabled by these commands
; perform ON IRQ
LAB_SIRQ
CLI ; enable interrupts
LDX #IrqBase ; set pointer to IRQ values
.byte $2C ; make next line BIT abs.
; perform ON NMI
LAB_SNMI
LDX #NmiBase ; set pointer to NMI values
STX TempB ; save interrupt pointer
JSR LAB_IGBY ; increment and scan memory (past token)
JSR LAB_GFPN ; get fixed-point number into temp integer
LDA Smeml ; get start of mem low byte
LDX Smemh ; get start of mem high byte
JSR LAB_SHLN ; search Basic for temp integer line number from AX
BCS LAB_LFND ; if carry set go set-up interrupt
JMP LAB_16F7 ; else go do "Undefined statement" error and warm start
LAB_LFND
LDX TempB ; get interrupt pointer
LDA Baslnl ; get pointer low byte
SBC #$01 ; -1 (carry already set for subtract)
STA PLUS_1,X ; save as interrupt pointer low byte
LDA Baslnh ; get pointer high byte
SBC #$00 ; subtract carry
STA PLUS_2,X ; save as interrupt pointer high byte
LDA #$C0 ; set interrupt enabled/setup bits
STA PLUS_0,X ; set interrupt flags
LAB_IRTS
RTS
; return from IRQ service, restores the enabled flag.
; perform RETIRQ
LAB_RETIRQ
BNE LAB_IRTS ; exit if following token (to allow syntax error)
LDA IrqBase ; get interrupt flags
ASL ; copy setup to enabled (b7)
ORA IrqBase ; OR in setup flag
STA IrqBase ; save enabled flag
JMP LAB_16E8 ; go do rest of RETURN
; return from NMI service, restores the enabled flag.
; perform RETNMI
LAB_RETNMI
BNE LAB_IRTS ; exit if following token (to allow syntax error)
LDA NmiBase ; get set-up flag
ASL ; copy setup to enabled (b7)
ORA NmiBase ; OR in setup flag
STA NmiBase ; save enabled flag
JMP LAB_16E8 ; go do rest of RETURN
; MAX() MIN() pre process
LAB_MMPP
JSR LAB_EVEZ ; process expression
JMP LAB_CTNM ; check if source is numeric, else do type mismatch
; perform MAX()
LAB_MAX
JSR LAB_PHFA ; push FAC1, evaluate expression,
; pull FAC2 and compare with FAC1
BPL LAB_MAX ; branch if no swap to do
LDA FAC2_1 ; get FAC2 mantissa1
ORA #$80 ; set top bit (clear sign from compare)
STA FAC2_1 ; save FAC2 mantissa1
JSR LAB_279B ; copy FAC2 to FAC1
BEQ LAB_MAX ; go do next (branch always)
; perform MIN()
LAB_MIN
JSR LAB_PHFA ; push FAC1, evaluate expression,
; pull FAC2 and compare with FAC1
BMI LAB_MIN ; branch if no swap to do
BEQ LAB_MIN ; branch if no swap to do
LDA FAC2_1 ; get FAC2 mantissa1
ORA #$80 ; set top bit (clear sign from compare)
STA FAC2_1 ; save FAC2 mantissa1
JSR LAB_279B ; copy FAC2 to FAC1
BEQ LAB_MIN ; go do next (branch always)
; exit routine. don't bother returning to the loop code
; check for correct exit, else so syntax error
LAB_MMEC
CMP #')' ; is it end of function?
BNE LAB_MMSE ; if not do MAX MIN syntax error
PLA ; dump return address low byte
PLA ; dump return address high byte
JMP LAB_IGBY ; update BASIC execute pointer (to chr past ")")
LAB_MMSE
JMP LAB_SNER ; do syntax error then warm start
; check for next, evaluate and return or exit
; this is the routine that does most of the work
LAB_PHFA
JSR LAB_GBYT ; get next BASIC byte
CMP #',' ; is there more ?
BNE LAB_MMEC ; if not go do end check
; push FAC1
JSR LAB_27BA ; round FAC1
LDA FAC1_s ; get FAC1 sign
ORA #$7F ; set all non sign bits
AND FAC1_1 ; AND FAC1 mantissa1 (AND in sign bit)
PHA ; push on stack
LDA FAC1_2 ; get FAC1 mantissa2
PHA ; push on stack
LDA FAC1_3 ; get FAC1 mantissa3
PHA ; push on stack
LDA FAC1_e ; get FAC1 exponent
PHA ; push on stack
JSR LAB_IGBY ; scan and get next BASIC byte (after ",")
JSR LAB_EVNM ; evaluate expression and check is numeric,
; else do type mismatch
; pop FAC2 (MAX/MIN expression so far)
PLA ; pop exponent
STA FAC2_e ; save FAC2 exponent
PLA ; pop mantissa3
STA FAC2_3 ; save FAC2 mantissa3
PLA ; pop mantissa1
STA FAC2_2 ; save FAC2 mantissa2
PLA ; pop sign/mantissa1
STA FAC2_1 ; save FAC2 sign/mantissa1
STA FAC2_s ; save FAC2 sign
; compare FAC1 with (packed) FAC2
LDA #<FAC2_e ; set pointer low byte to FAC2
LDY #>FAC2_e ; set pointer high byte to FAC2
JMP LAB_27F8 ; compare FAC1 with FAC2 (AY) and return
; returns A=$00 if FAC1 = (AY)
; returns A=$01 if FAC1 > (AY)
; returns A=$FF if FAC1 < (AY)
; perform WIDTH
LAB_WDTH
CMP #',' ; is next byte ","
BEQ LAB_TBSZ ; if so do tab size
JSR LAB_GTBY ; get byte parameter
TXA ; copy width to A
BEQ LAB_NSTT ; branch if set for infinite line
CPX #$10 ; else make min width = 16d
BCC TabErr ; if less do function call error and exit
; this next compare ensures that we can't exit WIDTH via an error leaving the
; tab size greater than the line length.
CPX TabSiz ; compare with tab size
BCS LAB_NSTT ; branch if >= tab size
STX TabSiz ; else make tab size = terminal width
LAB_NSTT
STX TWidth ; set the terminal width
JSR LAB_GBYT ; get BASIC byte back
BEQ WExit ; exit if no following
CMP #',' ; else is it ","
BNE LAB_MMSE ; if not do syntax error
LAB_TBSZ
JSR LAB_SGBY ; scan and get byte parameter
TXA ; copy TAB size
BMI TabErr ; if >127 do function call error and exit
CPX #$01 ; compare with min-1
BCC TabErr ; if <=1 do function call error and exit
LDA TWidth ; set flags for width
BEQ LAB_SVTB ; skip check if infinite line
CPX TWidth ; compare TAB with width
BEQ LAB_SVTB ; ok if =
BCS TabErr ; branch if too big
LAB_SVTB
STX TabSiz ; save TAB size
; calculate tab column limit from TAB size. The Iclim is set to the last tab
; position on a line that still has at least one whole tab width between it
; and the end of the line.
WExit
LDA TWidth ; get width
BEQ LAB_SULP ; branch if infinite line
CMP TabSiz ; compare with tab size
BCS LAB_WDLP ; branch if >= tab size
STA TabSiz ; else make tab size = terminal width
LAB_SULP
SEC ; set carry for subtract
LAB_WDLP
SBC TabSiz ; subtract tab size
BCS LAB_WDLP ; loop while no borrow
ADC TabSiz ; add tab size back
CLC ; clear carry for add
ADC TabSiz ; add tab size back again
STA Iclim ; save for now
LDA TWidth ; get width back
SEC ; set carry for subtract
SBC Iclim ; subtract remainder
STA Iclim ; save tab column limit
LAB_NOSQ
RTS
TabErr
JMP LAB_FCER ; do function call error then warm start
; perform SQR()
LAB_SQR
LDA FAC1_s ; get FAC1 sign
BMI TabErr ; if -ve do function call error
LDA FAC1_e ; get exponent
BEQ LAB_NOSQ ; if zero just return
; else do root
JSR LAB_27AB ; round and copy FAC1 to FAC2
LDA #$00 ; clear A
STA FACt_3 ; clear remainder
STA FACt_2 ; ..
STA FACt_1 ; ..
STA TempB ; ..
STA FAC1_3 ; clear root
STA FAC1_2 ; ..
STA FAC1_1 ; ..
LDX #$18 ; 24 pairs of bits to do
LDA FAC2_e ; get exponent
LSR ; check odd/even
BCS LAB_SQE2 ; if odd only 1 shift first time
LAB_SQE1
ASL FAC2_3 ; shift highest bit of number ..
ROL FAC2_2 ; ..
ROL FAC2_1 ; ..
ROL FACt_3 ; .. into remainder
ROL FACt_2 ; ..
ROL FACt_1 ; ..
ROL TempB ; .. never overflows
LAB_SQE2
ASL FAC2_3 ; shift highest bit of number ..
ROL FAC2_2 ; ..
ROL FAC2_1 ; ..
ROL FACt_3 ; .. into remainder
ROL FACt_2 ; ..
ROL FACt_1 ; ..
ROL TempB ; .. never overflows
ASL FAC1_3 ; root = root * 2
ROL FAC1_2 ; ..
ROL FAC1_1 ; .. never overflows
LDA FAC1_3 ; get root low byte
ROL ; *2
STA Temp3 ; save partial low byte
LDA FAC1_2 ; get root low mid byte
ROL ; *2
STA Temp3+1 ; save partial low mid byte
LDA FAC1_1 ; get root high mid byte
ROL ; *2
STA Temp3+2 ; save partial high mid byte
LDA #$00 ; get root high byte (always $00)
ROL ; *2
STA Temp3+3 ; save partial high byte
; carry clear for subtract +1
LDA FACt_3 ; get remainder low byte
SBC Temp3 ; subtract partial low byte
STA Temp3 ; save partial low byte
LDA FACt_2 ; get remainder low mid byte
SBC Temp3+1 ; subtract partial low mid byte
STA Temp3+1 ; save partial low mid byte
LDA FACt_1 ; get remainder high mid byte
SBC Temp3+2 ; subtract partial high mid byte
TAY ; copy partial high mid byte
LDA TempB ; get remainder high byte
SBC Temp3+3 ; subtract partial high byte
BCC LAB_SQNS ; skip sub if remainder smaller
STA TempB ; save remainder high byte
STY FACt_1 ; save remainder high mid byte
LDA Temp3+1 ; get remainder low mid byte
STA FACt_2 ; save remainder low mid byte
LDA Temp3 ; get partial low byte
STA FACt_3 ; save remainder low byte
INC FAC1_3 ; increment root low byte (never any rollover)
LAB_SQNS
DEX ; decrement bit pair count
BNE LAB_SQE1 ; loop if not all done
SEC ; set carry for subtract
LDA FAC2_e ; get exponent
SBC #$80 ; normalise
ROR ; /2 and re-bias to $80
ADC #$00 ; add bit zero back in (allow for half shift)
STA FAC1_e ; save it
JMP LAB_24D5 ; normalise FAC1 and return
; perform VARPTR()
LAB_VARPTR
JSR LAB_IGBY ; increment and scan memory
JSR LAB_GVAR ; get var address
JSR LAB_1BFB ; scan for ")" , else do syntax error then warm start
LDY Cvaral ; get var address low byte
LDA Cvarah ; get var address high byte
JMP LAB_AYFC ; save and convert integer AY to FAC1 and return
; perform PI
LAB_PI
LDA #<LAB_2C7C ; set (2*pi) pointer low byte
LDY #>LAB_2C7C ; set (2*pi) pointer high byte
JSR LAB_UFAC ; unpack memory (AY) into FAC1
DEC FAC1_e ; make result = PI
RTS
; perform TWOPI
LAB_TWOPI
LDA #<LAB_2C7C ; set (2*pi) pointer low byte
LDY #>LAB_2C7C ; set (2*pi) pointer high byte
JMP LAB_UFAC ; unpack memory (AY) into FAC1 and return
; system dependant i/o vectors
; these are in RAM and are set by the monitor at start-up
V_INPT
JMP (VEC_IN) ; non halting scan input device
V_OUTP
JMP (VEC_OUT) ; send byte to output device
V_LOAD
JMP (VEC_LD) ; load BASIC program
V_SAVE
JMP (VEC_SV) ; save BASIC program
; The rest are tables messages and code for RAM
; the rest of the code is tables and BASIC start-up code
PG2_TABS
.byte $00 ; ctrl-c flag - $00 = enabled
.byte $00 ; ctrl-c byte - GET needs this
.byte $00 ; ctrl-c byte timeout - GET needs this
.word CTRLC ; ctrl c check vector
; .word xxxx ; non halting key input - monitor to set this
; .word xxxx ; output vector - monitor to set this
; .word xxxx ; load vector - monitor to set this
; .word xxxx ; save vector - monitor to set this
PG2_TABE
; character get subroutine for zero page
; For a 1.8432MHz 6502 including the JSR and RTS
; fastest (>=":") = 29 cycles = 15.7uS
; slowest (<":") = 40 cycles = 21.7uS
; space skip = +21 cycles = +11.4uS
; inc across page = +4 cycles = +2.2uS
; the target address for the LDA at LAB_2CF4 becomes the BASIC execute pointer once the
; block is copied to it's destination, any non zero page address will do at assembly
; time, to assemble a three byte instruction.
; page 0 initialisation table from $BC
; increment and scan memory
LAB_2CEE
INC Bpntrl ; increment BASIC execute pointer low byte
BNE LAB_2CF4 ; branch if no carry
; else
INC Bpntrh ; increment BASIC execute pointer high byte
; page 0 initialisation table from $C2
; scan memory
LAB_2CF4
LDA $FFFF ; get byte to scan (addr set by call routine)
CMP #TK_ELSE ; compare with the token for ELSE
BEQ LAB_2D05 ; exit if ELSE, not numeric, carry set
CMP #':' ; compare with ":"
BCS LAB_2D05 ; exit if >= ":", not numeric, carry set
CMP #' ' ; compare with " "
BEQ LAB_2CEE ; if " " go do next
SEC ; set carry for SBC
SBC #'0' ; subtract "0"
SEC ; set carry for SBC
SBC #$D0 ; subtract -"0"
; clear carry if byte = "0"-"9"
LAB_2D05
RTS
; page zero initialisation table $00-$12 inclusive
StrTab
.byte $4C ; 0 JMP opcode
.word LAB_COLD ; 1 initial warm start vector (cold start)
.byte $00 ; 3 these bytes are not used by BASIC
.word $0000 ; 4
.word $0000 ; 6
.word $0000 ; 8
.byte $4C ; 10 JMP opcode
.word LAB_FCER ; 11 initial user function vector ("Function call" error)
.byte $00 ; 13 default NULL count
.byte $00 ; 14 clear terminal position
.byte $00 ; 15 default terminal width byte
.byte $F2 ; 16 default limit for TAB = 14
.word Ram_base ; 17 start of user RAM
EndTab
LAB_MSZM
.byte $0D,$0A,"Memory size ",$00
LAB_SMSG
.byte " Bytes free",$0D,$0A,$0A
.byte "Enhanced BASIC 2.22p5",$0A,$00
; numeric constants and series
; constants and series for LOG(n)
LAB_25A0
.byte $02 ; counter
.byte $80,$19,$56,$62 ; 0.59898
.byte $80,$76,$22,$F3 ; 0.96147
;## .byte $80,$76,$22,$F1 ; 0.96147
.byte $82,$38,$AA,$40 ; 2.88539
;## .byte $82,$38,$AA,$45 ; 2.88539
LAB_25AD
.byte $80,$35,$04,$F3 ; 0.70711 1/root 2
LAB_25B1
.byte $81,$35,$04,$F3 ; 1.41421 root 2
LAB_25B5
.byte $80,$80,$00,$00 ; -0.5
LAB_25B9
.byte $80,$31,$72,$18 ; 0.69315 LOG(2)
; numeric PRINT constants
LAB_2947
.byte $91,$43,$4F,$F8 ; 99999.9375 (max value with at least one decimal)
LAB_294B
.byte $94,$74,$23,$F7 ; 999999.4375 (max value before scientific notation)
LAB_294F
.byte $94,$74,$24,$00 ; 1000000
; EXP(n) constants and series
LAB_2AFA
.byte $81,$38,$AA,$3B ; 1.4427 (1/LOG base 2 e)
LAB_2AFE
.byte $06 ; counter
.byte $74,$63,$90,$8C ; 2.17023e-4
.byte $77,$23,$0C,$AB ; 0.00124
.byte $7A,$1E,$94,$00 ; 0.00968
.byte $7C,$63,$42,$80 ; 0.05548
.byte $7E,$75,$FE,$D0 ; 0.24023
.byte $80,$31,$72,$15 ; 0.69315
.byte $81,$00,$00,$00 ; 1.00000
;## .byte $07 ; counter
;## .byte $74,$94,$2E,$40 ; -1/7! (-1/5040)
;## .byte $77,$2E,$4F,$70 ; 1/6! ( 1/720)
;## .byte $7A,$88,$02,$6E ; -1/5! (-1/120)
;## .byte $7C,$2A,$A0,$E6 ; 1/4! ( 1/24)
;## .byte $7E,$AA,$AA,$50 ; -1/3! (-1/6)
;## .byte $7F,$7F,$FF,$FF ; 1/2! ( 1/2)
;## .byte $81,$80,$00,$00 ; -1/1! (-1/1)
;## .byte $81,$00,$00,$00 ; 1/0! ( 1/1)
; trigonometric constants and series
LAB_2C78
.byte $81,$49,$0F,$DB ; 1.570796371 (pi/2) as floating #
LAB_2C84
.byte $04 ; counter
.byte $86,$1E,$D7,$FB ; 39.7109
;## .byte $86,$1E,$D7,$BA ; 39.7109
.byte $87,$99,$26,$65 ;-76.575
;## .byte $87,$99,$26,$64 ;-76.575
.byte $87,$23,$34,$58 ; 81.6022
.byte $86,$A5,$5D,$E1 ;-41.3417
;## .byte $86,$A5,$5D,$E0 ;-41.3417
LAB_2C7C
.byte $83,$49,$0F,$DB ; 6.28319 (2*pi) as floating #
;## .byte $83,$49,$0F,$DA ; 6.28319 (2*pi) as floating #
LAB_2CC9
.byte $08 ; counter
.byte $78,$3A,$C5,$37 ; 0.00285
.byte $7B,$83,$A2,$5C ;-0.0160686
.byte $7C,$2E,$DD,$4D ; 0.0426915
.byte $7D,$99,$B0,$1E ;-0.0750429
.byte $7D,$59,$ED,$24 ; 0.106409
.byte $7E,$91,$72,$00 ;-0.142036
.byte $7E,$4C,$B9,$73 ; 0.199926
.byte $7F,$AA,$AA,$53 ;-0.333331
;## .byte $08 ; counter
;## .byte $78,$3B,$D7,$4A ; 1/17
;## .byte $7B,$84,$6E,$02 ;-1/15
;## .byte $7C,$2F,$C1,$FE ; 1/13
;## .byte $7D,$9A,$31,$74 ;-1/11
;## .byte $7D,$5A,$3D,$84 ; 1/9
;## .byte $7E,$91,$7F,$C8 ;-1/7
;## .byte $7E,$4C,$BB,$E4 ; 1/5
;## .byte $7F,$AA,$AA,$6C ;-1/3
LAB_1D96 = *+1 ; $00,$00 used for undefined variables
LAB_259C
.byte $81,$00,$00,$00 ; 1.000000, used for INC
LAB_2AFD
.byte $81,$80,$00,$00 ; -1.00000, used for DEC. must be on the same page as +1.00
; misc constants
LAB_1DF7
.byte $90 ;-32768 (uses first three bytes from 0.5)
LAB_2A96
.byte $80,$00,$00,$00 ; 0.5
LAB_2C80
.byte $7F,$00,$00,$00 ; 0.25
LAB_26B5
.byte $84,$20,$00,$00 ; 10.0000 divide by 10 constant
; This table is used in converting numbers to ASCII.
LAB_2A9A
LAB_2A9B = LAB_2A9A+1
LAB_2A9C = LAB_2A9B+1
.byte $FE,$79,$60 ; -100000
.byte $00,$27,$10 ; 10000
.byte $FF,$FC,$18 ; -1000
.byte $00,$00,$64 ; 100
.byte $FF,$FF,$F6 ; -10
.byte $00,$00,$01 ; 1
LAB_CTBL
.word LAB_END-1 ; END
.word LAB_FOR-1 ; FOR
.word LAB_NEXT-1 ; NEXT
.word LAB_DATA-1 ; DATA
.word LAB_INPUT-1 ; INPUT
.word LAB_DIM-1 ; DIM
.word LAB_READ-1 ; READ
.word LAB_LET-1 ; LET
.word LAB_DEC-1 ; DEC new command
.word LAB_GOTO-1 ; GOTO
.word LAB_RUN-1 ; RUN
.word LAB_IF-1 ; IF
.word LAB_RESTORE-1 ; RESTORE modified command
.word LAB_GOSUB-1 ; GOSUB
.word LAB_RETIRQ-1 ; RETIRQ new command
.word LAB_RETNMI-1 ; RETNMI new command
.word LAB_RETURN-1 ; RETURN
.word LAB_REM-1 ; REM
.word LAB_STOP-1 ; STOP
.word LAB_ON-1 ; ON modified command
.word LAB_NULL-1 ; NULL modified command
.word LAB_INC-1 ; INC new command
.word LAB_WAIT-1 ; WAIT
.word V_LOAD-1 ; LOAD
.word V_SAVE-1 ; SAVE
.word LAB_DEF-1 ; DEF
.word LAB_POKE-1 ; POKE
.word LAB_DOKE-1 ; DOKE new command
.word LAB_CALL-1 ; CALL new command
.word LAB_DO-1 ; DO new command
.word LAB_LOOP-1 ; LOOP new command
.word LAB_PRINT-1 ; PRINT
.word LAB_CONT-1 ; CONT
.word LAB_LIST-1 ; LIST
.word LAB_CLEAR-1 ; CLEAR
.word LAB_NEW-1 ; NEW
.word LAB_WDTH-1 ; WIDTH new command
.word LAB_GET-1 ; GET new command
.word LAB_SWAP-1 ; SWAP new command
.word LAB_BITSET-1 ; BITSET new command
.word LAB_BITCLR-1 ; BITCLR new command
.word retro_cls-1 ; CLS retro
.word retro_bye-1 ; BYE retro
.word retro_beep-1 ; BEEP retro
.word retro_dir-1 ; DIR retro
.word LAB_IRQ-1 ; IRQ new command
.word LAB_NMI-1 ; NMI new command
; function pre process routine table
LAB_FTPL
LAB_FTPM = LAB_FTPL+$01
.word LAB_PPFN-1 ; SGN(n) process numeric expression in ()
.word LAB_PPFN-1 ; INT(n) "
.word LAB_PPFN-1 ; ABS(n) "
.word LAB_EVEZ-1 ; USR(x) process any expression
.word LAB_1BF7-1 ; FRE(x) "
.word LAB_1BF7-1 ; POS(x) "
.word LAB_PPFN-1 ; SQR(n) process numeric expression in ()
.word LAB_PPFN-1 ; RND(n) "
.word LAB_PPFN-1 ; LOG(n) "
.word LAB_PPFN-1 ; EXP(n) "
.word LAB_PPFN-1 ; COS(n) "
.word LAB_PPFN-1 ; SIN(n) "
.word LAB_PPFN-1 ; TAN(n) "
.word LAB_PPFN-1 ; ATN(n) "
.word LAB_PPFN-1 ; PEEK(n) "
.word LAB_PPFN-1 ; DEEK(n) "
.word $0000 ; SADD() none
.word LAB_PPFS-1 ; LEN($) process string expression in ()
.word LAB_PPFN-1 ; STR$(n) process numeric expression in ()
.word LAB_PPFS-1 ; VAL($) process string expression in ()
.word LAB_PPFS-1 ; ASC($) "
.word LAB_PPFS-1 ; UCASE$($) "
.word LAB_PPFS-1 ; LCASE$($) "
.word LAB_PPFN-1 ; CHR$(n) process numeric expression in ()
.word LAB_BHSS-1 ; HEX$(n) "
.word LAB_BHSS-1 ; BIN$(n) "
.word $0000 ; BITTST() none
.word LAB_MMPP-1 ; MAX() process numeric expression
.word LAB_MMPP-1 ; MIN() "
.word LAB_PPBI-1 ; PI advance pointer
.word LAB_PPBI-1 ; TWOPI "
.word $0000 ; VARPTR() none
.word LAB_LRMS-1 ; LEFT$() process string expression
.word LAB_LRMS-1 ; RIGHT$() "
.word LAB_LRMS-1 ; MID$() "
; action addresses for functions
LAB_FTBL
LAB_FTBM = LAB_FTBL+$01
.word LAB_SGN-1 ; SGN()
.word LAB_INT-1 ; INT()
.word LAB_ABS-1 ; ABS()
.word LAB_USR-1 ; USR()
.word LAB_FRE-1 ; FRE()
.word LAB_POS-1 ; POS()
.word LAB_SQR-1 ; SQR()
.word LAB_RND-1 ; RND() modified function
.word LAB_LOG-1 ; LOG()
.word LAB_EXP-1 ; EXP()
.word LAB_COS-1 ; COS()
.word LAB_SIN-1 ; SIN()
.word LAB_TAN-1 ; TAN()
.word LAB_ATN-1 ; ATN()
.word LAB_PEEK-1 ; PEEK()
.word LAB_DEEK-1 ; DEEK() new function
.word LAB_SADD-1 ; SADD() new function
.word LAB_LENS-1 ; LEN()
.word LAB_STRS-1 ; STR$()
.word LAB_VAL-1 ; VAL()
.word LAB_ASC-1 ; ASC()
.word LAB_UCASE-1 ; UCASE$() new function
.word LAB_LCASE-1 ; LCASE$() new function
.word LAB_CHRS-1 ; CHR$()
.word LAB_HEXS-1 ; HEX$() new function
.word LAB_BINS-1 ; BIN$() new function
.word LAB_BTST-1 ; BITTST() new function
.word LAB_MAX-1 ; MAX() new function
.word LAB_MIN-1 ; MIN() new function
.word LAB_PI-1 ; PI new function
.word LAB_TWOPI-1 ; TWOPI new function
.word LAB_VARPTR-1 ; VARPTR() new function
.word LAB_LEFT-1 ; LEFT$()
.word LAB_RIGHT-1 ; RIGHT$()
.word LAB_MIDS-1 ; MID$()
; hierarchy and action addresses for operator
LAB_OPPT
.byte $79 ; +
.word LAB_ADD-1
.byte $79 ; -
.word LAB_SUBTRACT-1
.byte $7B ; *
.word LAB_MULTIPLY-1
.byte $7B ; /
.word LAB_DIVIDE-1
.byte $7F ; ^
.word LAB_POWER-1
.byte $50 ; AND
.word LAB_AND-1
.byte $46 ; EOR new operator
.word LAB_EOR-1
.byte $46 ; OR
.word LAB_OR-1
.byte $56 ; >> new operator
.word LAB_RSHIFT-1
.byte $56 ; << new operator
.word LAB_LSHIFT-1
.byte $7D ; >
.word LAB_GTHAN-1
.byte $5A ; =
.word LAB_EQUAL-1
.byte $64 ; <
.word LAB_LTHAN-1
; keywords start with ..
; this is the first character table and must be in alphabetic order
TAB_1STC
.byte "*"
.byte "+"
.byte "-"
.byte "/"
.byte "<"
.byte "="
.byte ">"
.byte "?"
.byte "A"
.byte "B"
.byte "C"
.byte "D"
.byte "E"
.byte "F"
.byte "G"
.byte "H"
.byte "I"
.byte "L"
.byte "M"
.byte "N"
.byte "O"
.byte "P"
.byte "R"
.byte "S"
.byte "T"
.byte "U"
.byte "V"
.byte "W"
.byte "^"
.byte $00 ; table terminator
; pointers to keyword tables
TAB_CHRT
.word TAB_STAR ; table for "*"
.word TAB_PLUS ; table for "+"
.word TAB_MNUS ; table for "-"
.word TAB_SLAS ; table for "/"
.word TAB_LESS ; table for "<"
.word TAB_EQUL ; table for "="
.word TAB_MORE ; table for ">"
.word TAB_QEST ; table for "?"
.word TAB_ASCA ; table for "A"
.word TAB_ASCB ; table for "B"
.word TAB_ASCC ; table for "C"
.word TAB_ASCD ; table for "D"
.word TAB_ASCE ; table for "E"
.word TAB_ASCF ; table for "F"
.word TAB_ASCG ; table for "G"
.word TAB_ASCH ; table for "H"
.word TAB_ASCI ; table for "I"
.word TAB_ASCL ; table for "L"
.word TAB_ASCM ; table for "M"
.word TAB_ASCN ; table for "N"
.word TAB_ASCO ; table for "O"
.word TAB_ASCP ; table for "P"
.word TAB_ASCR ; table for "R"
.word TAB_ASCS ; table for "S"
.word TAB_ASCT ; table for "T"
.word TAB_ASCU ; table for "U"
.word TAB_ASCV ; table for "V"
.word TAB_ASCW ; table for "W"
.word TAB_POWR ; table for "^"
; tables for each start character, note if a longer keyword with the same start
; letters as a shorter one exists then it must come first, else the list is in
; alphabetical order as follows ..
; [keyword,token
; [keyword,token]]
; end marker (#$00)
TAB_STAR
.byte TK_MUL,$00 ; *
TAB_PLUS
.byte TK_PLUS,$00 ; +
TAB_MNUS
.byte TK_MINUS,$00 ; -
TAB_SLAS
.byte TK_DIV,$00 ; /
TAB_LESS
LBB_LSHIFT
.byte "<",TK_LSHIFT ; << note - "<<" must come before "<"
.byte TK_LT ; <
.byte $00
TAB_EQUL
.byte TK_EQUAL,$00 ; =
TAB_MORE
LBB_RSHIFT
.byte ">",TK_RSHIFT ; >> note - ">>" must come before ">"
.byte TK_GT ; >
.byte $00
TAB_QEST
.byte TK_PRINT,$00 ; ?
TAB_ASCA
LBB_ABS
.byte "BS(",TK_ABS ; ABS(
LBB_AND
.byte "ND",TK_AND ; AND
LBB_ASC
.byte "SC(",TK_ASC ; ASC(
LBB_ATN
.byte "TN(",TK_ATN ; ATN(
.byte $00
TAB_ASCB
LBB_BEEP
.byte "EEP", TK_BEEP ; BEEP (retro)
LBB_BINS
.byte "IN$(",TK_BINS ; BIN$(
LBB_BITCLR
.byte "ITCLR",TK_BITCLR ; BITCLR
LBB_BITSET
.byte "ITSET",TK_BITSET ; BITSET
LBB_BITTST
.byte "ITTST(",TK_BITTST
LBB_BYE
.byte "YE", TK_BYE ; BYE (retro)
.byte $00
TAB_ASCC
LBB_CALL
.byte "ALL",TK_CALL ; CALL
LBB_CHRS
.byte "HR$(",TK_CHRS ; CHR$(
LBB_CLEAR
.byte "LEAR",TK_CLEAR ; CLEAR
LBB_CLS
.byte "LS", TK_CLS ; CLS (retro)
LBB_CONT
.byte "ONT",TK_CONT ; CONT
LBB_COS
.byte "OS(",TK_COS ; COS(
.byte $00
TAB_ASCD
LBB_DATA
.byte "ATA",TK_DATA ; DATA
LBB_DEC
.byte "EC",TK_DEC ; DEC
LBB_DEEK
.byte "EEK(",TK_DEEK ; DEEK(
LBB_DEF
.byte "EF",TK_DEF ; DEF
LBB_DIM
.byte "IM",TK_DIM ; DIM
LBB_DIR
.byte "IR",TK_DIR ; DIR - RETRO
LBB_DOKE
.byte "OKE",TK_DOKE ; DOKE note - "DOKE" must come before "DO"
LBB_DO
.byte "O",TK_DO ; DO
.byte $00
TAB_ASCE
LBB_ELSE
.byte "LSE",TK_ELSE ; ELSE
LBB_END
.byte "ND",TK_END ; END
LBB_EOR
.byte "OR",TK_EOR ; EOR
LBB_EXP
.byte "XP(",TK_EXP ; EXP(
.byte $00
TAB_ASCF
LBB_FN
.byte "N",TK_FN ; FN
LBB_FOR
.byte "OR",TK_FOR ; FOR
LBB_FRE
.byte "RE(",TK_FRE ; FRE(
.byte $00
TAB_ASCG
LBB_GET
.byte "ET",TK_GET ; GET
LBB_GOSUB
.byte "OSUB",TK_GOSUB ; GOSUB
LBB_GOTO
.byte "OTO",TK_GOTO ; GOTO
.byte $00
TAB_ASCH
LBB_HEXS
.byte "EX$(",TK_HEXS ; HEX$(
.byte $00
TAB_ASCI
LBB_IF
.byte "F",TK_IF ; IF
LBB_INC
.byte "NC",TK_INC ; INC
LBB_INPUT
.byte "NPUT",TK_INPUT ; INPUT
LBB_INT
.byte "NT(",TK_INT ; INT(
LBB_IRQ
.byte "RQ",TK_IRQ ; IRQ
.byte $00
TAB_ASCL
LBB_LCASES
.byte "CASE$(",TK_LCASES
; LCASE$(
LBB_LEFTS
.byte "EFT$(",TK_LEFTS ; LEFT$(
LBB_LEN
.byte "EN(",TK_LEN ; LEN(
LBB_LET
.byte "ET",TK_LET ; LET
LBB_LIST
.byte "IST",TK_LIST ; LIST
LBB_LOAD
.byte "OAD",TK_LOAD ; LOAD
LBB_LOG
.byte "OG(",TK_LOG ; LOG(
LBB_LOOP
.byte "OOP",TK_LOOP ; LOOP
.byte $00
TAB_ASCM
LBB_MAX
.byte "AX(",TK_MAX ; MAX(
LBB_MIDS
.byte "ID$(",TK_MIDS ; MID$(
LBB_MIN
.byte "IN(",TK_MIN ; MIN(
.byte $00
TAB_ASCN
LBB_NEW
.byte "EW",TK_NEW ; NEW
LBB_NEXT
.byte "EXT",TK_NEXT ; NEXT
LBB_NMI
.byte "MI",TK_NMI ; NMI
LBB_NOT
.byte "OT",TK_NOT ; NOT
LBB_NULL
.byte "ULL",TK_NULL ; NULL
.byte $00
TAB_ASCO
LBB_OFF
.byte "FF",TK_OFF ; OFF
LBB_ON
.byte "N",TK_ON ; ON
LBB_OR
.byte "R",TK_OR ; OR
.byte $00
TAB_ASCP
LBB_PEEK
.byte "EEK(",TK_PEEK ; PEEK(
LBB_PI
.byte "I",TK_PI ; PI
LBB_POKE
.byte "OKE",TK_POKE ; POKE
LBB_POS
.byte "OS(",TK_POS ; POS(
LBB_PRINT
.byte "RINT",TK_PRINT ; PRINT
.byte $00
TAB_ASCR
LBB_READ
.byte "EAD",TK_READ ; READ
LBB_REM
.byte "EM",TK_REM ; REM
LBB_RESTORE
.byte "ESTORE",TK_RESTORE
; RESTORE
LBB_RETIRQ
.byte "ETIRQ",TK_RETIRQ ; RETIRQ
LBB_RETNMI
.byte "ETNMI",TK_RETNMI ; RETNMI
LBB_RETURN
.byte "ETURN",TK_RETURN ; RETURN
LBB_RIGHTS
.byte "IGHT$(",TK_RIGHTS
; RIGHT$(
LBB_RND
.byte "ND(",TK_RND ; RND(
LBB_RUN
.byte "UN",TK_RUN ; RUN
.byte $00
TAB_ASCS
LBB_SADD
.byte "ADD(",TK_SADD ; SADD(
LBB_SAVE
.byte "AVE",TK_SAVE ; SAVE
LBB_SGN
.byte "GN(",TK_SGN ; SGN(
LBB_SIN
.byte "IN(",TK_SIN ; SIN(
LBB_SPC
.byte "PC(",TK_SPC ; SPC(
LBB_SQR
.byte "QR(",TK_SQR ; SQR(
LBB_STEP
.byte "TEP",TK_STEP ; STEP
LBB_STOP
.byte "TOP",TK_STOP ; STOP
LBB_STRS
.byte "TR$(",TK_STRS ; STR$(
LBB_SWAP
.byte "WAP",TK_SWAP ; SWAP
.byte $00
TAB_ASCT
LBB_TAB
.byte "AB(",TK_TAB ; TAB(
LBB_TAN
.byte "AN(",TK_TAN ; TAN(
LBB_THEN
.byte "HEN",TK_THEN ; THEN
LBB_TO
.byte "O",TK_TO ; TO
LBB_TWOPI
.byte "WOPI",TK_TWOPI ; TWOPI
.byte $00
TAB_ASCU
LBB_UCASES
.byte "CASE$(",TK_UCASES
; UCASE$(
LBB_UNTIL
.byte "NTIL",TK_UNTIL ; UNTIL
LBB_USR
.byte "SR(",TK_USR ; USR(
.byte $00
TAB_ASCV
LBB_VAL
.byte "AL(",TK_VAL ; VAL(
LBB_VPTR
.byte "ARPTR(",TK_VPTR ; VARPTR(
.byte $00
TAB_ASCW
LBB_WAIT
.byte "AIT",TK_WAIT ; WAIT
LBB_WHILE
.byte "HILE",TK_WHILE ; WHILE
LBB_WIDTH
.byte "IDTH",TK_WIDTH ; WIDTH
.byte $00
TAB_POWR
.byte TK_POWER,$00 ; ^
; new decode table for LIST
; Table is ..
; byte - keyword length, keyword first character
; word - pointer to rest of keyword from dictionary
; note if length is 1 then the pointer is ignored
LAB_KEYT
.byte 3,'E'
.word LBB_END ; END
.byte 3,'F'
.word LBB_FOR ; FOR
.byte 4,'N'
.word LBB_NEXT ; NEXT
.byte 4,'D'
.word LBB_DATA ; DATA
.byte 5,'I'
.word LBB_INPUT ; INPUT
.byte 3,'D'
.word LBB_DIM ; DIM
.byte 4,'R'
.word LBB_READ ; READ
.byte 3,'L'
.word LBB_LET ; LET
.byte 3,'D'
.word LBB_DEC ; DEC
.byte 4,'G'
.word LBB_GOTO ; GOTO
.byte 3,'R'
.word LBB_RUN ; RUN
.byte 2,'I'
.word LBB_IF ; IF
.byte 7,'R'
.word LBB_RESTORE ; RESTORE
.byte 5,'G'
.word LBB_GOSUB ; GOSUB
.byte 6,'R'
.word LBB_RETIRQ ; RETIRQ
.byte 6,'R'
.word LBB_RETNMI ; RETNMI
.byte 6,'R'
.word LBB_RETURN ; RETURN
.byte 3,'R'
.word LBB_REM ; REM
.byte 4,'S'
.word LBB_STOP ; STOP
.byte 2,'O'
.word LBB_ON ; ON
.byte 4,'N'
.word LBB_NULL ; NULL
.byte 3,'I'
.word LBB_INC ; INC
.byte 4,'W'
.word LBB_WAIT ; WAIT
.byte 4,'L'
.word LBB_LOAD ; LOAD
.byte 4,'S'
.word LBB_SAVE ; SAVE
.byte 3,'D'
.word LBB_DEF ; DEF
.byte 4,'P'
.word LBB_POKE ; POKE
.byte 4,'D'
.word LBB_DOKE ; DOKE
.byte 4,'C'
.word LBB_CALL ; CALL
.byte 2,'D'
.word LBB_DO ; DO
.byte 4,'L'
.word LBB_LOOP ; LOOP
.byte 5,'P'
.word LBB_PRINT ; PRINT
.byte 4,'C'
.word LBB_CONT ; CONT
.byte 4,'L'
.word LBB_LIST ; LIST
.byte 5,'C'
.word LBB_CLEAR ; CLEAR
.byte 3,'N'
.word LBB_NEW ; NEW
.byte 5,'W'
.word LBB_WIDTH ; WIDTH
.byte 3,'G'
.word LBB_GET ; GET
.byte 4,'S'
.word LBB_SWAP ; SWAP
.byte 6,'B'
.word LBB_BITSET ; BITSET
.byte 6,'B'
.word LBB_BITCLR ; BITCLR
.byte 3, 'C'
.word LBB_CLS ; CLS (retro)
.byte 3, 'B'
.word LBB_BYE ; BYE (retro)
.byte 4, 'B'
.word LBB_BEEP ; BEEP (retro)
.byte 3, 'D'
.word LBB_DIR ; DIR (retro)
.byte 3,'I'
.word LBB_IRQ ; IRQ
.byte 3,'N'
.word LBB_NMI ; NMI
; secondary commands (can't start a statement)
.byte 4,'T'
.word LBB_TAB ; TAB
.byte 4,'E'
.word LBB_ELSE ; ELSE
.byte 2,'T'
.word LBB_TO ; TO
.byte 2,'F'
.word LBB_FN ; FN
.byte 4,'S'
.word LBB_SPC ; SPC
.byte 4,'T'
.word LBB_THEN ; THEN
.byte 3,'N'
.word LBB_NOT ; NOT
.byte 4,'S'
.word LBB_STEP ; STEP
.byte 5,'U'
.word LBB_UNTIL ; UNTIL
.byte 5,'W'
.word LBB_WHILE ; WHILE
.byte 3,'O'
.word LBB_OFF ; OFF
; opperators
.byte 1,'+'
.word $0000 ; +
.byte 1,'-'
.word $0000 ; -
.byte 1,'*'
.word $0000 ; *
.byte 1,'/'
.word $0000 ; /
.byte 1,'^'
.word $0000 ; ^
.byte 3,'A'
.word LBB_AND ; AND
.byte 3,'E'
.word LBB_EOR ; EOR
.byte 2,'O'
.word LBB_OR ; OR
.byte 2,'>'
.word LBB_RSHIFT ; >>
.byte 2,'<'
.word LBB_LSHIFT ; <<
.byte 1,'>'
.word $0000 ; >
.byte 1,'='
.word $0000 ; =
.byte 1,'<'
.word $0000 ; <
; functions
.byte 4,'S' ;
.word LBB_SGN ; SGN
.byte 4,'I' ;
.word LBB_INT ; INT
.byte 4,'A' ;
.word LBB_ABS ; ABS
.byte 4,'U' ;
.word LBB_USR ; USR
.byte 4,'F' ;
.word LBB_FRE ; FRE
.byte 4,'P' ;
.word LBB_POS ; POS
.byte 4,'S' ;
.word LBB_SQR ; SQR
.byte 4,'R' ;
.word LBB_RND ; RND
.byte 4,'L' ;
.word LBB_LOG ; LOG
.byte 4,'E' ;
.word LBB_EXP ; EXP
.byte 4,'C' ;
.word LBB_COS ; COS
.byte 4,'S' ;
.word LBB_SIN ; SIN
.byte 4,'T' ;
.word LBB_TAN ; TAN
.byte 4,'A' ;
.word LBB_ATN ; ATN
.byte 5,'P' ;
.word LBB_PEEK ; PEEK
.byte 5,'D' ;
.word LBB_DEEK ; DEEK
.byte 5,'S' ;
.word LBB_SADD ; SADD
.byte 4,'L' ;
.word LBB_LEN ; LEN
.byte 5,'S' ;
.word LBB_STRS ; STR$
.byte 4,'V' ;
.word LBB_VAL ; VAL
.byte 4,'A' ;
.word LBB_ASC ; ASC
.byte 7,'U' ;
.word LBB_UCASES ; UCASE$
.byte 7,'L' ;
.word LBB_LCASES ; LCASE$
.byte 5,'C' ;
.word LBB_CHRS ; CHR$
.byte 5,'H' ;
.word LBB_HEXS ; HEX$
.byte 5,'B' ;
.word LBB_BINS ; BIN$
.byte 7,'B' ;
.word LBB_BITTST ; BITTST
.byte 4,'M' ;
.word LBB_MAX ; MAX
.byte 4,'M' ;
.word LBB_MIN ; MIN
.byte 2,'P' ;
.word LBB_PI ; PI
.byte 5,'T' ;
.word LBB_TWOPI ; TWOPI
.byte 7,'V' ;
.word LBB_VPTR ; VARPTR
.byte 6,'L' ;
.word LBB_LEFTS ; LEFT$
.byte 7,'R' ;
.word LBB_RIGHTS ; RIGHT$
.byte 5,'M' ;
.word LBB_MIDS ; MID$
; BASIC messages, mostly error messages
LAB_BAER
.word ERR_NF ;$00 NEXT without FOR
.word ERR_SN ;$02 syntax
.word ERR_RG ;$04 RETURN without GOSUB
.word ERR_OD ;$06 out of data
.word ERR_FC ;$08 function call
.word ERR_OV ;$0A overflow
.word ERR_OM ;$0C out of memory
.word ERR_US ;$0E undefined statement
.word ERR_BS ;$10 array bounds
.word ERR_DD ;$12 double dimension array
.word ERR_D0 ;$14 divide by 0
.word ERR_ID ;$16 illegal direct
.word ERR_TM ;$18 type mismatch
.word ERR_LS ;$1A long string
.word ERR_ST ;$1C string too complex
.word ERR_CN ;$1E continue error
.word ERR_UF ;$20 undefined function
.word ERR_LD ;$22 LOOP without DO
.word ERR_DS ;$24 DISK ERROR
.word ERR_OP ;$26 OPEN ERROR
.word ERR_CL ;$28 CLOSE ERROR
.word ERR_RD ;$2A READ ERROR
.word ERR_WR ;$2C WRITE ERROR
;
; I may implement these two errors to force definition of variables and
; dimensioning of arrays before use.
; .word ERR_UV ;$24 undefined variable
; the above error has been tested and works (see code and comments below LAB_1D8B)
; .word ERR_UA ;$26 undimensioned array
ERR_NF .byte "NEXT without FOR",$00
ERR_SN .byte "Syntax",$00
ERR_RG .byte "RETURN without GOSUB",$00
ERR_OD .byte "Out of DATA",$00
ERR_FC .byte "Function call",$00
ERR_OV .byte "Overflow",$00
ERR_OM .byte "Out of memory",$00
ERR_US .byte "Undefined statement",$00
ERR_BS .byte "Array bounds",$00
ERR_DD .byte "Double dimension",$00
ERR_D0 .byte "Divide by zero",$00
ERR_ID .byte "Illegal direct",$00
ERR_TM .byte "Type mismatch",$00
ERR_LS .byte "String too long",$00
ERR_ST .byte "String too complex",$00
ERR_CN .byte "Can't continue",$00
ERR_UF .byte "Undefined function",$00
ERR_LD .byte "LOOP without DO",$00
ERR_DS .byte "Disk error",$00
ERR_OP .byte "Open file error",$00
ERR_CL .byte "Close file error",$00
ERR_RD .byte "Disk read error",$00
ERR_WR .byte "Disk write error",$00
;ERR_UV .byte "Undefined variable",$00
; the above error has been tested and works (see code and comments below LAB_1D8B)
;ERR_UA .byte "Undimensioned array",$00
LAB_BMSG .byte $0D,$0A,"Break",$00
LAB_EMSG .byte " Error",$00
LAB_LMSG .byte " in line ",$00
LAB_RMSG .byte $0D,$0A,"Ready",$0D,$0A,$00
LAB_IMSG .byte " Extra ignored",$0D,$0A,$00
LAB_REDO .byte " Redo from start",$0D,$0A,$00
AA_end_basic
|
6502-retro/6502-retro-os
| 2,899
|
apps/ehbasic/min_mon.s
|
; vim: ft=asm_ca65
;
; minimal monitor for EhBASIC and 6502 simulator V1.05
; tabs converted to space, tabwidth=6
; To run EhBASIC on the simulator load and assemble [F7] this file, start the simulator
; running [F6] then start the code with the RESET [CTRL][SHIFT]R. Just selecting RUN
; will do nothing, you'll still have to do a reset to run the code.
.include "../../inc/fcb.inc"
.include "../../inc/errors.inc"
.include "basic.s"
;
;
; put the IRQ and MNI code in RAM so that it can be changed
IRQ_vec = VEC_SV+2 ; IRQ code vector
NMI_vec = IRQ_vec+$0A ; NMI code vector
; now the code. all this does is set up the vectors and interrupt code
; and wait for the user to select [C]old or [W]arm start. nothing else
; fits in less than 128 bytes
.code
; reset vector points here
RES_vec
; set up vectors and interrupt code, copy them to page 2
LDY #END_CODE-LAB_vec ; set index/count
LAB_stlp
LDA LAB_vec-1,Y ; get byte from interrupt code
STA VEC_IN-1,Y ; save to RAM
DEY ; decrement index/count
BNE LAB_stlp ; loop if more to do
; now do the signon message, Y = $00 here
LAB_signon
LDA LAB_mess,Y ; get byte from sign on message
BEQ :+ ; exit loop if done
JSR V_OUTP ; output character
INY ; increment index
BNE LAB_signon ; loop, branch always
lda bios_usernmi_vec+ 0
sta NMI_vec + 0
lda bios_usernmi_vec+ 1
sta NMI_vec + 1
:
JMP LAB_COLD ; do EhBASIC cold start
; using acai routines from rom bank 0
ACIAout
jmp bios_conout
ACIAin
jmp bios_const
;
; vector tables
LAB_vec
.word ACIAin ; byte in from simulated ACIAsfossfos
.word ACIAout ; byte out to simulated ACIA
.word load ; null load vector for EhBASIC
.word save ; null save vector for EhBASIC
.word RES_vec
; EhBASIC IRQ support
IRQ_CODE
PHA ; save A
LDA IrqBase ; get the IRQ flag byte
LSR ; shift the set b7 to b6, and on down ...
ORA IrqBase ; OR the original back in
STA IrqBase ; save the new IRQ flag byte
PLA ; restore A
RTS
; EhBASIC NMI support
NMI_CODE
PHA ; save A
LDA NmiBase ; get the NMI flag byte
LSR ; shift the set b7 to b6, and on down ...
ORA NmiBase ; OR the original back in
STA NmiBase ; save the new NMI flag byte
PLA ; restore A
RTS
END_CODE
LAB_mess
.byte $0D,$0A,"6502 EhBASIC",$00
; sign on string
.include "6502-retro-basic.s"
|
6502-retro/6502-retro-os
| 6,880
|
apps/mon/main.s
|
; vim: ft=asm_ca65 sw=4 ts=4 et
.include "fcb.inc"
.include "io.inc"
IN = wozmon_buf
acia_putc = bios_conout
acia_getc_nw = bios_const
.bss
wozmon_buf: .res $7F
.zeropage
rambank: .res 1
rombank: .res 1
XAML: .res 1
XAMH: .res 1
STL: .res 1
STH: .res 1
L: .res 1
H: .res 1
YSAV: .res 1
MODE: .res 1
MSGL: .res 1
MSGH: .res 1
.code
wozmon:
RESET:
CLD ;Clear decimal arithmetic mode.
CLI
LDA #$0D
JSR ECHO ;* New line.
LDA #$0A
JSR ECHO
LDA #<MSG1
STA MSGL
LDA #>MSG1
STA MSGH
JSR SHWMSG ;* Show Welcome.
LDA #$0D
JSR ECHO ;* New line.
LDA #$0A
JSR ECHO
SOFTRESET:
LDA #$9B ;* Auto escape.
NOTCR:
CMP #$88 ;"<-"? * Note this was chaged to $88 which is the back space key.
BEQ BACKSPACE ;Yes.
CMP #$9B ;ESC?
BEQ ESCAPE ;Yes.
INY ;Advance text index.
BPL NEXTCHAR ;Auto ESC if >127.
ESCAPE:
LDA #$DC ;"\"
JSR ECHO ;Output it.
GETLINE:
LDA #$8D ;CR.
JSR ECHO ;Output it.
LDA #$8A
JSR ECHO
LDY #$01 ;Initiallize text index.
BACKSPACE:
DEY ;Backup text index.
BMI GETLINE ;Beyond start of line, reinitialize.
LDA #$A0 ;*Space, overwrite the backspaced char.
JSR ECHO
LDA #$88 ;*Backspace again to get to correct pos.
JSR ECHO
NEXTCHAR:
JSR acia_getc_nw
BCC NEXTCHAR
CMP #$60 ;*Is it Lower case
BMI CONVERT ;*Nope, just convert it
AND #$5F ;*If lower case, convert to Upper case
CONVERT:
ORA #$80 ;*Convert it to "ASCII Keyboard" Input
STA IN,Y ;Add to text buffer.
JSR ECHO ;Display character.
CMP #$8D ;CR?
BNE NOTCR ;No.
LDY #$FF ;Reset text index.
LDA #$00 ;For XAM mode.
TAX ;0->X.
SETSTOR:
ASL ;Leaves $7B if setting STOR mode.
SETMODE:
STA MODE ;$00 = XAM, $7B = STOR, $AE = BLOK XAM.
BLSKIP:
INY ;Advance text index.
NEXTITEM:
LDA IN,Y ;Get character.
CMP #$8D ;CR?
BEQ GETLINE ;Yes, done this line.
CMP #$AE ;"."?
BCC BLSKIP ;Skip delimiter.
BEQ SETMODE ;Set BLOCK XAM mode.
CMP #$BA ;":"?
BEQ SETSTOR ;Yes, set STOR mode.
CMP #$D1 ;"Q"?
BEQ EXIT
CMP #$D2 ;"R"?
BEQ RUN ;Yes, run user program.
STX L ;$00->L.
STX H ; and H.
STY YSAV ;Save Y for comparison.
NEXTHEX:
LDA IN,Y ;Get character for hex test.
EOR #$B0 ;Map digits to $0-9.
CMP #$0A ;Digit?
BCC DIG ;Yes.
ADC #$88 ;Map letter "A"-"F" to $FA-FF.
CMP #$FA ;Hex letter?
BCC NOTHEX ;No, character not hex.
DIG:
ASL
ASL ;Hex digit to MSD of A.
ASL
ASL
LDX #$04 ;Shift count.
HEXSHIFT:
ASL ;Hex digit left MSB to carry.
ROL L ;Rotate into LSD.
ROL H ;Rotate into MSD's.
DEX ;Done 4 shifts?
BNE HEXSHIFT ;No, loop.
INY ;Advance text index.
BNE NEXTHEX ;Always taken. Check next character for hex.
NOTHEX:
CPY YSAV ;Check if L, H empty (no hex digits).
BNE NOESCAPE ;* Branch out of range, had to improvise...
JMP ESCAPE ;Yes, generate ESC sequence.
EXIT:
JMP bios_wboot
RUN:
JSR ACTRUN ;* JSR to the Address we want to run.
JMP SOFTRESET ;* When returned for the program, reset EWOZ.
ACTRUN:
JMP (XAML) ;Run at current XAM index.
NOESCAPE:
BIT MODE ;Test MODE byte.
BVC NOTSTOR ;B6=0 for STOR, 1 for XAM and BLOCK XAM
LDA L ;LSD's of hex data.
STA (STL, X) ;Store at current "store index".
INC STL ;Increment store index.
BNE NEXTITEM ;Get next item. (no carry).
INC STH ;Add carry to 'store index' high order.
TONEXTITEM:
JMP NEXTITEM ;Get next command item.
NOTSTOR:
BMI XAMNEXT ;B7=0 for XAM, 1 for BLOCK XAM.
LDX #$02 ;Byte count.
SETADR:
LDA L-1,X ;Copy hex data to
STA STL-1,X ;"store index".
STA XAML-1,X ;And to "XAM index'.
DEX ;Next of 2 bytes.
BNE SETADR ;Loop unless X = 0.
NXTPRNT:
BNE PRDATA ;NE means no address to print.
LDA #$8D ;CR.
JSR ECHO ;Output it.
LDA #$8A
JSR ECHO
LDA XAMH ;'Examine index' high-order byte.
JSR PRBYTE ;Output it in hex format.
LDA XAML ;Low-order "examine index" byte.
JSR PRBYTE ;Output it in hex format.
LDA #$BA ;":".
JSR ECHO ;Output it.
PRDATA:
LDA #$A0 ;Blank.
JSR ECHO ;Output it.
LDA (XAML,X) ;Get data byte at 'examine index".
JSR PRBYTE ;Output it in hex format.
XAMNEXT:
STX MODE ;0-> MODE (XAM mode).
LDA XAML
CMP L ;Compare 'examine index" to hex data.
LDA XAMH
SBC H
BCS TONEXTITEM ;Not less, so no more data to output.
INC XAML
BNE MOD8CHK ;Increment 'examine index".
INC XAMH
MOD8CHK:
LDA XAML ;Check low-order 'exainine index' byte
AND #$0F ;For MOD 8=0 ** changed to $0F to get 16 values per row **
BPL NXTPRNT ;Always taken.
PRBYTE:
PHA ;Save A for LSD.
LSR
LSR
LSR ;MSD to LSD position.
LSR
JSR PRHEX ;Output hex digit.
PLA ;Restore A.
PRHEX:
AND #$0F ;Mask LSD for hex print.
ORA #$B0 ;Add "0".
CMP #$BA ;Digit?
BCC ECHO ;Yes, output it.
ADC #$06 ;Add offset for letter.
ECHO:
PHA ;*Save A
AND #$7F ;*Change to "standard ASCII"
JSR acia_putc
PLA ;*Restore A
RTS ;*Done, over and out...
SHWMSG:
LDY #$0
@PRINT:
LDA (MSGL),Y
BEQ @DONE
JSR ECHO
INY
BNE @PRINT
@DONE:
RTS
MSG1: .BYTE "Welcome to EWOZ 1.0.",0
.include "../app.inc"
|
6502-retro/6502-retro-os
| 1,244
|
apps/lib/read.s
|
;
; int __fastcall__ read (int fd, void* buf, unsigned count);
;
.import _sfos_c_read
.import popax, popptr1
.importzp ptr1, ptr2, ptr3
.export _read
.proc _read
sta ptr3
stx ptr3+1 ; Count in ptr3
inx
stx ptr2+1 ; Increment and store in ptr2
tax
inx
stx ptr2
jsr popptr1 ; Buffer address in ptr1
jsr popax
begin: dec ptr2
bne getch
dec ptr2+1
beq done ; If buffer full, return
getch:
phy
phx
jsr _sfos_c_read; Get character using Monitor ROM call
plx
ply
and #$7F ; Clear top bit
cmp #$0D ; Check for '\r'
bne putch ; ...if CR character
lda #$0A ; Replace with '\n'
putch: ldy #$00 ; Put char into return buffer
sta (ptr1),y
inc ptr1 ; Increment pointer
bne begin
inc ptr1+1
bne begin
done: lda ptr3
ldx ptr3+1
rts ; Return count
.endproc
|
6502-retro/6502-retro-os
| 1,256
|
apps/lib/write.s
|
;
; int __fastcall__ write (int fd, const void* buf, int count);
;
.import _sfos_c_write
.import popax, popptr1
.importzp ptr1, ptr2, ptr3
.export _write
.proc _write
sta ptr3
stx ptr3+1 ; Count in ptr3
inx
stx ptr2+1 ; Increment and store in ptr2
tax
inx
stx ptr2
jsr popptr1 ; Buffer address in ptr1
jsr popax
begin: dec ptr2
bne outch
dec ptr2+1
beq done
outch: ldy #0
lda (ptr1),y
pha ; Save A (changed by OUTCHR)
phy
phx
jsr _sfos_c_write; Send character using Monitor call
plx
ply
pla ; Restore A
cmp #$0A ; Check for '\n'
bne next ; ...if LF character
lda #$0D ; Add a carriage return
phy
phx
jsr _sfos_c_write
plx
ply
next: inc ptr1
bne begin
inc ptr1+1
jmp begin
done: lda ptr3
ldx ptr3+1
rts ; Return count
.endproc
|
6502-retro/6502-retro-os
| 1,150
|
apps/lib/sfos_wrappers.s
|
; vim: ft=asm_ca65 ts=4 sw=4
.include "bios.inc"
.export _sfos_error_code := bios_error_code
.export _sfos_cmdline := $300
.export _sfos_cmdoffset := $3C0
.export _sfos_buf := $400
.export _sfos_buf_end := $600
.export _sfos_entry := sfos_entry
.export _bios_cboot := bios_cboot
.export _bios_wboot := bios_wboot
.export _bios_conout := bios_conout
.export _bios_conin := bios_conin
.export _bios_const := bios_const
.export _bios_puts := bios_puts
.export _bios_prbyte := bios_prbyte
.export _bios_setdma := bios_setdma
.export _bios_setlba := bios_setlba
.export _bios_sdread := bios_sdread
.export _bios_sdwrite := bios_sdwrite
.export _bios_sn_beep := bios_sn_beep
.export _bios_sn_start := bios_sn_start
.export _bios_sn_silence := bios_sn_silence
.export _bios_sn_stop := bios_sn_stop
.export _bios_sn_send := bios_sn_send
.export _bios_led_on := bios_led_on
.export _bios_led_off := bios_led_off
.export _bios_get_button := bios_get_button
.export _notectr := notectr
|
6502-retro/6502-retro-os
| 4,039
|
apps/format/format.s
|
; vim: ft=asm_ca65 sw=4 ts=4 et
.include "fcb.inc"
.zeropage
bufptr: .word 0
.code
main:
lda #<str_message
ldx #>str_message
jsr c_printstr
jsr c_read
and #$DF
sta temp
sec
sbc #'A'-1
sta selected_drive
jsr newline
lda #<str_chose
ldx #>str_chose
jsr c_printstr
lda temp
jsr c_write
jsr newline
lda #<str_confirm
ldx #>str_confirm
jsr c_printstr
jsr c_read
cmp #'Y'
beq format
jmp exit
format:
lda #<str_format_start
ldx #>str_format_start
jsr c_printstr
; write empty dirents to the buffer each time incrementing the FN
; when the buffer is full, flush it to disk. Stop when all 256
; dirents have been written.
stz file_num
stz sector_num
new_buffer:
lda #<SFOS_BUF
sta bufptr+0
lda #>SFOS_BUF
sta bufptr+1
buffer_loop:
jsr copy_empty_dirent_to_bufptr
ldy #sfcb::DD
lda selected_drive
sta (bufptr),y
ldy #sfcb::FN
lda file_num
sta (bufptr),y
inc file_num
jsr bufptr_to_next_dirent
bcc buffer_loop
; full buffer - need to flush to disk
stz lba+1
stz lba+2
stz lba+3
lda selected_drive
dec
clc
asl ;x2
asl ;x4
asl ;x8
asl ;x16
clc
adc #$80
adc sector_num
sta lba+0
lda #<SFOS_BUF
ldx #>SFOS_BUF
jsr d_setdma
lda #<lba
ldx #>lba
jsr d_setlba
jsr d_writerawblock
lda #'.'
jsr c_write
inc sector_num
lda sector_num
cmp #$10
bne new_buffer
jsr set_user_drive
jmp exit
; ---- HELPER FUNCTIONS ------------------------------------------------------
copy_empty_dirent_to_bufptr:
ldy #31
: lda empty_dirent,y
sta (bufptr),y
dey
bpl :-
rts
; CARRY SET When buffer overflows, else carry clear.
bufptr_to_next_dirent:
clc
lda bufptr+0
adc #32
sta bufptr+0
lda bufptr+1
adc #0
sta bufptr+1
cmp #>SFOS_BUF_END
beq :+
clc
rts
: sec
rts
prbyte:
pha ;save a for lsd.
lsr
lsr
lsr ;msd to lsd position.
lsr
jsr @prhex ;output hex digit.
pla ;restore a.
@prhex:
and #$0f ;mask lsd for hex print.
ora #$b0 ;add "0".
cmp #$ba ;digit?
bcc @echo ;yes, output it.
adc #$06 ;add offset for letter.
@echo:
pha ;*save a
and #$7f ;*change to "standard ascii"
jsr c_write
pla ;*restore a
rts ;*done, over and out...
;
newline:
lda #<str_newline
ldx #>str_newline
jmp c_printstr
;
restore_active_drive:
lda FCB2
bne :+
rts
: lda saved_active_drive
sta active_drive
ldx #0
jmp d_getsetdrive
set_user_drive:
lda #$FF
ldx #$00
jsr d_getsetdrive
sta active_drive
lda FCB2
bne set_drive
rts
set_drive:
pha
lda active_drive
sta saved_active_drive
pla
sta active_drive
ldx #0
jmp d_getsetdrive
exit:
jsr restore_active_drive
jmp bios_wboot
.include "../app.inc"
.bss
_fcb: .res 32,0
active_drive: .byte 0
saved_active_drive: .byte 0
temp: .byte 0
selected_drive: .byte 0
dirpos: .byte 0
file_num: .byte 0
lba: .res 4,0
sector_num: .byte 0
.rodata
str_message: .byte 10,13,"Which drive would you like to format [A-H]? > ",0
str_chose: .byte 10,13,"You have selected drive: ",0
str_confirm: .byte 10,13,"Are you sure? (Y/n) > ",0
str_format_start:.byte 10,13,"Formatting ",0
str_format_end: .byte " OK",0
str_error: .byte 10,13,"ERROR",10,13,0
str_newline: .byte 10,13,0
; 0 1 2 3 4 5 6 7 8 9 A B C D E, F
empty_dirent: .byte 0, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, $20, 0, 0, 0, 0 ; 00
.byte $E5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ; 10
|
6502-retro/6502-retro-os
| 13,330
|
apps/xm/xm.s
|
; vim: ft=asm_ca65 sw=4 ts=4 et
.include "fcb.inc"
SOH = $01 ; start block
EOT = $04 ; end of text marker
ACK = $06 ; good block acknowledged
NAK = $15 ; bad block acknowledged
CAN = $18 ; cancel (not standard, not supported)
CR = $0d ; carriage return
LF = $0a ; line feed
ESC = $1b ; ESC to exit
.zeropage
crc: .res 1
crch: .res 1
ptr: .res 1
ptrh: .res 1
blkno: .res 1
retry: .res 1
retry2: .res 1
bflag: .res 1
.code
main:
; first things first. make a new file. Fail if file exists
jsr set_user_drive
; copy fcb2 filename into fcb
jsr clear_fcb
ldx #sfcb::N1
: lda FCB2,x
sta FCB,x
inx
cpx #sfcb::T3+1
bne :-
jsr newline
lda #<FCB
ldx #>FCB
jsr d_make
bcc :+
lda #<str_makefailed
ldx #>str_makefailed
jsr c_printstr
lda #1
clc
rts
:
start:
jsr PrintMsg ; send prompt and info
lda #$01
sta blkno ; set block # to 1
sta bflag ; set flag to get address from block 1
StartCrc:
lda #'C' ; "C" start with CRC mode
jsr Put_Chr ; send it
lda #$FF
sta retry2 ; set loop counter for ~3 sec delay
lda #$00
sta crc
sta crch ; init CRC value
jsr GetByte ; wait for input
bcs GotByte ; byte received, process it
bcc StartCrc ; resend "C"
StartBlk:
lda #$FF ;
sta retry2 ; set loop counter for ~3 sec delay
lda #$00 ;
sta crc ;
sta crch ; init CRC value
jsr GetByte ; get first byte of block
bcc StartBlk ; timed out, keep waiting...
GotByte:
cmp #ESC ; quitting?
bne GotByte1 ; no
jsr restore_active_drive
jmp bios_wboot ; YES - do BRK or change to RTS if desired
GotByte1:
cmp #SOH ; start of block?
beq BegBlk ; yes
cmp #EOT ;
bne BadCrc ; Not SOH or EOT, so flush buffer & send NAK
jmp Done ; EOT - all done!
BegBlk:
ldx #$00
GetBlk:
lda #$ff ; 3 sec window to receive characters
sta retry2 ;
GetBlk1:
jsr GetByte ; get next character
bcc BadCrc ; chr rcv error, flush and send NAK
GetBlk2:
sta Rbuff,x ; good char, save it in the rcv buffer
inx ; inc buffer pointer
cpx #$84 ; <01> <FE> <128 bytes> <CRCH> <CRCL>
bne GetBlk ; get 132 characters
ldx #$00 ;
lda Rbuff,x ; get block # from buffer
cmp blkno ; compare to expected block #
beq GoodBlk1 ; matched!
jsr Print_Err ; Unexpected block number - abort
jsr Flush ; mismatched - flush buffer and then do BRK
jsr restore_active_drive
jmp bios_wboot
GoodBlk1:
eor #$ff ; 1's comp of block #
inx ;
cmp Rbuff,x ; compare with expected 1's comp of block #
beq GoodBlk2 ; matched!
jsr Print_Err ; Unexpected block number - abort
jsr Flush ; mismatched - flush buffer and then do BRK
jsr restore_active_drive
jmp bios_wboot ; bad 1's comp of block#
GoodBlk2:
ldy #$02 ;
CalcCrc:
lda Rbuff,y ; calculate the CRC for the 128 bytes of data
jsr UpdCrc ; could inline sub here for speed
iny ;
cpy #$82 ; 128 bytes
bne CalcCrc ;
lda Rbuff,y ; get hi CRC from buffer
cmp crch ; compare to calculated hi CRC
bne BadCrc ; bad crc, send NAK
iny ;
lda Rbuff,y ; get lo CRC from buffer
cmp crc ; compare to calculated lo CRC
beq GoodCrc ; good CRC
BadCrc:
jsr Flush ; flush the input port
lda #NAK ;
jsr Put_Chr ; send NAK to resend block
jmp StartBlk ; start over, get the block again
GoodCrc:
ldx #$02 ;
lda blkno ; get the block number
cmp #$01 ; 1st block?
bne CopyBlk ; no, copy all 128 bytes
lda bflag ; is it really block 1, not block 257, 513 etc.
beq CopyBlk ; no, copy all 128 bytes
@get_target_address: ; in this case, the first 2 bytes contain the start address to save to.
lda Rbuff,x ; get target address from 1st 2 bytes of blk 1
sta FCB + sfcb::L1 ; save to FCB LOAD and EXEC are the same.
sta FCB + sfcb::E1
inx ;
lda Rbuff,x ; get hi address
sta FCB + sfcb::L2
sta FCB + sfcb::E2
inx ; point to first byte of data
lda #<SFOS_BUF ; write data into buffer and when we get to top of buffer, write
sta ptr+0 ; to disk
lda #>SFOS_BUF
sta ptr+1
jsr clear_buf
@get_target_address_end:
dec bflag ; set the flag so we won't get another address
CopyBlk:
ldy #$00 ; set offset to zero
CopyBlk3:
lda Rbuff,x ; get data byte from buffer
sta (ptr) ; save to target
inc ptr+0 ; point to next address
bne CopyBlk4 ; did it step over page boundary?
inc ptr+1 ; adjust high address for page crossing
;; ; check if we need to flush the buffer to disk.
lda ptr+1
cmp #>SFOS_BUF_END
bne CopyBlk4
;; WRITE BUFFER TO DISK
phx
lda #<SFOS_BUF
ldx #>SFOS_BUF
jsr d_setdma
lda #<FCB
ldx #>FCB
jsr d_writeseqblock
bcc :+
plx
jsr restore_active_drive
jmp bios_wboot
:
lda #<SFOS_BUF
sta ptr+0
lda #>SFOS_BUF
sta ptr+1
inc FCB + sfcb::SC
jsr clear_buf
plx
CopyBlk4:
inx ; point to next data byte
cpx #$82 ; is it the last byte
bne CopyBlk3 ; no, get the next one
IncBlk:
inc blkno ; done. Inc the block #
lda #ACK ; send ACK
jsr Put_Chr ;
jmp StartBlk ; get next block
Done:
lda #ACK ; last block, send ACK and exit.
jsr Put_Chr ;
jsr Flush ; get leftover characters, if any
jsr Print_Good ;
lda #<SFOS_BUF ; write the last sector
ldx #>SFOS_BUF
jsr d_setdma
lda #<FCB
ldx #>FCB
jsr d_writeseqblock
inc FCB+sfcb::SC
;
; save the size (sector count * 512)
lda FCB+sfcb::SC
sta FCB+sfcb::S0
; x 512 This works because S0, S1 and S2 are all initialised to zero by make.
ldx #9
clc
: asl FCB+sfcb::S0 ;x512
rol FCB+sfcb::S1
rol FCB+sfcb::S2
dex
bne :-
;
; set attribute
;jsr debug_fcb
lda #<FCB
ldx #>FCB
jsr d_close
jsr restore_active_drive
jmp bios_wboot;
;
;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
;
; subroutines
;
;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
;
GetByte:
lda #$00 ; wait for chr input and cycle timing loop
sta retry ; set low value of timing loop
StartCrcLp:
jsr Get_Chr ; get chr from serial port, don't wait
bcs GetByte1 ; got one, so exit
dec retry ; no character received, so dec counter
bne StartCrcLp ;
dec retry2 ; dec hi byte of counter
bne StartCrcLp ; look for character again
clc ; if loop times out, CLC, else SEC and return
GetByte1:
rts ; with character in "A"
;
Flush:
lda #$70 ; flush receive buffer
sta retry2 ; flush until empty for ~1 sec.
Flush1:
jsr GetByte ; read the port
bcs Flush ; if chr recvd, wait for another
rts ; else done
;
PrintMsg:
ldx #$00 ; PRINT starting message
PrtMsg1:
lda Msg,x
beq PrtMsg2
jsr Put_Chr
inx
bne PrtMsg1
PrtMsg2:
rts
Msg:
.byte "Begin XMODEM/CRC transfer. Press <Esc> to abort..."
.byte CR, LF
.byte 0
;
Print_Err:
ldx #$00 ; PRINT Error message
PrtErr1:
lda ErrMsg,x
beq PrtErr2
jsr Put_Chr
inx
bne PrtErr1
PrtErr2:
rts
ErrMsg:
.byte "Upload Error!"
.byte CR, LF
.byte 0
;
Print_Good:
ldx #$00 ; PRINT Good Transfer message
Prtgood1:
lda GoodMsg,x
beq Prtgood2
jsr Put_Chr
inx
bne Prtgood1
Prtgood2:
rts
GoodMsg:
.byte "Upload Successful!"
.byte CR, LF
.byte 0
;
;
;======================================================================
; I/O Device Specific Routines
;
; Two routines are used to communicate with the I/O device.
;
; "Get_Chr" routine will scan the input port for a character. It will
; return without waiting with the Carry flag CLEAR if no character is
; present or return with the Carry flag SET and the character in the "A"
; register if one was present.
;
; "Put_Chr" routine will write one byte to the output port. Its alright
; if this routine waits for the port to be ready. its assumed that the
; character was send upon return from this routine.
;
; input chr from ACIA (no waiting)
;
Get_Chr:
jmp c_status
; output to OutPut Port
;
Put_Chr:
jmp c_write
;=========================================================================
;
;
; CRC subroutines
;
;
UpdCrc:
eor crc+1 ; Quick CRC computation with lookup tables
tax ; updates the two bytes at crc & crc+1
lda crc ; with the byte send in the "A" register
eor crchi,X
sta crc+1
lda crclo,X
sta crc
rts
restore_active_drive:
lda FCB2
bne :+
rts
: lda saved_active_drive
sta active_drive
ldx #0
jmp d_getsetdrive
set_user_drive:
lda #$FF
ldx #$00
jsr d_getsetdrive
sta active_drive
lda FCB2
bne set_drive
rts
set_drive:
pha
lda active_drive
sta saved_active_drive
pla
sta active_drive
ldx #0
jmp d_getsetdrive
clear_fcb:
ldx #31
lda #0
: sta FCB,x
dex
bpl :-
rts
clear_fcb2:
ldx #31
lda #0
: sta FCB2,x
dex
bpl :-
rts
newline:
lda #<str_newline
ldx #>str_newline
jmp c_printstr
clear_buf:
lda #0
ldy #0
: sta SFOS_BUF,y
iny
bne :-
: sta SFOS_BUF+256,y
iny
bne :-
rts
.include "../app.inc"
.bss
Rbuff: .res 128, 0
active_drive: .byte 0
saved_active_drive: .byte 0
.rodata
str_message: .byte 10,13,"XModem Receive",10,13,0
str_fileexists: .byte 10,13,"File already exists.",10,13,0
str_newline: .byte 10,13,0
str_makefailed: .byte 10,13,"MAKE FAILED",10,13,0
crclo:
.byte $00,$21,$42,$63,$84,$A5,$C6,$E7,$08,$29,$4A,$6B,$8C,$AD,$CE,$EF
.byte $31,$10,$73,$52,$B5,$94,$F7,$D6,$39,$18,$7B,$5A,$BD,$9C,$FF,$DE
.byte $62,$43,$20,$01,$E6,$C7,$A4,$85,$6A,$4B,$28,$09,$EE,$CF,$AC,$8D
.byte $53,$72,$11,$30,$D7,$F6,$95,$B4,$5B,$7A,$19,$38,$DF,$FE,$9D,$BC
.byte $C4,$E5,$86,$A7,$40,$61,$02,$23,$CC,$ED,$8E,$AF,$48,$69,$0A,$2B
.byte $F5,$D4,$B7,$96,$71,$50,$33,$12,$FD,$DC,$BF,$9E,$79,$58,$3B,$1A
.byte $A6,$87,$E4,$C5,$22,$03,$60,$41,$AE,$8F,$EC,$CD,$2A,$0B,$68,$49
.byte $97,$B6,$D5,$F4,$13,$32,$51,$70,$9F,$BE,$DD,$FC,$1B,$3A,$59,$78
.byte $88,$A9,$CA,$EB,$0C,$2D,$4E,$6F,$80,$A1,$C2,$E3,$04,$25,$46,$67
.byte $B9,$98,$FB,$DA,$3D,$1C,$7F,$5E,$B1,$90,$F3,$D2,$35,$14,$77,$56
.byte $EA,$CB,$A8,$89,$6E,$4F,$2C,$0D,$E2,$C3,$A0,$81,$66,$47,$24,$05
.byte $DB,$FA,$99,$B8,$5F,$7E,$1D,$3C,$D3,$F2,$91,$B0,$57,$76,$15,$34
.byte $4C,$6D,$0E,$2F,$C8,$E9,$8A,$AB,$44,$65,$06,$27,$C0,$E1,$82,$A3
.byte $7D,$5C,$3F,$1E,$F9,$D8,$BB,$9A,$75,$54,$37,$16,$F1,$D0,$B3,$92
.byte $2E,$0F,$6C,$4D,$AA,$8B,$E8,$C9,$26,$07,$64,$45,$A2,$83,$E0,$C1
.byte $1F,$3E,$5D,$7C,$9B,$BA,$D9,$F8,$17,$36,$55,$74,$93,$B2,$D1,$F0
; hi byte CRC lookup table (should be page aligned)
crchi:
.byte $00,$10,$20,$30,$40,$50,$60,$70,$81,$91,$A1,$B1,$C1,$D1,$E1,$F1
.byte $12,$02,$32,$22,$52,$42,$72,$62,$93,$83,$B3,$A3,$D3,$C3,$F3,$E3
.byte $24,$34,$04,$14,$64,$74,$44,$54,$A5,$B5,$85,$95,$E5,$F5,$C5,$D5
.byte $36,$26,$16,$06,$76,$66,$56,$46,$B7,$A7,$97,$87,$F7,$E7,$D7,$C7
.byte $48,$58,$68,$78,$08,$18,$28,$38,$C9,$D9,$E9,$F9,$89,$99,$A9,$B9
.byte $5A,$4A,$7A,$6A,$1A,$0A,$3A,$2A,$DB,$CB,$FB,$EB,$9B,$8B,$BB,$AB
.byte $6C,$7C,$4C,$5C,$2C,$3C,$0C,$1C,$ED,$FD,$CD,$DD,$AD,$BD,$8D,$9D
.byte $7E,$6E,$5E,$4E,$3E,$2E,$1E,$0E,$FF,$EF,$DF,$CF,$BF,$AF,$9F,$8F
.byte $91,$81,$B1,$A1,$D1,$C1,$F1,$E1,$10,$00,$30,$20,$50,$40,$70,$60
.byte $83,$93,$A3,$B3,$C3,$D3,$E3,$F3,$02,$12,$22,$32,$42,$52,$62,$72
.byte $B5,$A5,$95,$85,$F5,$E5,$D5,$C5,$34,$24,$14,$04,$74,$64,$54,$44
.byte $A7,$B7,$87,$97,$E7,$F7,$C7,$D7,$26,$36,$06,$16,$66,$76,$46,$56
.byte $D9,$C9,$F9,$E9,$99,$89,$B9,$A9,$58,$48,$78,$68,$18,$08,$38,$28
.byte $CB,$DB,$EB,$FB,$8B,$9B,$AB,$BB,$4A,$5A,$6A,$7A,$0A,$1A,$2A,$3A
.byte $FD,$ED,$DD,$CD,$BD,$AD,$9D,$8D,$7C,$6C,$5C,$4C,$3C,$2C,$1C,$0C
.byte $EF,$FF,$CF,$DF,$AF,$BF,$8F,$9F,$6E,$7E,$4E,$5E,$2E,$3E,$0E,$1E
;
|
6502-retro/6502-retro-os
| 2,584
|
apps/copy/copy.s
|
; vim: ft=asm_ca65 sw=4 ts=4 et
.include "fcb.inc"
.zeropage
.code
main:
lda #<str_message
ldx #>str_message
jsr c_printstr
jsr set_user_drive
; gather arguments
; FCB2 contains source
; CMDOFFSET points to file name of destination. Parse it.
; clear out FCB
ldx #0
lda #0
: sta FCB,x
inx
cpx #32
bne :-
; parse fcb
lda #<FCB
ldx #>FCB
jsr d_setdma
lda CMDOFFSET+0
ldx CMDOFFSET+1
jsr d_parsefcb
jsr newline
; FCB contains the destination copy:
; open the source
lda #<FCB2
ldx #>FCB2
jsr d_open
; copy meta from FCB2 into FCB
lda FCB2+sfcb::L1
sta FCB+sfcb::L1
lda FCB2+sfcb::L2
sta FCB+sfcb::L2
lda FCB2+sfcb::SC
sta FCB+sfcb::SC
lda FCB2+sfcb::E1
sta FCB+sfcb::E1
lda FCB2+sfcb::E2
sta FCB+sfcb::E2
lda FCB2+sfcb::S0
sta FCB+sfcb::S0
lda FCB2+sfcb::S1
sta FCB+sfcb::S1
lda FCB2+sfcb::S2
sta FCB+sfcb::S2
lda FCB+sfcb::DD
jsr d_getsetdrive
; make the destination
lda #<FCB
ldx #>FCB
jsr d_make
lda FCB2+sfcb::SC
sta temp
; if the source file is empty, we just close and complete the copy.
lda FCB2 + sfcb::SC
beq close
loop:
; read a block of the source
lda #<SFOS_BUF
ldx #>SFOS_BUF
jsr d_setdma
lda #<FCB2
ldx #>FCB2
jsr d_readseqblock
lda #'r'
jsr c_write
lda #<SFOS_BUF
ldx #>SFOS_BUF
jsr d_setdma
lda #<FCB
ldx #>FCB
jsr d_writeseqblock
lda #'w'
jsr c_write
dec temp
lda temp
bne loop
close:
lda #<FCB
ldx #>FCB
jsr d_close
; all done
jmp exit
; ---- HELPER FUNCTIONS ------------------------------------------------------
newline:
lda #<str_newline
ldx #>str_newline
jmp c_printstr
restore_active_drive:
lda FCB2
bne :+
rts
: lda saved_active_drive
sta active_drive
ldx #0
jmp d_getsetdrive
set_user_drive:
lda #$FF
ldx #$00
jsr d_getsetdrive
sta active_drive
lda FCB2
bne set_drive
rts
set_drive:
pha
lda active_drive
sta saved_active_drive
pla
sta active_drive
ldx #0
jmp d_getsetdrive
exit:
jsr restore_active_drive
jmp bios_wboot
.include "../app.inc"
.bss
_fcb: .res 32,0
active_drive: .byte 0
saved_active_drive: .byte 0
temp: .byte 0
.rodata
str_message: .byte 10,13,"Copy file...",10,13,0
str_newline: .byte 10,13,0
str_error: .byte 10,13,"Error copying file...",10,13,0
|
6502-retro/6502-retro-os
| 1,491
|
apps/msbasic/defines.s
|
.if .def(cbmbasic1)
CBM1 := 1
.include "defines_cbm1.s"
.elseif .def(osi)
OSI := 1
.include "defines_osi.s"
.elseif .def(applesoft)
APPLE := 1
.include "defines_apple.s"
.elseif .def(kb9)
KIM := 1
.include "defines_kim.s"
.elseif .def(cbmbasic2)
CBM2 := 1
.include "defines_cbm2.s"
.elseif .def(kbdbasic)
KBD := 1
.include "defines_kbd.s"
.elseif .def(microtan)
MICROTAN := 1
.include "defines_microtan.s"
.elseif .def(aim65)
AIM65 := 1
.include "defines_aim65.s"
.elseif .def(sym1)
SYM1 := 1
.include "defines_sym1.s"
.elseif .def(retro)
RETRO := 1
.include "defines_retro.s"
.endif
.ifdef CONFIG_2C
CONFIG_2B := 1
.endif
.ifdef CONFIG_2B
CONFIG_2A := 1
.endif
.ifdef CONFIG_2A
CONFIG_2 := 1
.endif
.ifdef CONFIG_2
CONFIG_11A := 1
.endif
.ifdef CONFIG_11A
CONFIG_11 := 1
.endif
.ifdef CONFIG_11
CONFIG_10A := 1
.endif
.ifdef CONFIG_SMALL
BYTES_FP := 4
CONFIG_SMALL_ERROR := 1
.else
BYTES_FP := 5
.endif
.ifndef BYTES_PER_ELEMENT
BYTES_PER_ELEMENT := BYTES_FP
.endif
BYTES_PER_VARIABLE := BYTES_FP+2
MANTISSA_BYTES := BYTES_FP-1
BYTES_PER_FRAME := 2*BYTES_FP+8
FOR_STACK1 := 2*BYTES_FP+5
FOR_STACK2 := BYTES_FP+4
.ifndef MAX_EXPON
MAX_EXPON = 10
.endif
STACK := $0100
.ifndef STACK2
STACK2 := STACK
.endif
.ifdef INPUTBUFFER
.if INPUTBUFFER >= $0100
CONFIG_NO_INPUTBUFFER_ZP := 1
.endif
.if INPUTBUFFER = $0200
CONFIG_INPUTBUFFER_0200 := 1
.endif
.endif
INPUTBUFFERX = INPUTBUFFER & $FF00
CR=13
LF=10
.ifndef CRLF_1
CRLF_1 := CR
CRLF_2 := LF
.endif
|
6502-retro/6502-retro-os
| 9,493
|
apps/msbasic/array.s
|
.segment "CODE"
; ----------------------------------------------------------------------------
; COMPUTE ADDRESS OF FIRST VALUE IN ARRAY
; ARYPNT = (LOWTR) + #DIMS*2 + 5
; ----------------------------------------------------------------------------
GETARY:
lda EOLPNTR
asl a
adc #$05
adc LOWTR
ldy LOWTR+1
bcc L2FAF
iny
L2FAF:
sta HIGHDS
sty HIGHDS+1
rts
; ----------------------------------------------------------------------------
NEG32768:
.byte $90,$80,$00,$00
.ifdef CONFIG_2C
.byte $00; bugfix: short number
.endif
; ----------------------------------------------------------------------------
; EVALUATE NUMERIC FORMULA AT TXTPTR
; CONVERTING RESULT TO INTEGER 0 <= X <= 32767
; IN FAC+3,4
; ----------------------------------------------------------------------------
MAKINT:
jsr CHRGET
.ifdef CONFIG_2
jsr FRMEVL
.else
jsr FRMNUM
.endif
; ----------------------------------------------------------------------------
; CONVERT FAC TO INTEGER
; MUST BE POSITIVE AND LESS THAN 32768
; ----------------------------------------------------------------------------
MKINT:
.ifdef CONFIG_2
jsr CHKNUM
.endif
lda FACSIGN
bmi MI1
; ----------------------------------------------------------------------------
; CONVERT FAC TO INTEGER
; MUST BE -32767 <= FAC <= 32767
; ----------------------------------------------------------------------------
AYINT:
lda FAC
cmp #$90
bcc MI2
lda #<NEG32768
ldy #>NEG32768
jsr FCOMP
MI1:
bne IQERR
MI2:
jmp QINT
; ----------------------------------------------------------------------------
; LOCATE ARRAY ELEMENT OR CREATE AN ARRAY
; ----------------------------------------------------------------------------
ARRAY:
lda DIMFLG
.ifndef CONFIG_SMALL
ora VALTYP+1
.endif
pha
lda VALTYP
pha
ldy #$00
L2FDE:
tya
pha
lda VARNAM+1
pha
lda VARNAM
pha
jsr MAKINT
pla
sta VARNAM
pla
sta VARNAM+1
pla
tay
tsx
lda STACK+2,x
pha
lda STACK+1,x
pha
lda FAC_LAST-1
sta STACK+2,x
lda FAC_LAST
sta STACK+1,x
iny
jsr CHRGOT
cmp #$2C
beq L2FDE
sty EOLPNTR
jsr CHKCLS
pla
sta VALTYP
pla
.ifndef CONFIG_SMALL
sta VALTYP+1
and #$7F
.endif
sta DIMFLG
; ----------------------------------------------------------------------------
; SEARCH ARRAY TABLE FOR THIS ARRAY NAME
; ----------------------------------------------------------------------------
ldx ARYTAB
lda ARYTAB+1
L301F:
stx LOWTR
sta LOWTR+1
cmp STREND+1
bne L302B
cpx STREND
beq MAKE_NEW_ARRAY
L302B:
ldy #$00
lda (LOWTR),y
iny
cmp VARNAM
bne L303A
lda VARNAM+1
cmp (LOWTR),y
beq USE_OLD_ARRAY
L303A:
iny
lda (LOWTR),y
clc
adc LOWTR
tax
iny
lda (LOWTR),y
adc LOWTR+1
bcc L301F
; ----------------------------------------------------------------------------
; ERROR: BAD SUBSCRIPTS
; ----------------------------------------------------------------------------
SUBERR:
ldx #ERR_BADSUBS
.byte $2C
; ----------------------------------------------------------------------------
; ERROR: ILLEGAL QUANTITY
; ----------------------------------------------------------------------------
IQERR:
ldx #ERR_ILLQTY
JER:
jmp ERROR
; ----------------------------------------------------------------------------
; FOUND THE ARRAY
; ----------------------------------------------------------------------------
USE_OLD_ARRAY:
ldx #ERR_REDIMD
lda DIMFLG
bne JER
jsr GETARY
lda EOLPNTR
ldy #$04
cmp (LOWTR),y
bne SUBERR
jmp FIND_ARRAY_ELEMENT
; ----------------------------------------------------------------------------
; CREATE A NEW ARRAY, UNLESS CALLED FROM GETARYPT
; ----------------------------------------------------------------------------
MAKE_NEW_ARRAY:
jsr GETARY
jsr REASON
lda #$00
tay
sta STRNG2+1
ldx #BYTES_PER_ELEMENT
.if .def(CONFIG_SMALL) && (!.def(CONFIG_2))
stx STRNG2
.endif
lda VARNAM
sta (LOWTR),y
.ifndef CONFIG_SMALL
bpl L3078
dex
L3078:
.endif
iny
lda VARNAM+1
sta (LOWTR),y
.if (!.def(CONFIG_SMALL)) || .def(CONFIG_2)
bpl L3081
dex
.if !(.def(CONFIG_SMALL) && .def(CONFIG_2))
dex
.endif
L3081:
stx STRNG2
.endif
lda EOLPNTR
iny
iny
iny
sta (LOWTR),y
L308A:
ldx #$0B
lda #$00
bit DIMFLG
bvc L309A
pla
clc
adc #$01
tax
pla
adc #$00
L309A:
iny
sta (LOWTR),y
iny
txa
sta (LOWTR),y
jsr MULTIPLY_SUBSCRIPT
stx STRNG2
sta STRNG2+1
ldy INDEX
dec EOLPNTR
bne L308A
adc HIGHDS+1
bcs GME
sta HIGHDS+1
tay
txa
adc HIGHDS
bcc L30BD
iny
beq GME
L30BD:
jsr REASON
sta STREND
sty STREND+1
lda #$00
inc STRNG2+1
ldy STRNG2
beq L30D1
L30CC:
dey
sta (HIGHDS),y
bne L30CC
L30D1:
dec HIGHDS+1
dec STRNG2+1
bne L30CC
inc HIGHDS+1
sec
lda STREND
sbc LOWTR
ldy #$02
sta (LOWTR),y
lda STREND+1
iny
sbc LOWTR+1
sta (LOWTR),y
lda DIMFLG
bne RTS9
iny
; ----------------------------------------------------------------------------
; FIND SPECIFIED ARRAY ELEMENT
;
; (LOWTR),Y POINTS AT # OF DIMS IN ARRAY DESCRIPTOR
; THE SUBSCRIPTS ARE ALL ON THE STACK AS INTEGERS
; ----------------------------------------------------------------------------
FIND_ARRAY_ELEMENT:
lda (LOWTR),y
sta EOLPNTR
lda #$00
sta STRNG2
L30F6:
sta STRNG2+1
iny
pla
tax
sta FAC_LAST-1
pla
sta FAC_LAST
cmp (LOWTR),y
bcc FAE2
bne GSE
iny
txa
cmp (LOWTR),y
bcc FAE3
; ----------------------------------------------------------------------------
GSE:
jmp SUBERR
GME:
jmp MEMERR
; ----------------------------------------------------------------------------
FAE2:
iny
FAE3:
lda STRNG2+1
ora STRNG2
clc
beq L3124
jsr MULTIPLY_SUBSCRIPT
txa
adc FAC_LAST-1
tax
tya
ldy INDEX
L3124:
adc FAC_LAST
stx STRNG2
dec EOLPNTR
bne L30F6
.if .def(CONFIG_SMALL) && (!.def(CONFIG_2))
asl STRNG2
rol a
bcs GSE
asl STRNG2
rol a
bcs GSE
tay
lda STRNG2
.else
.ifdef CONFIG_11A
sta STRNG2+1
.endif
ldx #BYTES_FP
.ifdef CONFIG_SMALL
lda VARNAM+1
.else
lda VARNAM
.endif
bpl L3135
dex
L3135:
.ifdef CONFIG_SMALL
stx RESULT+1
.else
lda VARNAM+1
bpl L313B
dex
dex
L313B:
stx RESULT+2
.endif
lda #$00
jsr MULTIPLY_SUBS1
txa
.endif
adc HIGHDS
sta VARPNT
tya
adc HIGHDS+1
sta VARPNT+1
tay
lda VARPNT
RTS9:
rts
; ----------------------------------------------------------------------------
; MULTIPLY (STRNG2) BY ((LOWTR),Y)
; LEAVING PRODUCT IN A,X. (HI-BYTE ALSO IN Y.)
; USED ONLY BY ARRAY SUBSCRIPT ROUTINES
; ----------------------------------------------------------------------------
MULTIPLY_SUBSCRIPT:
sty INDEX
lda (LOWTR),y
sta RESULT_LAST-2
dey
lda (LOWTR),y
MULTIPLY_SUBS1:
sta RESULT_LAST-1
lda #$10
sta INDX
ldx #$00
ldy #$00
L3163:
txa
asl a
tax
tya
rol a
tay
bcs GME
asl STRNG2
rol STRNG2+1
bcc L317C
clc
txa
adc RESULT_LAST-2
tax
tya
adc RESULT_LAST-1
tay
bcs GME
L317C:
dec INDX
bne L3163
rts
|
6502-retro/6502-retro-os
| 6,913
|
apps/msbasic/flow1.s
|
.segment "CODE"
; ----------------------------------------------------------------------------
; "FOR" STATEMENT
;
; FOR PUSHES 18 BYTES ON THE STACK:
; 2 -- TXTPTR
; 2 -- LINE NUMBER
; 5 -- INITIAL (CURRENT) FOR VARIABLE VALUE
; 1 -- STEP SIGN
; 5 -- STEP VALUE
; 2 -- ADDRESS OF FOR VARIABLE IN VARTAB
; 1 -- FOR TOKEN ($81)
; ----------------------------------------------------------------------------
FOR:
lda #$80
sta SUBFLG
jsr LET
jsr GTFORPNT
bne L2619
txa
adc #FOR_STACK1
tax
txs
L2619:
pla
pla
lda #FOR_STACK2
jsr CHKMEM
jsr DATAN
clc
tya
adc TXTPTR
pha
lda TXTPTR+1
adc #$00
pha
lda CURLIN+1
pha
lda CURLIN
pha
lda #TOKEN_TO
jsr SYNCHR
jsr CHKNUM
jsr FRMNUM
lda FACSIGN
ora #$7F
and FAC+1
sta FAC+1
lda #<STEP
ldy #>STEP
sta INDEX
sty INDEX+1
jmp FRM_STACK3
; ----------------------------------------------------------------------------
; "STEP" PHRASE OF "FOR" STATEMENT
; ----------------------------------------------------------------------------
STEP:
lda #<CON_ONE
ldy #>CON_ONE
jsr LOAD_FAC_FROM_YA
jsr CHRGOT
cmp #TOKEN_STEP
bne L2665
jsr CHRGET
jsr FRMNUM
L2665:
jsr SIGN
jsr FRM_STACK2
lda FORPNT+1
pha
lda FORPNT
pha
lda #$81
pha
; ----------------------------------------------------------------------------
; PERFORM NEXT STATEMENT
; ----------------------------------------------------------------------------
NEWSTT:
jsr ISCNTC
lda TXTPTR
ldy TXTPTR+1
.if .def(CONFIG_NO_INPUTBUFFER_ZP) && .def(CONFIG_2)
cpy #>INPUTBUFFER
.ifdef CBM2
nop
.endif
beq LC6D4
.else
; BUG on AppleSoft I,
; fixed differently on AppleSoft II (ldx/inx)
beq L2683
.endif
sta OLDTEXT
sty OLDTEXT+1
LC6D4:
ldy #$00
L2683:
lda (TXTPTR),y
.ifndef CONFIG_11
beq LA5DC ; old: 1 cycle more on generic case
cmp #$3A
beq NEWSTT2
SYNERR1:
jmp SYNERR
LA5DC:
.else
bne COLON; new: 1 cycle more on ":" case
.endif
ldy #$02
lda (TXTPTR),y
clc
.ifdef CONFIG_2
jeq L2701
.else
beq L2701
.endif
iny
lda (TXTPTR),y
sta CURLIN
iny
lda (TXTPTR),y
sta CURLIN+1
tya
adc TXTPTR
sta TXTPTR
bcc NEWSTT2
inc TXTPTR+1
NEWSTT2:
jsr CHRGET
jsr EXECUTE_STATEMENT
jmp NEWSTT
; ----------------------------------------------------------------------------
; EXECUTE A STATEMENT
;
; (A) IS FIRST CHAR OF STATEMENT
; CARRY IS SET
; ----------------------------------------------------------------------------
EXECUTE_STATEMENT:
.ifndef CONFIG_11A
beq RET1
.else
beq RET2
.endif
.ifndef CONFIG_11
sec
.endif
EXECUTE_STATEMENT1:
sbc #$80
.ifndef CONFIG_11
jcc LET ; old: 1 cycle more on instr.
.else
bcc LET1; new: 1 cycle more on assignment
.endif
cmp #NUM_TOKENS
.ifdef CONFIG_2
bcs LC721
.else
bcs SYNERR1
.endif
asl a
tay
lda TOKEN_ADDRESS_TABLE+1,y
pha
lda TOKEN_ADDRESS_TABLE,y
pha
jmp CHRGET
.ifdef CONFIG_11
LET1:
jmp LET
COLON:
cmp #$3A
beq NEWSTT2
SYNERR1:
jmp SYNERR
.endif
.ifdef CONFIG_2; GO TO
LC721:
cmp #TOKEN_GO-$80
bne SYNERR1
jsr CHRGET
lda #TOKEN_TO
jsr SYNCHR
jmp GOTO
.endif
; ----------------------------------------------------------------------------
; "RESTORE" STATEMENT
; ----------------------------------------------------------------------------
RESTORE:
sec
lda TXTTAB
sbc #$01
ldy TXTTAB+1
bcs SETDA
dey
SETDA:
sta DATPTR
sty DATPTR+1
RET2:
rts
.include "iscntc.s"
;!!! runs into "STOP"
; ----------------------------------------------------------------------------
; "STOP" STATEMENT
; ----------------------------------------------------------------------------
STOP:
bcs END2
; ----------------------------------------------------------------------------
; "END" STATEMENT
; ----------------------------------------------------------------------------
END:
clc
END2:
bne RET1
lda TXTPTR
ldy TXTPTR+1
.if .def(CONFIG_NO_INPUTBUFFER_ZP) && .def(CONFIG_2)
; BUG on AppleSoft I
; fix exists on AppleSoft II
; TXTPTR+1 will always be > 0
ldx CURLIN+1
inx
.endif
beq END4
sta OLDTEXT
sty OLDTEXT+1
CONTROL_C_TYPED:
lda CURLIN
ldy CURLIN+1
sta OLDLIN
sty OLDLIN+1
END4:
pla
pla
L2701:
lda #<QT_BREAK
ldy #>QT_BREAK
.ifndef KBD
ldx #$00
stx Z14
.endif
bcc L270E
jmp PRINT_ERROR_LINNUM
L270E:
jmp RESTART
.ifdef KBD
LE664:
tay
jmp SNGFLT
.endif
; ----------------------------------------------------------------------------
; "CONT" COMMAND
; ----------------------------------------------------------------------------
CONT:
bne RET1
ldx #ERR_CANTCONT
ldy OLDTEXT+1
bne L271C
jmp ERROR
L271C:
lda OLDTEXT
sta TXTPTR
sty TXTPTR+1
lda OLDLIN
ldy OLDLIN+1
sta CURLIN
sty CURLIN+1
RET1:
rts
.ifdef KBD
PRT:
jsr GETBYT
txa
; not ROR bug safe
ror a
ror a
ror a
sta $8F
rts
LE68C:
ldy #$12
LE68E:
lda LEA30,y
sta $03A2,y
dey
bpl LE68E
rts
.endif
.ifndef AIM65
.if .def(CONFIG_NULL) || .def(CONFIG_PRINTNULLS)
; CBM1 has the keyword removed,
; but the code is still here
NULL:
jsr GETBYT
bne RET1
inx
cpx #NULL_MAX
bcs L2739
dex
stx Z15
L2738:
rts
L2739:
jmp IQERR
.endif
.ifndef CONFIG_11A
CLEAR:
bne RET1
jmp CLEARC
.endif
.endif
|
6502-retro/6502-retro-os
| 19,266
|
apps/msbasic/string.s
|
.segment "CODE"
; ----------------------------------------------------------------------------
; "STR$" FUNCTION
; ----------------------------------------------------------------------------
STR:
jsr CHKNUM
ldy #$00
jsr FOUT1
pla
pla
LD353:
lda #<(STACK2-1)
ldy #>(STACK2-1)
.if STACK2 > $0100
bne STRLIT
.else
beq STRLIT
.endif
; ----------------------------------------------------------------------------
; GET SPACE AND MAKE DESCRIPTOR FOR STRING WHOSE
; ADDRESS IS IN FAC+3,4 AND WHOSE LENGTH IS IN A-REG
; ----------------------------------------------------------------------------
STRINI:
ldx FAC_LAST-1
ldy FAC_LAST
stx DSCPTR
sty DSCPTR+1
; ----------------------------------------------------------------------------
; GET SPACE AND MAKE DESCRIPTOR FOR STRING WHOSE
; ADDRESS IS IN Y,X AND WHOSE LENGTH IS IN A-REG
; ----------------------------------------------------------------------------
STRSPA:
jsr GETSPA
stx FAC+1
sty FAC+2
sta FAC
rts
; ----------------------------------------------------------------------------
; BUILD A DESCRIPTOR FOR STRING STARTING AT Y,A
; AND TERMINATED BY $00 OR QUOTATION MARK
; RETURN WITH DESCRIPTOR IN A TEMPORARY
; AND ADDRESS OF DESCRIPTOR IN FAC+3,4
; ----------------------------------------------------------------------------
STRLIT:
ldx #$22
stx CHARAC
stx ENDCHR
; ----------------------------------------------------------------------------
; BUILD A DESCRIPTOR FOR STRING STARTING AT Y,A
; AND TERMINATED BY $00, (CHARAC), OR (ENDCHR)
;
; RETURN WITH DESCRIPTOR IN A TEMPORARY
; AND ADDRESS OF DESCRIPTOR IN FAC+3,4
; ----------------------------------------------------------------------------
STRLT2:
sta STRNG1
sty STRNG1+1
sta FAC+1
sty FAC+2
ldy #$FF
L3298:
iny
lda (STRNG1),y
beq L32A9
cmp CHARAC
beq L32A5
cmp ENDCHR
bne L3298
L32A5:
cmp #$22
beq L32AA
L32A9:
clc
L32AA:
sty FAC
tya
adc STRNG1
sta STRNG2
ldx STRNG1+1
bcc L32B6
inx
L32B6:
stx STRNG2+1
lda STRNG1+1
.ifdef CONFIG_NO_INPUTBUFFER_ZP
beq LD399
cmp #>INPUTBUFFER
.elseif .def(AIM65)
beq LD399
cmp #$01
.endif
bne PUTNEW
LD399:
tya
jsr STRINI
ldx STRNG1
ldy STRNG1+1
jsr MOVSTR
; ----------------------------------------------------------------------------
; STORE DESCRIPTOR IN TEMPORARY DESCRIPTOR STACK
;
; THE DESCRIPTOR IS NOW IN FAC, FAC+1, FAC+2
; PUT ADDRESS OF TEMP DESCRIPTOR IN FAC+3,4
; ----------------------------------------------------------------------------
PUTNEW:
ldx TEMPPT
cpx #TEMPST+9
bne PUTEMP
ldx #ERR_FRMCPX
JERR:
jmp ERROR
PUTEMP:
lda FAC
sta 0,x
lda FAC+1
sta 1,x
lda FAC+2
sta 2,x
ldy #$00
stx FAC_LAST-1
sty FAC_LAST
.ifdef CONFIG_2
sty FACEXTENSION
.endif
dey
sty VALTYP
stx LASTPT
inx
inx
inx
stx TEMPPT
rts
; ----------------------------------------------------------------------------
; MAKE SPACE FOR STRING AT BOTTOM OF STRING SPACE
; (A)=# BYTES SPACE TO MAKE
;
; RETURN WITH (A) SAME,
; AND Y,X = ADDRESS OF SPACE ALLOCATED
; ----------------------------------------------------------------------------
GETSPA:
lsr DATAFLG
L32F1:
pha
eor #$FF
sec
adc FRETOP
ldy FRETOP+1
bcs L32FC
dey
L32FC:
cpy STREND+1
bcc L3311
bne L3306
cmp STREND
bcc L3311
L3306:
sta FRETOP
sty FRETOP+1
sta FRESPC
sty FRESPC+1
tax
pla
rts
L3311:
ldx #ERR_MEMFULL
lda DATAFLG
bmi JERR
jsr GARBAG
lda #$80
sta DATAFLG
pla
bne L32F1
; ----------------------------------------------------------------------------
; SHOVE ALL REFERENCED STRINGS AS HIGH AS POSSIBLE
; IN MEMORY (AGAINST HIMEM), FREEING UP SPACE
; BELOW STRING AREA DOWN TO STREND.
; ----------------------------------------------------------------------------
GARBAG:
.ifdef CONST_MEMSIZ
ldx #<CONST_MEMSIZ
lda #>CONST_MEMSIZ
.else
ldx MEMSIZ
lda MEMSIZ+1
.endif
FINDHIGHESTSTRING:
stx FRETOP
sta FRETOP+1
ldy #$00
sty FNCNAM+1
.ifdef CONFIG_2
sty FNCNAM ; GC bugfix!
.endif
lda STREND
ldx STREND+1
sta LOWTR
stx LOWTR+1
lda #TEMPST
ldx #$00
sta INDEX
stx INDEX+1
L333D:
cmp TEMPPT
beq L3346
jsr CHECK_VARIABLE
beq L333D
L3346:
lda #BYTES_PER_VARIABLE
sta DSCLEN
lda VARTAB
ldx VARTAB+1
sta INDEX
stx INDEX+1
L3352:
cpx ARYTAB+1
bne L335A
cmp ARYTAB
beq L335F
L335A:
jsr CHECK_SIMPLE_VARIABLE
beq L3352
L335F:
sta HIGHDS
stx HIGHDS+1
lda #$03 ; OSI GC bugfix -> $04 ???
sta DSCLEN
L3367:
lda HIGHDS
ldx HIGHDS+1
L336B:
cpx STREND+1
bne L3376
cmp STREND
bne L3376
jmp MOVE_HIGHEST_STRING_TO_TOP
L3376:
sta INDEX
stx INDEX+1
.ifdef CONFIG_SMALL
ldy #$01
.else
ldy #$00
lda (INDEX),y
tax
iny
.endif
lda (INDEX),y
php
iny
lda (INDEX),y
adc HIGHDS
sta HIGHDS
iny
lda (INDEX),y
adc HIGHDS+1
sta HIGHDS+1
plp
bpl L3367
.ifndef CONFIG_SMALL
txa
bmi L3367
.endif
iny
lda (INDEX),y
.ifdef CONFIG_CBM1_PATCHES
jsr LE7F3 ; XXX patch, call into screen editor
.else
.ifdef CONFIG_11
ldy #$00 ; GC bugfix
.endif
asl a
adc #$05
.endif
adc INDEX
sta INDEX
bcc L33A7
inc INDEX+1
L33A7:
ldx INDEX+1
L33A9:
cpx HIGHDS+1
bne L33B1
cmp HIGHDS
beq L336B
L33B1:
jsr CHECK_VARIABLE
beq L33A9
; ----------------------------------------------------------------------------
; PROCESS A SIMPLE VARIABLE
; ----------------------------------------------------------------------------
CHECK_SIMPLE_VARIABLE:
.ifndef CONFIG_SMALL
lda (INDEX),y
bmi CHECK_BUMP
.endif
iny
lda (INDEX),y
bpl CHECK_BUMP
iny
; ----------------------------------------------------------------------------
; IF STRING IS NOT EMPTY, CHECK IF IT IS HIGHEST
; ----------------------------------------------------------------------------
CHECK_VARIABLE:
lda (INDEX),y
beq CHECK_BUMP
iny
lda (INDEX),y
tax
iny
lda (INDEX),y
cmp FRETOP+1
bcc L33D5
bne CHECK_BUMP
cpx FRETOP
bcs CHECK_BUMP
L33D5:
cmp LOWTR+1
bcc CHECK_BUMP
bne L33DF
cpx LOWTR
bcc CHECK_BUMP
L33DF:
stx LOWTR
sta LOWTR+1
lda INDEX
ldx INDEX+1
sta FNCNAM
stx FNCNAM+1
lda DSCLEN
sta Z52
; ----------------------------------------------------------------------------
; ADD (DSCLEN) TO PNTR IN INDEX
; RETURN WITH Y=0, PNTR ALSO IN X,A
; ----------------------------------------------------------------------------
CHECK_BUMP:
lda DSCLEN
clc
adc INDEX
sta INDEX
bcc L33FA
inc INDEX+1
L33FA:
ldx INDEX+1
ldy #$00
rts
; ----------------------------------------------------------------------------
; FOUND HIGHEST NON-EMPTY STRING, SO MOVE IT
; TO TOP AND GO BACK FOR ANOTHER
; ----------------------------------------------------------------------------
MOVE_HIGHEST_STRING_TO_TOP:
.ifdef CONFIG_2
lda FNCNAM+1 ; GC bugfix
ora FNCNAM
.else
ldx FNCNAM+1
.endif
beq L33FA
lda Z52
.ifndef CONFIG_10A
sbc #$03
.else
and #$04
.endif
lsr a
tay
sta Z52
lda (FNCNAM),y
adc LOWTR
sta HIGHTR
lda LOWTR+1
adc #$00
sta HIGHTR+1
lda FRETOP
ldx FRETOP+1
sta HIGHDS
stx HIGHDS+1
jsr BLTU2
ldy Z52
iny
lda HIGHDS
sta (FNCNAM),y
tax
inc HIGHDS+1
lda HIGHDS+1
iny
sta (FNCNAM),y
jmp FINDHIGHESTSTRING
; ----------------------------------------------------------------------------
; CONCATENATE TWO STRINGS
; ----------------------------------------------------------------------------
CAT:
lda FAC_LAST
pha
lda FAC_LAST-1
pha
jsr FRM_ELEMENT
jsr CHKSTR
pla
sta STRNG1
pla
sta STRNG1+1
ldy #$00
lda (STRNG1),y
clc
adc (FAC_LAST-1),y
bcc L3454
ldx #ERR_STRLONG
jmp ERROR
L3454:
jsr STRINI
jsr MOVINS
lda DSCPTR
ldy DSCPTR+1
jsr FRETMP
jsr MOVSTR1
lda STRNG1
ldy STRNG1+1
jsr FRETMP
jsr PUTNEW
jmp FRMEVL2
; ----------------------------------------------------------------------------
; GET STRING DESCRIPTOR POINTED AT BY (STRNG1)
; AND MOVE DESCRIBED STRING TO (FRESPC)
; ----------------------------------------------------------------------------
MOVINS:
ldy #$00
lda (STRNG1),y
pha
iny
lda (STRNG1),y
tax
iny
lda (STRNG1),y
tay
pla
; ----------------------------------------------------------------------------
; MOVE STRING AT (Y,X) WITH LENGTH (A)
; TO DESTINATION WHOSE ADDRESS IS IN FRESPC,FRESPC+1
; ----------------------------------------------------------------------------
MOVSTR:
stx INDEX
sty INDEX+1
MOVSTR1:
tay
beq L3490
pha
L3487:
dey
lda (INDEX),y
sta (FRESPC),y
tya
bne L3487
pla
L3490:
clc
adc FRESPC
sta FRESPC
bcc L3499
inc FRESPC+1
L3499:
rts
; ----------------------------------------------------------------------------
; IF (FAC) IS A TEMPORARY STRING, RELEASE DESCRIPTOR
; ----------------------------------------------------------------------------
FRESTR:
jsr CHKSTR
; ----------------------------------------------------------------------------
; IF STRING DESCRIPTOR POINTED TO BY FAC+3,4 IS
; A TEMPORARY STRING, RELEASE IT.
; ----------------------------------------------------------------------------
FREFAC:
lda FAC_LAST-1
ldy FAC_LAST
; ----------------------------------------------------------------------------
; IF STRING DESCRIPTOR WHOSE ADDRESS IS IN Y,A IS
; A TEMPORARY STRING, RELEASE IT.
; ----------------------------------------------------------------------------
FRETMP:
sta INDEX
sty INDEX+1
jsr FRETMS
php
ldy #$00
lda (INDEX),y
pha
iny
lda (INDEX),y
tax
iny
lda (INDEX),y
tay
pla
plp
bne L34CD
cpy FRETOP+1
bne L34CD
cpx FRETOP
bne L34CD
pha
clc
adc FRETOP
sta FRETOP
bcc L34CC
inc FRETOP+1
L34CC:
pla
L34CD:
stx INDEX
sty INDEX+1
rts
; ----------------------------------------------------------------------------
; RELEASE TEMPORARY DESCRIPTOR IF Y,A = LASTPT
; ----------------------------------------------------------------------------
FRETMS:
.ifdef KBD
cpy #$00
.else
cpy LASTPT+1
.endif
bne L34E2
cmp LASTPT
bne L34E2
sta TEMPPT
sbc #$03
sta LASTPT
ldy #$00
L34E2:
rts
; ----------------------------------------------------------------------------
; "CHR$" FUNCTION
; ----------------------------------------------------------------------------
CHRSTR:
jsr CONINT
txa
pha
lda #$01
jsr STRSPA
pla
ldy #$00
sta (FAC+1),y
pla
pla
jmp PUTNEW
; ----------------------------------------------------------------------------
; "LEFT$" FUNCTION
; ----------------------------------------------------------------------------
LEFTSTR:
jsr SUBSTRING_SETUP
cmp (DSCPTR),y
tya
SUBSTRING1:
bcc L3503
lda (DSCPTR),y
tax
tya
L3503:
pha
SUBSTRING2:
txa
SUBSTRING3:
pha
jsr STRSPA
lda DSCPTR
ldy DSCPTR+1
jsr FRETMP
pla
tay
pla
clc
adc INDEX
sta INDEX
bcc L351C
inc INDEX+1
L351C:
tya
jsr MOVSTR1
jmp PUTNEW
; ----------------------------------------------------------------------------
; "RIGHT$" FUNCTION
; ----------------------------------------------------------------------------
RIGHTSTR:
jsr SUBSTRING_SETUP
clc
sbc (DSCPTR),y
eor #$FF
jmp SUBSTRING1
; ----------------------------------------------------------------------------
; "MID$" FUNCTION
; ----------------------------------------------------------------------------
MIDSTR:
lda #$FF
sta FAC_LAST
jsr CHRGOT
cmp #$29
beq L353F
jsr CHKCOM
jsr GETBYT
L353F:
jsr SUBSTRING_SETUP
.ifdef CONFIG_2
beq GOIQ
.endif
dex
txa
pha
clc
ldx #$00
sbc (DSCPTR),y
bcs SUBSTRING2
eor #$FF
cmp FAC_LAST
bcc SUBSTRING3
lda FAC_LAST
bcs SUBSTRING3
; ----------------------------------------------------------------------------
; COMMON SETUP ROUTINE FOR LEFT$, RIGHT$, MID$:
; REQUIRE ")"; POP RETURN ADRS, GET DESCRIPTOR
; ADDRESS, GET 1ST PARAMETER OF COMMAND
; ----------------------------------------------------------------------------
SUBSTRING_SETUP:
jsr CHKCLS
pla
.ifndef CONFIG_11
sta JMPADRS+1
pla
sta JMPADRS+2
.else
tay
pla
sta Z52
.endif
pla
pla
pla
tax
pla
sta DSCPTR
pla
sta DSCPTR+1
.ifdef CONFIG_11
lda Z52
pha
tya
pha
.endif
ldy #$00
txa
.ifndef CONFIG_2
beq GOIQ
.endif
.ifndef CONFIG_11
inc JMPADRS+1
jmp (JMPADRS+1)
.else
rts
.endif
; ----------------------------------------------------------------------------
; "LEN" FUNCTION
; ----------------------------------------------------------------------------
LEN:
jsr GETSTR
SNGFLT1:
jmp SNGFLT
; ----------------------------------------------------------------------------
; IF LAST RESULT IS A TEMPORARY STRING, FREE IT
; MAKE VALTYP NUMERIC, RETURN LENGTH IN Y-REG
; ----------------------------------------------------------------------------
GETSTR:
jsr FRESTR
ldx #$00
stx VALTYP
tay
rts
; ----------------------------------------------------------------------------
; "ASC" FUNCTION
; ----------------------------------------------------------------------------
ASC:
jsr GETSTR
beq GOIQ
ldy #$00
lda (INDEX),y
tay
.ifndef CONFIG_11A
jmp SNGFLT1
.else
jmp SNGFLT
.endif
; ----------------------------------------------------------------------------
GOIQ:
jmp IQERR
; ----------------------------------------------------------------------------
; SCAN TO NEXT CHARACTER AND CONVERT EXPRESSION
; TO SINGLE BYTE IN X-REG
; ----------------------------------------------------------------------------
GTBYTC:
jsr CHRGET
; ----------------------------------------------------------------------------
; EVALUATE EXPRESSION AT TXTPTR, AND
; CONVERT IT TO SINGLE BYTE IN X-REG
; ----------------------------------------------------------------------------
GETBYT:
jsr FRMNUM
; ----------------------------------------------------------------------------
; CONVERT (FAC) TO SINGLE BYTE INTEGER IN X-REG
; ----------------------------------------------------------------------------
CONINT:
jsr MKINT
ldx FAC_LAST-1
bne GOIQ
ldx FAC_LAST
jmp CHRGOT
; ----------------------------------------------------------------------------
; "VAL" FUNCTION
; ----------------------------------------------------------------------------
VAL:
jsr GETSTR
bne L35AC
jmp ZERO_FAC
L35AC:
ldx TXTPTR
ldy TXTPTR+1
stx STRNG2
sty STRNG2+1
ldx INDEX
stx TXTPTR
clc
adc INDEX
sta DEST
ldx INDEX+1
stx TXTPTR+1
bcc L35C4
inx
L35C4:
stx DEST+1
ldy #$00
lda (DEST),y
pha
lda #$00
sta (DEST),y
jsr CHRGOT
jsr FIN
pla
ldy #$00
sta (DEST),y
; ----------------------------------------------------------------------------
; COPY STRNG2 INTO TXTPTR
; ----------------------------------------------------------------------------
POINT:
ldx STRNG2
ldy STRNG2+1
stx TXTPTR
sty TXTPTR+1
rts
|
6502-retro/6502-retro-os
| 11,296
|
apps/msbasic/init.s
|
.segment "INIT"
.ifdef KBD
FNDLIN2:
php
jmp FNDLIN
.endif
; ----------------------------------------------------------------------------
PR_WRITTEN_BY:
.ifndef KBD
.ifndef CONFIG_CBM_ALL
.ifndef AIM65
.ifndef SYM1
lda #<QT_WRITTEN_BY
ldy #>QT_WRITTEN_BY
jsr STROUT
.endif
.endif
.endif
.endif
COLD_START:
.ifdef SYM1
jsr ACCESS
.endif
.ifdef KBD
lda #<LFD81
sta $03A0
lda #>LFD81
sta $03A1
lda #$20
sta $0480
lda $0352
sta $04
lda $0353
sta $05
.else
.ifndef CBM2
ldx #$FF
stx CURLIN+1
.endif
.ifdef CONFIG_NO_INPUTBUFFER_ZP
ldx #$FB
.elseif .def(AIM65)
ldx #$FE
.endif
txs
.ifndef CONFIG_CBM_ALL
lda #<COLD_START
ldy #>COLD_START
sta GORESTART+1
sty GORESTART+2
.ifndef AIM65
sta GOSTROUT+1
sty GOSTROUT+2
lda #<AYINT
ldy #>AYINT
sta GOAYINT
sty GOAYINT+1
lda #<GIVAYF
ldy #>GIVAYF
sta GOGIVEAYF
sty GOGIVEAYF+1
.endif
.endif
lda #$4C
.ifdef CONFIG_CBM_ALL
sta JMPADRS
.endif
sta GORESTART
.ifdef AIM65
sta JMPADRS
sta ATN
sta GOSTROUT
.else
.ifndef CONFIG_CBM_ALL
sta GOSTROUT
sta JMPADRS
.endif
.ifdef SYM1
sta USR1
sta USR3
sta USR2
.endif
.if (!.def(CONFIG_RAM)) && (!.def(CONFIG_CBM_ALL))
sta USR
.endif
.endif
.ifndef CONFIG_RAM
.ifdef APPLE
lda #<USR_FUNC
ldy #>USR_FUNC
.else
lda #<IQERR
ldy #>IQERR
.endif
.ifdef AIM65
sta ATN+1
sty ATN+2
sta GOSTROUT+1
sty GOSTROUT+2
.else
sta USR+1
sty USR+2
.ifdef SYM1
sta USR1+1
sty USR1+2
lda #<DUMPT
ldy #>DUMPT
sta USR2+1
sty USR2+2
lda #<L8C78
ldy #>L8C78
sta USR3+1
sty USR3+2
.endif
.endif
.endif
.ifndef CBM1
lda #WIDTH
sta Z17
lda #WIDTH2
sta Z18
.endif
.endif
; All non-CONFIG_SMALL versions of BASIC have
; the same bug here: While the number of bytes
; to be copied is correct for CONFIG_SMALL,
; it is one byte short on non-CONFIG_SMALL:
; It seems the "ldx" value below has been
; hardcoded. So on these configurations,
; the last byte of GENERIC_RNDSEED, which
; is 5 bytes instead of 4, does not get copied -
; which is nothing major, because it is just
; the least significant 8 bits of the mantissa
; of the random number seed.
; KBD added three bytes to CHRGET and removed
; the random number seed, but only adjusted
; the number of bytes by adding 3 - this
; copies four bytes too many, which is no
; problem.
.ifdef CONFIG_SMALL
.ifdef KBD
ldx #GENERIC_CHRGET_END-GENERIC_CHRGET+4
.else
ldx #GENERIC_CHRGET_END-GENERIC_CHRGET
.endif
.else
ldx #GENERIC_CHRGET_END-GENERIC_CHRGET-1 ; XXX
.endif
L4098:
lda GENERIC_CHRGET-1,x
sta CHRGET-1,x
dex
bne L4098
.ifdef CONFIG_2
lda #$03
sta DSCLEN
.endif
.ifndef KBD
txa
sta SHIFTSIGNEXT
.ifdef CONFIG_CBM_ALL
sta CURDVC
.endif
sta LASTPT+1
.ifndef AIM65
.if .defined(CONFIG_NULL) || .defined(CONFIG_PRINTNULLS)
sta Z15
.endif
.endif
.ifndef CONFIG_11
sta POSX
.endif
pha
sta Z14
.ifndef CBM2
.ifndef AIM65
.ifndef SYM1
.ifndef MICROTAN
lda #$03
sta DSCLEN
.endif
.endif
.endif
.ifndef CONFIG_11
lda #$2C
sta LINNUM+1
.endif
jsr CRDO
.endif
.ifdef CBM2
inx
stx INPUTBUFFER-3
stx INPUTBUFFER-4
.endif
.ifdef APPLE
lda #$01
sta INPUTBUFFER-3
sta INPUTBUFFER-4
.endif
ldx #TEMPST
stx TEMPPT
.ifndef CONFIG_CBM_ALL
lda #<QT_MEMORY_SIZE
ldy #>QT_MEMORY_SIZE
jsr STROUT
.ifdef APPLE
jsr INLINX
.else
jsr NXIN
.endif
stx TXTPTR
sty TXTPTR+1
jsr CHRGET
.ifndef AIM65
.ifndef SYM1
cmp #$41
beq PR_WRITTEN_BY
.endif
.endif
tay
bne L40EE
.endif
.ifndef CBM2
lda #<RAMSTART2
.endif
ldy #>RAMSTART2
.ifdef CONFIG_2
sta TXTTAB
sty TXTTAB+1
.endif
sta LINNUM
sty LINNUM+1
.ifdef CBM2
tay
.else
ldy #$00
.endif
L40D7:
inc LINNUM
bne L40DD
inc LINNUM+1
.ifdef CBM1
; CBM: hard RAM top limit is $8000
lda LINNUM+1
cmp #$80
beq L40FA
.endif
.ifdef CBM2
; optimized version of the CBM1 code
bmi L40FA
.endif
.if .def(AIM65)
; AIM65: hard RAM top limit is $A000
lda LINNUM+1
cmp #$A0
beq L40FA
.endif
L40DD:
.ifdef CONFIG_2
lda #$55 ; 01010101 / 10101010
.else
lda #$92 ; 10010010 / 00100100
.endif
sta (LINNUM),y
cmp (LINNUM),y
bne L40FA
asl a
sta (LINNUM),y
cmp (LINNUM),y
.ifdef CONFIG_CBM_ALL
beq L40D7
.else
.ifndef CONFIG_11
beq L40D7; old: faster
bne L40FA
.else
bne L40FA; new: slower
beq L40D7
.endif
L40EE:
jsr CHRGOT
jsr LINGET
tay
beq L40FA
jmp SYNERR
.endif
L40FA:
lda LINNUM
ldy LINNUM+1
sta MEMSIZ
sty MEMSIZ+1
.if !(.def(MICROTAN) || .def(AIM65) || .def(SYM1))
sta FRETOP
sty FRETOP+1
.endif
L4106:
.ifndef CONFIG_CBM_ALL
.ifdef APPLE
lda #$FF
jmp L2829
.word STROUT ; PATCH!
jsr NXIN
.else
lda #<QT_TERMINAL_WIDTH
ldy #>QT_TERMINAL_WIDTH
jsr STROUT
jsr NXIN
.endif
stx TXTPTR
sty TXTPTR+1
jsr CHRGET
tay
beq L4136
jsr LINGET
lda LINNUM+1
bne L4106
lda LINNUM
cmp #$10
bcc L4106
L2829:
sta Z17
L4129:
.ifdef AIM65
sbc #$0A
.else
sbc #$0E
.endif
bcs L4129
eor #$FF
.ifdef AIM65
sbc #$08
.else
sbc #$0C
.endif
clc
adc Z17
sta Z18
.endif
L4136:
.ifdef CONFIG_RAM
lda #<QT_WANT
ldy #>QT_WANT
jsr STROUT
jsr NXIN
stx TXTPTR
sty TXTPTR+1
jsr CHRGET
ldx #<RAMSTART1
ldy #>RAMSTART1
cmp #'Y'
beq L4183
cmp #'A'
beq L4157
cmp #'N'
bne L4136
L4157:
ldx #<IQERR
ldy #>IQERR
stx UNFNC_ATN
sty UNFNC_ATN+1
ldx #<ATN ; overwrite starting
ldy #>ATN ; with ATN
cmp #'A'
beq L4183
ldx #<IQERR
ldy #>IQERR
stx UNFNC_COS
sty UNFNC_COS+1
stx UNFNC_TAN
sty UNFNC_TAN+1
stx UNFNC_SIN
sty UNFNC_SIN+1
ldx #<SIN_COS_TAN_ATN ; overwrite
ldy #>SIN_COS_TAN_ATN ; all of trig.s
L4183:
.else
ldx #<RAMSTART2
ldy #>RAMSTART2
.endif
stx TXTTAB
sty TXTTAB+1
ldy #$00
tya
sta (TXTTAB),y
inc TXTTAB
.ifndef CBM2
bne L4192
inc TXTTAB+1
L4192:
.endif
.if CONFIG_SCRTCH_ORDER = 1
jsr SCRTCH
.endif
lda TXTTAB
ldy TXTTAB+1
jsr REASON
.ifdef CBM2
lda #<QT_BASIC
ldy #>QT_BASIC
jsr STROUT
.else
jsr CRDO
.endif
lda MEMSIZ
sec
sbc TXTTAB
tax
lda MEMSIZ+1
sbc TXTTAB+1
jsr LINPRT
lda #<QT_BYTES_FREE
ldy #>QT_BYTES_FREE
jsr STROUT
.if CONFIG_SCRTCH_ORDER = 2
jsr SCRTCH
.endif
.ifdef CONFIG_CBM_ALL
jmp RESTART
.elseif .def(AIM65)
lda #<CRDO
ldy #>CRDO
sta GORESTART+1
sty GORESTART+2
jmp RESTART
.else
lda #<STROUT
ldy #>STROUT
sta GOSTROUT+1
sty GOSTROUT+2
.if CONFIG_SCRTCH_ORDER = 3
jsr SCRTCH
.endif
lda #<RESTART
ldy #>RESTART
sta GORESTART+1
sty GORESTART+2
jmp (GORESTART+1)
.endif
.if .def(CONFIG_RAM) || .def(OSI)
; OSI is compiled for ROM, but includes
; this unused string
QT_WANT:
.byte "WANT SIN-COS-TAN-ATN"
.byte 0
.endif
QT_WRITTEN_BY:
.ifndef CONFIG_CBM_ALL
.if !(.def(AIM65) || .def(SYM1))
.ifdef APPLE
asc80 "COPYRIGHT 1977 BY MICROSOFT CO"
.byte CR,0
.else
.byte CR,LF,$0C ; FORM FEED
.ifndef CONFIG_11
.byte "WRITTEN BY RICHARD W. WEILAND."
.else
.byte "WRITTEN BY WEILAND & GATES"
.endif
.byte CR,LF,0
.endif
.endif
QT_MEMORY_SIZE:
.byte "MEMORY SIZE"
.byte 0
QT_TERMINAL_WIDTH:
.if !(.def(AIM65) || .def(SYM1))
.byte "TERMINAL "
.endif
.byte "WIDTH"
.byte 0
.endif
QT_BYTES_FREE:
.byte " BYTES FREE"
.ifdef CBM1
.elseif .def(CBM2)
.byte CR,0
.elseif .def(APPLE)
.byte 0
.else
.byte CR,LF,CR,LF
.endif
QT_BASIC:
.ifdef OSI
.byte "OSI 6502 BASIC VERSION 1.0 REV 3.2"
.endif
.ifdef KIM
.byte "MOS TECH 6502 BASIC V1.1"
.endif
.ifdef MICROTAN
.byte "MICROTAN BASIC"
.endif
.ifdef AIM65
.byte " AIM 65 BASIC V1.1"
.endif
.ifdef SYM1
.byte "BASIC V1.1"
.endif
.ifdef CBM1
.byte $13 ; HOME
.byte "*** COMMODORE BASIC ***"
.byte $11,$11,$11,0 ; DOWN/DOWN/DOWN
.endif
.ifdef CBM2
.byte "### COMMODORE BASIC ###"
.byte CR,CR,0
.endif
.ifdef APPLE
.byte LF,CR,LF
.byte "APPLE BASIC V1.1"
.endif
.ifndef CONFIG_CBM_ALL
.byte CR,LF
.ifdef MICROTAN
.byte "(C) 1980 MICROSOFT"
.elseif .def(AIM65)
.byte 0
.byte "(C) 1978 MICROSOFT"
.elseif .def(SYM1)
.byte "COPYRIGHT 1978 SYNERTEK SYSTEMS CORP."
.else
.byte "COPYRIGHT 1977 BY MICROSOFT CO."
.endif
.byte CR,LF
.ifndef AIM65
.byte 0
.endif
.endif
.endif
|
6502-retro/6502-retro-os
| 3,519
|
apps/msbasic/memory.s
|
; generic stack and memory management code
; this code is identical across all versions of
; BASIC
.segment "CODE"
; ----------------------------------------------------------------------------
; CALLED BY "NEXT" AND "FOR" TO SCAN THROUGH
; THE STACK FOR A FRAME WITH THE SAME VARIABLE.
;
; (FORPNT) = ADDRESS OF VARIABLE IF "FOR" OR "NEXT"
; = $XXFF IF CALLED FROM "RETURN"
; <<< BUG: SHOULD BE $FFXX >>>
;
; RETURNS .NE. IF VARIABLE NOT FOUND,
; (X) = STACK PNTR AFTER SKIPPING ALL FRAMES
;
; .EQ. IF FOUND
; (X) = STACK PNTR OF FRAME FOUND
; ----------------------------------------------------------------------------
GTFORPNT:
tsx
inx
inx
inx
inx
L2279:
lda STACK+1,x
cmp #$81
bne L22A1
lda FORPNT+1
bne L228E
lda STACK+2,x
sta FORPNT
lda STACK+3,x
sta FORPNT+1
L228E:
cmp STACK+3,x
bne L229A
lda FORPNT
cmp STACK+2,x
beq L22A1
L229A:
txa
clc
adc #BYTES_PER_FRAME
tax
bne L2279
L22A1:
rts
; ----------------------------------------------------------------------------
; MOVE BLOCK OF MEMORY UP
;
; ON ENTRY:
; (Y,A) = (HIGHDS) = DESTINATION END+1
; (LOWTR) = LOWEST ADDRESS OF SOURCE
; (HIGHTR) = HIGHEST SOURCE ADDRESS+1
; ----------------------------------------------------------------------------
BLTU:
jsr REASON
sta STREND
sty STREND+1
BLTU2:
sec
lda HIGHTR
sbc LOWTR
sta INDEX
tay
lda HIGHTR+1
sbc LOWTR+1
tax
inx
tya
beq L22DD
lda HIGHTR
sec
sbc INDEX
sta HIGHTR
bcs L22C6
dec HIGHTR+1
sec
L22C6:
lda HIGHDS
sbc INDEX
sta HIGHDS
bcs L22D6
dec HIGHDS+1
bcc L22D6
L22D2:
lda (HIGHTR),y
sta (HIGHDS),y
L22D6:
dey
bne L22D2
lda (HIGHTR),y
sta (HIGHDS),y
L22DD:
dec HIGHTR+1
dec HIGHDS+1
dex
bne L22D6
rts
; ----------------------------------------------------------------------------
; CHECK IF ENOUGH ROOM LEFT ON STACK
; FOR "FOR", "GOSUB", OR EXPRESSION EVALUATION
; ----------------------------------------------------------------------------
CHKMEM:
asl a
adc #SPACE_FOR_GOSUB
bcs MEMERR
sta INDEX
tsx
cpx INDEX
bcc MEMERR
rts
; ----------------------------------------------------------------------------
; CHECK IF ENOUGH ROOM BETWEEN ARRAYS AND STRINGS
; (Y,A) = ADDR ARRAYS NEED TO GROW TO
; ----------------------------------------------------------------------------
REASON:
cpy FRETOP+1
bcc L231E
bne L22FC
cmp FRETOP
bcc L231E
L22FC:
pha
ldx #FAC-TEMP1-1
tya
L2300:
pha
lda TEMP1,x
dex
bpl L2300
jsr GARBAG
ldx #TEMP1-FAC+1
L230B:
pla
sta FAC,x
inx
bmi L230B
pla
tay
pla
cpy FRETOP+1
bcc L231E
bne MEMERR
cmp FRETOP
bcs MEMERR
L231E:
rts
|
6502-retro/6502-retro-os
| 1,061
|
apps/msbasic/defines_cbm2.s
|
; configuration
CONFIG_2A := 1
CONFIG_CBM_ALL := 1
CONFIG_DATAFLG := 1
CONFIG_EASTER_EGG := 1
CONFIG_FILE := 1; support PRINT#, INPUT#, GET#, CMD
CONFIG_NO_CR := 1; terminal doesn't need explicit CRs on line ends
CONFIG_NO_LINE_EDITING := 1; support for "@", "_", BEL etc.
CONFIG_NO_READ_Y_IS_ZERO_HACK := 1
CONFIG_PEEK_SAVE_LINNUM := 1
CONFIG_SCRTCH_ORDER := 2
; zero page
ZP_START1 = $00
ZP_START2 = $0D
ZP_START3 = $03
ZP_START4 = $13
; extra/override ZP variables
CURDVC := $000E
TISTR := $008D
Z96 := $0096
POSX := $00C6
TXPSV := LASTOP
USR := GORESTART ; XXX
; inputbuffer
INPUTBUFFER := $0200
; constants
SPACE_FOR_GOSUB := $3E
STACK_TOP := $FA
WIDTH := 40
WIDTH2 := 30
RAMSTART2 := $0400
; magic memory locations
ENTROPY = $E844
; monitor functions
OPEN := $FFC0
CLOSE := $FFC3
CHKIN := $FFC6
CHKOUT := $FFC9
CLRCH := $FFCC
CHRIN := $FFCF
CHROUT := $FFD2
LOAD := $FFD5
SAVE := $FFD8
VERIFY := $FFDB
SYS := $FFDE
ISCNTC := $FFE1
GETIN := $FFE4
CLALL := $FFE7
LE7F3 := $E7F3; for CBM1
MONCOUT := CHROUT
MONRDKEY := GETIN
|
6502-retro/6502-retro-os
| 5,011
|
apps/msbasic/misc1.s
|
.segment "CODE"
; ----------------------------------------------------------------------------
; CONVERT LINE NUMBER
; ----------------------------------------------------------------------------
LINGET:
ldx #$00
stx LINNUM
stx LINNUM+1
L28BE:
bcs L28B7
sbc #$2F
sta CHARAC
lda LINNUM+1
sta INDEX
cmp #$19
bcs L28A0
; <<<<<DANGEROUS CODE>>>>>
; NOTE THAT IF (A) = $AB ON THE LINE ABOVE,
; ON.1 WILL COMPARE = AND CAUSE A CATASTROPHIC
; JUMP TO $22D9 (FOR GOTO), OR OTHER LOCATIONS
; FOR OTHER CALLS TO LINGET.
;
; YOU CAN SEE THIS IS YOU FIRST PUT "BRK" IN $22D9,
; THEN TYPE "GO TO 437761".
;
; ANY VALUE FROM 437760 THROUGH 440319 WILL CAUSE
; THE PROBLEM. ($AB00 - $ABFF)
; <<<<<DANGEROUS CODE>>>>>
lda LINNUM
asl a
rol INDEX
asl a
rol INDEX
adc LINNUM
sta LINNUM
lda INDEX
adc LINNUM+1
sta LINNUM+1
asl LINNUM
rol LINNUM+1
lda LINNUM
adc CHARAC
sta LINNUM
bcc L28EC
inc LINNUM+1
L28EC:
jsr CHRGET
jmp L28BE
; ----------------------------------------------------------------------------
; "LET" STATEMENT
;
; LET <VAR> = <EXP>
; <VAR> = <EXP>
; ----------------------------------------------------------------------------
LET:
jsr PTRGET
sta FORPNT
sty FORPNT+1
lda #TOKEN_EQUAL
jsr SYNCHR
.ifndef CONFIG_SMALL
lda VALTYP+1
pha
.endif
lda VALTYP
pha
jsr FRMEVL
pla
rol a
jsr CHKVAL
bne LETSTRING
.ifndef CONFIG_SMALL
pla
LET2:
bpl L2923
jsr ROUND_FAC
jsr AYINT
ldy #$00
lda FAC+3
sta (FORPNT),y
iny
lda FAC+4
sta (FORPNT),y
rts
L2923:
.endif
; ----------------------------------------------------------------------------
; REAL VARIABLE = EXPRESSION
; ----------------------------------------------------------------------------
jmp SETFOR
LETSTRING:
.ifndef CONFIG_SMALL
pla
.endif
; ----------------------------------------------------------------------------
; INSTALL STRING, DESCRIPTOR ADDRESS IS AT FAC+3,4
; ----------------------------------------------------------------------------
PUTSTR:
.ifdef CONFIG_CBM_ALL
ldy FORPNT+1
.ifdef CBM1
cpy #$D0 ; TI$
.else
cpy #$DE
.endif
bne LC92B
jsr FREFAC
cmp #$06
.ifdef CBM2
bne IQERR1
.else
jne IQERR
.endif
ldy #$00
sty FAC
sty FACSIGN
LC8E8:
sty STRNG2
jsr LC91C
jsr MUL10
inc STRNG2
ldy STRNG2
jsr LC91C
jsr COPY_FAC_TO_ARG_ROUNDED
tax
beq LC902
inx
txa
jsr LD9BF
LC902:
ldy STRNG2
iny
cpy #$06
bne LC8E8
jsr MUL10
jsr QINT
ldx #$02
sei
LC912:
lda FAC+2,x
sta TISTR,x
dex
bpl LC912
cli
rts
LC91C:
lda (INDEX),y
jsr CHRGOT2
bcc LC926
IQERR1:
jmp IQERR
LC926:
sbc #$2F
jmp ADDACC
LC92B:
.endif
ldy #$02
lda (FAC_LAST-1),y
cmp FRETOP+1
bcc L2946
bne L2938
dey
lda (FAC_LAST-1),y
cmp FRETOP
bcc L2946
L2938:
ldy FAC_LAST
cpy VARTAB+1
bcc L2946
bne L294D
lda FAC_LAST-1
cmp VARTAB
bcs L294D
L2946:
lda FAC_LAST-1
ldy FAC_LAST
jmp L2963
L294D:
ldy #$00
lda (FAC_LAST-1),y
jsr STRINI
lda DSCPTR
ldy DSCPTR+1
sta STRNG1
sty STRNG1+1
jsr MOVINS
lda #FAC
ldy #$00
L2963:
sta DSCPTR
sty DSCPTR+1
jsr FRETMS
ldy #$00
lda (DSCPTR),y
sta (FORPNT),y
iny
lda (DSCPTR),y
sta (FORPNT),y
iny
lda (DSCPTR),y
sta (FORPNT),y
RET5:
rts
.ifdef AIM65
LB89D:
cmp #$21
bne RET5
lda #$80
sta PRIFLG
jmp CHRGET
.endif
.ifdef CONFIG_FILE
PRINTH:
jsr CMD
jmp LCAD6
CMD:
jsr GETBYT
beq LC98F
lda #$2C
jsr SYNCHR
LC98F:
php
jsr CHKOUT
stx CURDVC
plp
jmp PRINT
.endif
|
6502-retro/6502-retro-os
| 45,699
|
apps/msbasic/float.s
|
.segment "CODE"
TEMP1X = TEMP1+(5-BYTES_FP)
; ----------------------------------------------------------------------------
; ADD 0.5 TO FAC
; ----------------------------------------------------------------------------
FADDH:
lda #<CON_HALF
ldy #>CON_HALF
jmp FADD
; ----------------------------------------------------------------------------
; FAC = (Y,A) - FAC
; ----------------------------------------------------------------------------
FSUB:
jsr LOAD_ARG_FROM_YA
; ----------------------------------------------------------------------------
; FAC = ARG - FAC
; ----------------------------------------------------------------------------
FSUBT:
lda FACSIGN
eor #$FF
sta FACSIGN
eor ARGSIGN
sta SGNCPR
lda FAC
jmp FADDT
; ----------------------------------------------------------------------------
; Commodore BASIC V2 Easter Egg
; ----------------------------------------------------------------------------
.ifdef CONFIG_EASTER_EGG
EASTER_EGG:
lda LINNUM
cmp #<6502
bne L3628
lda LINNUM+1
sbc #>6502
bne L3628
sta LINNUM
tay
lda #$80
sta LINNUM+1
LD758:
ldx #$0A
LD75A:
lda MICROSOFT-1,x
and #$3F
sta (LINNUM),y
iny
bne LD766
inc LINNUM+1
LD766:
dex
bne LD75A
dec FORPNT
bne LD758
rts
.endif
; ----------------------------------------------------------------------------
; SHIFT SMALLER ARGUMENT MORE THAN 7 BITS
; ----------------------------------------------------------------------------
FADD1:
jsr SHIFT_RIGHT
bcc FADD3
; ----------------------------------------------------------------------------
; FAC = (Y,A) + FAC
; ----------------------------------------------------------------------------
FADD:
jsr LOAD_ARG_FROM_YA
; ----------------------------------------------------------------------------
; FAC = ARG + FAC
; ----------------------------------------------------------------------------
FADDT:
bne L365B
jmp COPY_ARG_TO_FAC
L365B:
ldx FACEXTENSION
stx ARGEXTENSION
ldx #ARG
lda ARG
FADD2:
tay
.ifdef KBD
beq RTS4
.else
beq RTS3
.endif
sec
sbc FAC
beq FADD3
bcc L367F
sty FAC
ldy ARGSIGN
sty FACSIGN
eor #$FF
adc #$00
ldy #$00
sty ARGEXTENSION
ldx #FAC
bne L3683
L367F:
ldy #$00
sty FACEXTENSION
L3683:
cmp #$F9
bmi FADD1
tay
lda FACEXTENSION
lsr 1,x
jsr SHIFT_RIGHT4
FADD3:
bit SGNCPR
bpl FADD4
ldy #FAC
cpx #ARG
beq L369B
ldy #ARG
L369B:
sec
eor #$FF
adc ARGEXTENSION
sta FACEXTENSION
.ifndef CONFIG_SMALL
lda 4,y
sbc 4,x
sta FAC+4
.endif
lda 3,y
sbc 3,x
sta FAC+3
lda 2,y
sbc 2,x
sta FAC+2
lda 1,y
sbc 1,x
sta FAC+1
; ----------------------------------------------------------------------------
; NORMALIZE VALUE IN FAC
; ----------------------------------------------------------------------------
NORMALIZE_FAC1:
bcs NORMALIZE_FAC2
jsr COMPLEMENT_FAC
NORMALIZE_FAC2:
ldy #$00
tya
clc
L36C7:
ldx FAC+1
bne NORMALIZE_FAC4
ldx FAC+2
stx FAC+1
ldx FAC+3
stx FAC+2
.ifdef CONFIG_SMALL
ldx FACEXTENSION
stx FAC+3
.else
ldx FAC+4
stx FAC+3
ldx FACEXTENSION
stx FAC+4
.endif
sty FACEXTENSION
adc #$08
.ifdef CONFIG_2B
; bugfix?
; fix does not exist on AppleSoft 2
cmp #(MANTISSA_BYTES+1)*8
.else
cmp #MANTISSA_BYTES*8
.endif
bne L36C7
; ----------------------------------------------------------------------------
; SET FAC = 0
; (ONLY NECESSARY TO ZERO EXPONENT AND SIGN CELLS)
; ----------------------------------------------------------------------------
ZERO_FAC:
lda #$00
STA_IN_FAC_SIGN_AND_EXP:
sta FAC
STA_IN_FAC_SIGN:
sta FACSIGN
rts
; ----------------------------------------------------------------------------
; ADD MANTISSAS OF FAC AND ARG INTO FAC
; ----------------------------------------------------------------------------
FADD4:
adc ARGEXTENSION
sta FACEXTENSION
.ifndef CONFIG_SMALL
lda FAC+4
adc ARG+4
sta FAC+4
.endif
lda FAC+3
adc ARG+3
sta FAC+3
lda FAC+2
adc ARG+2
sta FAC+2
lda FAC+1
adc ARG+1
sta FAC+1
jmp NORMALIZE_FAC5
; ----------------------------------------------------------------------------
; FINISH NORMALIZING FAC
; ----------------------------------------------------------------------------
NORMALIZE_FAC3:
adc #$01
asl FACEXTENSION
.ifndef CONFIG_SMALL
rol FAC+4
.endif
rol FAC+3
rol FAC+2
rol FAC+1
NORMALIZE_FAC4:
bpl NORMALIZE_FAC3
sec
sbc FAC
bcs ZERO_FAC
eor #$FF
adc #$01
sta FAC
NORMALIZE_FAC5:
bcc L3764
NORMALIZE_FAC6:
inc FAC
beq OVERFLOW
.ifndef CONFIG_ROR_WORKAROUND
ror FAC+1
ror FAC+2
ror FAC+3
.ifndef CONFIG_SMALL
ror FAC+4
.endif
ror FACEXTENSION
.else
lda #$00
bcc L372E
lda #$80
L372E:
lsr FAC+1
ora FAC+1
sta FAC+1
lda #$00
bcc L373A
lda #$80
L373A:
lsr FAC+2
ora FAC+2
sta FAC+2
lda #$00
bcc L3746
lda #$80
L3746:
lsr FAC+3
ora FAC+3
sta FAC+3
lda #$00
bcc L3752
lda #$80
L3752:
lsr FAC+4
ora FAC+4
sta FAC+4
lda #$00
bcc L375E
lda #$80
L375E:
lsr FACEXTENSION
ora FACEXTENSION
sta FACEXTENSION
.endif
L3764:
rts
; ----------------------------------------------------------------------------
; 2'S COMPLEMENT OF FAC
; ----------------------------------------------------------------------------
COMPLEMENT_FAC:
lda FACSIGN
eor #$FF
sta FACSIGN
; ----------------------------------------------------------------------------
; 2'S COMPLEMENT OF FAC MANTISSA ONLY
; ----------------------------------------------------------------------------
COMPLEMENT_FAC_MANTISSA:
lda FAC+1
eor #$FF
sta FAC+1
lda FAC+2
eor #$FF
sta FAC+2
lda FAC+3
eor #$FF
sta FAC+3
.ifndef CONFIG_SMALL
lda FAC+4
eor #$FF
sta FAC+4
.endif
lda FACEXTENSION
eor #$FF
sta FACEXTENSION
inc FACEXTENSION
bne RTS12
; ----------------------------------------------------------------------------
; INCREMENT FAC MANTISSA
; ----------------------------------------------------------------------------
INCREMENT_FAC_MANTISSA:
.ifndef CONFIG_SMALL
inc FAC+4
bne RTS12
.endif
inc FAC+3
bne RTS12
inc FAC+2
bne RTS12
inc FAC+1
RTS12:
rts
OVERFLOW:
ldx #ERR_OVERFLOW
jmp ERROR
; ----------------------------------------------------------------------------
; SHIFT 1,X THRU 5,X RIGHT
; (A) = NEGATIVE OF SHIFT COUNT
; (X) = POINTER TO BYTES TO BE SHIFTED
;
; RETURN WITH (Y)=0, CARRY=0, EXTENSION BITS IN A-REG
; ----------------------------------------------------------------------------
SHIFT_RIGHT1:
ldx #RESULT-1
SHIFT_RIGHT2:
.ifdef CONFIG_SMALL
ldy 3,x
.else
ldy 4,x
.endif
sty FACEXTENSION
.ifndef CONFIG_SMALL
ldy 3,x
sty 4,x
.endif
ldy 2,x
sty 3,x
ldy 1,x
sty 2,x
ldy SHIFTSIGNEXT
sty 1,x
; ----------------------------------------------------------------------------
; MAIN ENTRY TO RIGHT SHIFT SUBROUTINE
; ----------------------------------------------------------------------------
SHIFT_RIGHT:
adc #$08
bmi SHIFT_RIGHT2
beq SHIFT_RIGHT2
sbc #$08
tay
lda FACEXTENSION
bcs SHIFT_RIGHT5
.ifndef CONFIG_ROR_WORKAROUND
LB588:
asl 1,x
bcc LB58E
inc 1,x
LB58E:
ror 1,x
ror 1,x
; ----------------------------------------------------------------------------
; ENTER HERE FOR SHORT SHIFTS WITH NO SIGN EXTENSION
; ----------------------------------------------------------------------------
SHIFT_RIGHT4:
ror 2,x
ror 3,x
.ifndef CONFIG_SMALL
ror 4,x
.endif
ror a
iny
bne LB588
.else
L37C4:
pha
lda 1,x
and #$80
lsr 1,x
ora 1,x
sta 1,x
.byte $24
SHIFT_RIGHT4:
pha
lda #$00
bcc L37D7
lda #$80
L37D7:
lsr 2,x
ora 2,x
sta 2,x
lda #$00
bcc L37E3
lda #$80
L37E3:
lsr 3,x
ora 3,x
sta 3,x
lda #$00
bcc L37EF
lda #$80
L37EF:
lsr 4,x
ora 4,x
sta 4,x
pla
php
lsr a
plp
bcc L37FD
ora #$80
L37FD:
iny
bne L37C4
.endif
SHIFT_RIGHT5:
clc
rts
; ----------------------------------------------------------------------------
.ifdef CONFIG_SMALL
CON_ONE:
.byte $81,$00,$00,$00
POLY_LOG:
.byte $02
.byte $80,$19,$56,$62
.byte $80,$76,$22,$F3
.byte $82,$38,$AA,$40
CON_SQR_HALF:
.byte $80,$35,$04,$F3
CON_SQR_TWO:
.byte $81,$35,$04,$F3
CON_NEG_HALF:
.byte $80,$80,$00,$00
CON_LOG_TWO:
.byte $80,$31,$72,$18
.else
CON_ONE:
.byte $81,$00,$00,$00,$00
POLY_LOG:
.byte $03
.byte $7F,$5E,$56,$CB,$79
.byte $80,$13,$9B,$0B,$64
.byte $80,$76,$38,$93,$16
.byte $82,$38,$AA,$3B,$20
CON_SQR_HALF:
.byte $80,$35,$04,$F3,$34
CON_SQR_TWO:
.byte $81,$35,$04,$F3,$34
CON_NEG_HALF:
.byte $80,$80,$00,$00,$00
CON_LOG_TWO:
.byte $80,$31,$72,$17,$F8
.endif
; ----------------------------------------------------------------------------
; "LOG" FUNCTION
; ----------------------------------------------------------------------------
LOG:
jsr SIGN
beq GIQ
bpl LOG2
GIQ:
jmp IQERR
LOG2:
lda FAC
sbc #$7F
pha
lda #$80
sta FAC
lda #<CON_SQR_HALF
ldy #>CON_SQR_HALF
jsr FADD
lda #<CON_SQR_TWO
ldy #>CON_SQR_TWO
jsr FDIV
lda #<CON_ONE
ldy #>CON_ONE
jsr FSUB
lda #<POLY_LOG
ldy #>POLY_LOG
jsr POLYNOMIAL_ODD
lda #<CON_NEG_HALF
ldy #>CON_NEG_HALF
jsr FADD
pla
jsr ADDACC
lda #<CON_LOG_TWO
ldy #>CON_LOG_TWO
; ----------------------------------------------------------------------------
; FAC = (Y,A) * FAC
; ----------------------------------------------------------------------------
FMULT:
jsr LOAD_ARG_FROM_YA
; ----------------------------------------------------------------------------
; FAC = ARG * FAC
; ----------------------------------------------------------------------------
FMULTT:
.ifndef CONFIG_11
beq L3903
.else
jeq L3903
.endif
jsr ADD_EXPONENTS
lda #$00
sta RESULT
sta RESULT+1
sta RESULT+2
.ifndef CONFIG_SMALL
sta RESULT+3
.endif
lda FACEXTENSION
jsr MULTIPLY1
.ifndef CONFIG_SMALL
lda FAC+4
jsr MULTIPLY1
.endif
lda FAC+3
jsr MULTIPLY1
lda FAC+2
jsr MULTIPLY1
lda FAC+1
jsr MULTIPLY2
jmp COPY_RESULT_INTO_FAC
; ----------------------------------------------------------------------------
; MULTIPLY ARG BY (A) INTO RESULT
; ----------------------------------------------------------------------------
MULTIPLY1:
bne MULTIPLY2
jmp SHIFT_RIGHT1
MULTIPLY2:
lsr a
ora #$80
L38A7:
tay
bcc L38C3
clc
.ifndef CONFIG_SMALL
lda RESULT+3
adc ARG+4
sta RESULT+3
.endif
lda RESULT+2
adc ARG+3
sta RESULT+2
lda RESULT+1
adc ARG+2
sta RESULT+1
lda RESULT
adc ARG+1
sta RESULT
L38C3:
.ifndef CONFIG_ROR_WORKAROUND
ror RESULT
ror RESULT+1
.ifdef APPLE_BAD_BYTE
; this seems to be a bad byte in the dump
.byte RESULT+2,RESULT+2 ; XXX BUG!
.else
ror RESULT+2
.endif
.ifndef CONFIG_SMALL
ror RESULT+3
.endif
ror FACEXTENSION
.else
lda #$00
bcc L38C9
lda #$80
L38C9:
lsr RESULT
ora RESULT
sta RESULT
lda #$00
bcc L38D5
lda #$80
L38D5:
lsr RESULT+1
ora RESULT+1
sta RESULT+1
lda #$00
bcc L38E1
lda #$80
L38E1:
lsr RESULT+2
ora RESULT+2
sta RESULT+2
lda #$00
bcc L38ED
lda #$80
L38ED:
lsr RESULT+3
ora RESULT+3
sta RESULT+3
lda #$00
bcc L38F9
lda #$80
L38F9:
lsr FACEXTENSION
ora FACEXTENSION
sta FACEXTENSION
.endif
tya
lsr a
bne L38A7
L3903:
rts
; ----------------------------------------------------------------------------
; UNPACK NUMBER AT (Y,A) INTO ARG
; ----------------------------------------------------------------------------
LOAD_ARG_FROM_YA:
sta INDEX
sty INDEX+1
ldy #BYTES_FP-1
.ifndef CONFIG_SMALL
lda (INDEX),y
sta ARG+4
dey
.endif
lda (INDEX),y
sta ARG+3
dey
lda (INDEX),y
sta ARG+2
dey
lda (INDEX),y
sta ARGSIGN
eor FACSIGN
sta SGNCPR
lda ARGSIGN
ora #$80
sta ARG+1
dey
lda (INDEX),y
sta ARG
lda FAC
rts
; ----------------------------------------------------------------------------
; ADD EXPONENTS OF ARG AND FAC
; (CALLED BY FMULT AND FDIV)
;
; ALSO CHECK FOR OVERFLOW, AND SET RESULT SIGN
; ----------------------------------------------------------------------------
ADD_EXPONENTS:
lda ARG
ADD_EXPONENTS1:
beq ZERO
clc
adc FAC
bcc L393C
bmi JOV
clc
.byte $2C
L393C:
bpl ZERO
adc #$80
sta FAC
bne L3947
jmp STA_IN_FAC_SIGN
L3947:
lda SGNCPR
sta FACSIGN
rts
; ----------------------------------------------------------------------------
; IF (FAC) IS POSITIVE, GIVE "OVERFLOW" ERROR
; IF (FAC) IS NEGATIVE, SET FAC=0, POP ONE RETURN, AND RTS
; CALLED FROM "EXP" FUNCTION
; ----------------------------------------------------------------------------
OUTOFRNG:
lda FACSIGN
eor #$FF
bmi JOV
; ----------------------------------------------------------------------------
; POP RETURN ADDRESS AND SET FAC=0
; ----------------------------------------------------------------------------
ZERO:
pla
pla
jmp ZERO_FAC
JOV:
jmp OVERFLOW
; ----------------------------------------------------------------------------
; MULTIPLY FAC BY 10
; ----------------------------------------------------------------------------
MUL10:
jsr COPY_FAC_TO_ARG_ROUNDED
tax
beq L3970
clc
adc #$02
bcs JOV
LD9BF:
ldx #$00
stx SGNCPR
jsr FADD2
inc FAC
beq JOV
L3970:
rts
; ----------------------------------------------------------------------------
CONTEN:
.ifdef CONFIG_SMALL
.byte $84,$20,$00,$00
.else
.byte $84,$20,$00,$00,$00
.endif
; ----------------------------------------------------------------------------
; DIVIDE FAC BY 10
; ----------------------------------------------------------------------------
DIV10:
jsr COPY_FAC_TO_ARG_ROUNDED
lda #<CONTEN
ldy #>CONTEN
ldx #$00
; ----------------------------------------------------------------------------
; FAC = ARG / (Y,A)
; ----------------------------------------------------------------------------
DIV:
stx SGNCPR
jsr LOAD_FAC_FROM_YA
jmp FDIVT
; ----------------------------------------------------------------------------
; FAC = (Y,A) / FAC
; ----------------------------------------------------------------------------
FDIV:
jsr LOAD_ARG_FROM_YA
; ----------------------------------------------------------------------------
; FAC = ARG / FAC
; ----------------------------------------------------------------------------
FDIVT:
beq L3A02
jsr ROUND_FAC
lda #$00
sec
sbc FAC
sta FAC
jsr ADD_EXPONENTS
inc FAC
beq JOV
ldx #-MANTISSA_BYTES
lda #$01
L39A1:
ldy ARG+1
cpy FAC+1
bne L39B7
ldy ARG+2
cpy FAC+2
bne L39B7
ldy ARG+3
cpy FAC+3
.ifndef CONFIG_SMALL
bne L39B7
ldy ARG+4
cpy FAC+4
.endif
L39B7:
php
rol a
bcc L39C4
inx
sta RESULT_LAST-1,x
beq L39F2
bpl L39F6
lda #$01
L39C4:
plp
bcs L39D5
L39C7:
asl ARG_LAST
.ifndef CONFIG_SMALL
rol ARG+3
.endif
rol ARG+2
rol ARG+1
bcs L39B7
bmi L39A1
bpl L39B7
L39D5:
tay
.ifndef CONFIG_SMALL
lda ARG+4
sbc FAC+4
sta ARG+4
.endif
lda ARG+3
sbc FAC+3
sta ARG+3
lda ARG+2
sbc FAC+2
sta ARG+2
lda ARG+1
sbc FAC+1
sta ARG+1
tya
jmp L39C7
L39F2:
lda #$40
bne L39C4
L39F6:
asl a
asl a
asl a
asl a
asl a
asl a
sta FACEXTENSION
plp
jmp COPY_RESULT_INTO_FAC
L3A02:
ldx #ERR_ZERODIV
jmp ERROR
; ----------------------------------------------------------------------------
; COPY RESULT INTO FAC MANTISSA, AND NORMALIZE
; ----------------------------------------------------------------------------
COPY_RESULT_INTO_FAC:
lda RESULT
sta FAC+1
lda RESULT+1
sta FAC+2
lda RESULT+2
sta FAC+3
.ifndef CONFIG_SMALL
lda RESULT+3
sta FAC+4
.endif
jmp NORMALIZE_FAC2
; ----------------------------------------------------------------------------
; UNPACK (Y,A) INTO FAC
; ----------------------------------------------------------------------------
LOAD_FAC_FROM_YA:
sta INDEX
sty INDEX+1
ldy #MANTISSA_BYTES
.ifndef CONFIG_SMALL
lda (INDEX),y
sta FAC+4
dey
.endif
lda (INDEX),y
sta FAC+3
dey
lda (INDEX),y
sta FAC+2
dey
lda (INDEX),y
sta FACSIGN
ora #$80
sta FAC+1
dey
lda (INDEX),y
sta FAC
sty FACEXTENSION
rts
; ----------------------------------------------------------------------------
; ROUND FAC, STORE IN TEMP2
; ----------------------------------------------------------------------------
STORE_FAC_IN_TEMP2_ROUNDED:
ldx #TEMP2
.byte $2C
; ----------------------------------------------------------------------------
; ROUND FAC, STORE IN TEMP1
; ----------------------------------------------------------------------------
STORE_FAC_IN_TEMP1_ROUNDED:
ldx #TEMP1X
ldy #$00
beq STORE_FAC_AT_YX_ROUNDED
; ----------------------------------------------------------------------------
; ROUND FAC, AND STORE WHERE FORPNT POINTS
; ----------------------------------------------------------------------------
SETFOR:
ldx FORPNT
ldy FORPNT+1
; ----------------------------------------------------------------------------
; ROUND FAC, AND STORE AT (Y,X)
; ----------------------------------------------------------------------------
STORE_FAC_AT_YX_ROUNDED:
jsr ROUND_FAC
stx INDEX
sty INDEX+1
ldy #MANTISSA_BYTES
.ifndef CONFIG_SMALL
lda FAC+4
sta (INDEX),y
dey
.endif
lda FAC+3
sta (INDEX),y
dey
lda FAC+2
sta (INDEX),y
dey
lda FACSIGN
ora #$7F
and FAC+1
sta (INDEX),y
dey
lda FAC
sta (INDEX),y
sty FACEXTENSION
rts
; ----------------------------------------------------------------------------
; COPY ARG INTO FAC
; ----------------------------------------------------------------------------
COPY_ARG_TO_FAC:
lda ARGSIGN
MFA:
sta FACSIGN
ldx #BYTES_FP
L3A7A:
lda SHIFTSIGNEXT,x
sta EXPSGN,x
dex
bne L3A7A
stx FACEXTENSION
rts
; ----------------------------------------------------------------------------
; ROUND FAC AND COPY TO ARG
; ----------------------------------------------------------------------------
COPY_FAC_TO_ARG_ROUNDED:
jsr ROUND_FAC
MAF:
ldx #BYTES_FP+1
L3A89:
lda EXPSGN,x
sta SHIFTSIGNEXT,x
dex
bne L3A89
stx FACEXTENSION
RTS14:
rts
; ----------------------------------------------------------------------------
; ROUND FAC USING EXTENSION BYTE
; ----------------------------------------------------------------------------
ROUND_FAC:
lda FAC
beq RTS14
asl FACEXTENSION
bcc RTS14
; ----------------------------------------------------------------------------
; INCREMENT MANTISSA AND RE-NORMALIZE IF CARRY
; ----------------------------------------------------------------------------
INCREMENT_MANTISSA:
jsr INCREMENT_FAC_MANTISSA
bne RTS14
jmp NORMALIZE_FAC6
; ----------------------------------------------------------------------------
; TEST FAC FOR ZERO AND SIGN
;
; FAC > 0, RETURN +1
; FAC = 0, RETURN 0
; FAC < 0, RETURN -1
; ----------------------------------------------------------------------------
SIGN:
lda FAC
beq RTS15
L3AA7:
lda FACSIGN
SIGN2:
rol a
lda #$FF
bcs RTS15
lda #$01
RTS15:
rts
; ----------------------------------------------------------------------------
; "SGN" FUNCTION
; ----------------------------------------------------------------------------
SGN:
jsr SIGN
; ----------------------------------------------------------------------------
; CONVERT (A) INTO FAC, AS SIGNED VALUE -128 TO +127
; ----------------------------------------------------------------------------
FLOAT:
sta FAC+1
lda #$00
sta FAC+2
ldx #$88
; ----------------------------------------------------------------------------
; FLOAT UNSIGNED VALUE IN FAC+1,2
; (X) = EXPONENT
; ----------------------------------------------------------------------------
FLOAT1:
lda FAC+1
eor #$FF
rol a
; ----------------------------------------------------------------------------
; FLOAT UNSIGNED VALUE IN FAC+1,2
; (X) = EXPONENT
; C=0 TO MAKE VALUE NEGATIVE
; C=1 TO MAKE VALUE POSITIVE
; ----------------------------------------------------------------------------
FLOAT2:
lda #$00
.ifndef CONFIG_SMALL
sta FAC+4
.endif
sta FAC+3
LDB21:
stx FAC
sta FACEXTENSION
sta FACSIGN
jmp NORMALIZE_FAC1
; ----------------------------------------------------------------------------
; "ABS" FUNCTION
; ----------------------------------------------------------------------------
ABS:
lsr FACSIGN
rts
; ----------------------------------------------------------------------------
; COMPARE FAC WITH PACKED # AT (Y,A)
; RETURN A=1,0,-1 AS (Y,A) IS <,=,> FAC
; ----------------------------------------------------------------------------
FCOMP:
sta DEST
; ----------------------------------------------------------------------------
; SPECIAL ENTRY FROM "NEXT" PROCESSOR
; "DEST" ALREADY SET UP
; ----------------------------------------------------------------------------
FCOMP2:
sty DEST+1
ldy #$00
lda (DEST),y
iny
tax
beq SIGN
lda (DEST),y
eor FACSIGN
bmi L3AA7
cpx FAC
bne L3B0A
lda (DEST),y
ora #$80
cmp FAC+1
bne L3B0A
iny
lda (DEST),y
cmp FAC+2
bne L3B0A
iny
.ifndef CONFIG_SMALL
lda (DEST),y
cmp FAC+3
bne L3B0A
iny
.endif
lda #$7F
cmp FACEXTENSION
lda (DEST),y
sbc FAC_LAST
beq L3B32
L3B0A:
lda FACSIGN
bcc L3B10
eor #$FF
L3B10:
jmp SIGN2
; ----------------------------------------------------------------------------
; QUICK INTEGER FUNCTION
;
; CONVERTS FP VALUE IN FAC TO INTEGER VALUE
; IN FAC+1...FAC+4, BY SHIFTING RIGHT WITH SIGN
; EXTENSION UNTIL FRACTIONAL BITS ARE OUT.
;
; THIS SUBROUTINE ASSUMES THE EXPONENT < 32.
; ----------------------------------------------------------------------------
QINT:
lda FAC
beq QINT3
sec
sbc #120+8*BYTES_FP
bit FACSIGN
bpl L3B27
tax
lda #$FF
sta SHIFTSIGNEXT
jsr COMPLEMENT_FAC_MANTISSA
txa
L3B27:
ldx #FAC
cmp #$F9
bpl QINT2
jsr SHIFT_RIGHT
sty SHIFTSIGNEXT
L3B32:
rts
QINT2:
tay
lda FACSIGN
and #$80
lsr FAC+1
ora FAC+1
sta FAC+1
jsr SHIFT_RIGHT4
sty SHIFTSIGNEXT
rts
; ----------------------------------------------------------------------------
; "INT" FUNCTION
;
; USES QINT TO CONVERT (FAC) TO INTEGER FORM,
; AND THEN REFLOATS THE INTEGER.
; ----------------------------------------------------------------------------
INT:
lda FAC
cmp #120+8*BYTES_FP
bcs RTS17
jsr QINT
sty FACEXTENSION
lda FACSIGN
sty FACSIGN
eor #$80
rol a
lda #120+8*BYTES_FP
sta FAC
lda FAC_LAST
sta CHARAC
jmp NORMALIZE_FAC1
QINT3:
sta FAC+1
sta FAC+2
sta FAC+3
.ifndef CONFIG_SMALL
sta FAC+4
.endif
tay
RTS17:
rts
; ----------------------------------------------------------------------------
; CONVERT STRING TO FP VALUE IN FAC
;
; STRING POINTED TO BY TXTPTR
; FIRST CHAR ALREADY SCANNED BY CHRGET
; (A) = FIRST CHAR, C=0 IF DIGIT.
; ----------------------------------------------------------------------------
FIN:
ldy #$00
ldx #SERLEN-TMPEXP
L3B6F:
sty TMPEXP,x
dex
bpl L3B6F
bcc FIN2
.ifdef SYM1
cmp #$26
bne LDABB
jmp LCDFE
LDABB:
.endif
cmp #$2D
bne L3B7E
stx SERLEN
beq FIN1
L3B7E:
cmp #$2B
bne FIN3
FIN1:
jsr CHRGET
FIN2:
bcc FIN9
FIN3:
cmp #$2E
beq FIN10
cmp #$45
bne FIN7
jsr CHRGET
bcc FIN5
cmp #TOKEN_MINUS
beq L3BA6
cmp #$2D
beq L3BA6
cmp #TOKEN_PLUS
beq FIN4
cmp #$2B
beq FIN4
bne FIN6
L3BA6:
.ifndef CONFIG_ROR_WORKAROUND
ror EXPSGN
.else
lda #$00
bcc L3BAC
lda #$80
L3BAC:
lsr EXPSGN
ora EXPSGN
sta EXPSGN
.endif
FIN4:
jsr CHRGET
FIN5:
bcc GETEXP
FIN6:
bit EXPSGN
bpl FIN7
lda #$00
sec
sbc EXPON
jmp FIN8
; ----------------------------------------------------------------------------
; FOUND A DECIMAL POINT
; ----------------------------------------------------------------------------
FIN10:
.ifndef CONFIG_ROR_WORKAROUND
ror LOWTR
.else
lda #$00
bcc L3BC9
lda #$80
L3BC9:
lsr LOWTR
ora LOWTR
sta LOWTR
.endif
bit LOWTR
bvc FIN1
; ----------------------------------------------------------------------------
; NUMBER TERMINATED, ADJUST EXPONENT NOW
; ----------------------------------------------------------------------------
FIN7:
lda EXPON
FIN8:
sec
sbc INDX
sta EXPON
beq L3BEE
bpl L3BE7
L3BDE:
jsr DIV10
inc EXPON
bne L3BDE
beq L3BEE
L3BE7:
jsr MUL10
dec EXPON
bne L3BE7
L3BEE:
lda SERLEN
bmi L3BF3
rts
L3BF3:
jmp NEGOP
; ----------------------------------------------------------------------------
; ACCUMULATE A DIGIT INTO FAC
; ----------------------------------------------------------------------------
FIN9:
pha
bit LOWTR
bpl L3BFD
inc INDX
L3BFD:
jsr MUL10
pla
sec
sbc #$30
jsr ADDACC
jmp FIN1
; ----------------------------------------------------------------------------
; ADD (A) TO FAC
; ----------------------------------------------------------------------------
ADDACC:
pha
jsr COPY_FAC_TO_ARG_ROUNDED
pla
jsr FLOAT
lda ARGSIGN
eor FACSIGN
sta SGNCPR
ldx FAC
jmp FADDT
; ----------------------------------------------------------------------------
; ACCUMULATE DIGIT OF EXPONENT
; ----------------------------------------------------------------------------
GETEXP:
lda EXPON
cmp #MAX_EXPON
bcc L3C2C
.ifdef CONFIG_10A
lda #$64
.endif
bit EXPSGN
.ifdef CONFIG_10A
bmi L3C3A
.else
bmi LDC70
.endif
jmp OVERFLOW
LDC70:
.ifndef CONFIG_10A
lda #$0B
.endif
L3C2C:
asl a
asl a
clc
adc EXPON
asl a
clc
ldy #$00
adc (TXTPTR),y
sec
sbc #$30
L3C3A:
sta EXPON
jmp FIN4
; ----------------------------------------------------------------------------
.ifdef CONFIG_SMALL
; these values are /1000 of what the labels say
CON_99999999_9:
.byte $91,$43,$4F,$F8
CON_999999999:
.byte $94,$74,$23,$F7
CON_BILLION:
.byte $94,$74,$24,$00
.else
CON_99999999_9:
.byte $9B,$3E,$BC,$1F,$FD
CON_999999999:
.ifndef CONFIG_10A
.byte $9E,$6E,$6B,$27,$FE
.else
.byte $9E,$6E,$6B,$27,$FD
.endif
CON_BILLION:
.byte $9E,$6E,$6B,$28,$00
.endif
; ----------------------------------------------------------------------------
; PRINT "IN <LINE #>"
; ----------------------------------------------------------------------------
INPRT:
.ifdef KBD
jsr LFE0B
.byte " in"
.byte 0
.else
lda #<QT_IN
ldy #>QT_IN
jsr GOSTROUT2
.endif
lda CURLIN+1
ldx CURLIN
; ----------------------------------------------------------------------------
; PRINT A,X AS DECIMAL INTEGER
; ----------------------------------------------------------------------------
LINPRT:
sta FAC+1
stx FAC+2
ldx #$90
sec
jsr FLOAT2
jsr FOUT
GOSTROUT2:
jmp STROUT
; ----------------------------------------------------------------------------
; CONVERT (FAC) TO STRING STARTING AT STACK
; RETURN WITH (Y,A) POINTING AT STRING
; ----------------------------------------------------------------------------
FOUT:
ldy #$01
; ----------------------------------------------------------------------------
; "STR$" FUNCTION ENTERS HERE, WITH (Y)=0
; SO THAT RESULT STRING STARTS AT STACK-1
; (THIS IS USED AS A FLAG)
; ----------------------------------------------------------------------------
FOUT1:
lda #$20
bit FACSIGN
bpl L3C73
lda #$2D
L3C73:
sta STACK2-1,y
sta FACSIGN
sty STRNG2
iny
lda #$30
ldx FAC
bne L3C84
jmp FOUT4
L3C84:
lda #$00
cpx #$80
beq L3C8C
bcs L3C95
L3C8C:
lda #<CON_BILLION
ldy #>CON_BILLION
jsr FMULT
.ifdef CONFIG_SMALL
lda #-6 ; exponent adjustment
.else
lda #-9
.endif
L3C95:
sta INDX
; ----------------------------------------------------------------------------
; ADJUST UNTIL 1E8 <= (FAC) <1E9
; ----------------------------------------------------------------------------
L3C97:
lda #<CON_999999999
ldy #>CON_999999999
jsr FCOMP
beq L3CBE
bpl L3CB4
L3CA2:
lda #<CON_99999999_9
ldy #>CON_99999999_9
jsr FCOMP
beq L3CAD
bpl L3CBB
L3CAD:
jsr MUL10
dec INDX
bne L3CA2
L3CB4:
jsr DIV10
inc INDX
bne L3C97
L3CBB:
jsr FADDH
L3CBE:
jsr QINT
; ----------------------------------------------------------------------------
; FAC+1...FAC+4 IS NOW IN INTEGER FORM
; WITH POWER OF TEN ADJUSTMENT IN TMPEXP
;
; IF -10 < TMPEXP > 1, PRINT IN DECIMAL FORM
; OTHERWISE, PRINT IN EXPONENTIAL FORM
; ----------------------------------------------------------------------------
ldx #$01
lda INDX
clc
adc #3*BYTES_FP-5
bmi L3CD3
cmp #3*BYTES_FP-4
bcs L3CD4
adc #$FF
tax
lda #$02
L3CD3:
sec
L3CD4:
sbc #$02
sta EXPON
stx INDX
txa
beq L3CDF
bpl L3CF2
L3CDF:
ldy STRNG2
lda #$2E
iny
sta STACK2-1,y
txa
beq L3CF0
lda #$30
iny
sta STACK2-1,y
L3CF0:
sty STRNG2
; ----------------------------------------------------------------------------
; NOW DIVIDE BY POWERS OF TEN TO GET SUCCESSIVE DIGITS
; ----------------------------------------------------------------------------
L3CF2:
ldy #$00
LDD3A:
ldx #$80
L3CF6:
lda FAC_LAST
clc
.ifndef CONFIG_SMALL
adc DECTBL+3,y
sta FAC+4
lda FAC+3
.endif
adc DECTBL+2,y
sta FAC+3
lda FAC+2
adc DECTBL+1,y
sta FAC+2
lda FAC+1
adc DECTBL,y
sta FAC+1
inx
bcs L3D1A
bpl L3CF6
bmi L3D1C
L3D1A:
bmi L3CF6
L3D1C:
txa
bcc L3D23
eor #$FF
adc #$0A
L3D23:
adc #$2F
iny
iny
iny
.ifndef CONFIG_SMALL
iny
.endif
sty VARPNT
ldy STRNG2
iny
tax
and #$7F
sta STACK2-1,y
dec INDX
bne L3D3E
lda #$2E
iny
sta STACK2-1,y
L3D3E:
sty STRNG2
ldy VARPNT
txa
eor #$FF
and #$80
tax
cpy #DECTBL_END-DECTBL
.ifdef CONFIG_CBM_ALL
beq LDD96
cpy #$3C ; XXX
.endif
bne L3CF6
; ----------------------------------------------------------------------------
; NINE DIGITS HAVE BEEN STORED IN STRING. NOW LOOK
; BACK AND LOP OFF TRAILING ZEROES AND A TRAILING
; DECIMAL POINT.
; ----------------------------------------------------------------------------
LDD96:
ldy STRNG2
L3D4E:
lda STACK2-1,y
dey
cmp #$30
beq L3D4E
cmp #$2E
beq L3D5B
iny
L3D5B:
lda #$2B
ldx EXPON
beq L3D8F
bpl L3D6B
lda #$00
sec
sbc EXPON
tax
lda #$2D
L3D6B:
sta STACK2+1,y
lda #$45
sta STACK2,y
txa
ldx #$2F
sec
L3D77:
inx
sbc #$0A
bcs L3D77
adc #$3A
sta STACK2+3,y
txa
sta STACK2+2,y
lda #$00
sta STACK2+4,y
beq L3D94
FOUT4:
sta STACK2-1,y
L3D8F:
lda #$00
sta STACK2,y
L3D94:
lda #<STACK2
ldy #>STACK2
rts
; ----------------------------------------------------------------------------
CON_HALF:
.ifdef CONFIG_SMALL
.byte $80,$00,$00,$00
.else
.byte $80,$00,$00,$00,$00
.endif
; ----------------------------------------------------------------------------
; POWERS OF 10 FROM 1E8 DOWN TO 1,
; AS 32-BIT INTEGERS, WITH ALTERNATING SIGNS
; ----------------------------------------------------------------------------
DECTBL:
.ifdef CONFIG_SMALL
.byte $FE,$79,$60 ; -100000
.byte $00,$27,$10 ; 10000
.byte $FF,$FC,$18 ; -1000
.byte $00,$00,$64 ; 100
.byte $FF,$FF,$F6 ; -10
.byte $00,$00,$01 ; 1
.else
.byte $FA,$0A,$1F,$00 ; -100000000
.byte $00,$98,$96,$80 ; 10000000
.byte $FF,$F0,$BD,$C0 ; -1000000
.byte $00,$01,$86,$A0 ; 100000
.byte $FF,$FF,$D8,$F0 ; -10000
.byte $00,$00,$03,$E8 ; 1000
.byte $FF,$FF,$FF,$9C ; -100
.byte $00,$00,$00,$0A ; 10
.byte $FF,$FF,$FF,$FF ; -1
.endif
DECTBL_END:
.ifdef CONFIG_CBM_ALL
.byte $FF,$DF,$0A,$80 ; TI$
.byte $00,$03,$4B,$C0
.byte $FF,$FF,$73,$60
.byte $00,$00,$0E,$10
.byte $FF,$FF,$FD,$A8
.byte $00,$00,$00,$3C
.endif
.ifdef CONFIG_2
C_ZERO = CON_HALF + 2
.endif
; ----------------------------------------------------------------------------
; "SQR" FUNCTION
; ----------------------------------------------------------------------------
SQR:
jsr COPY_FAC_TO_ARG_ROUNDED
lda #<CON_HALF
ldy #>CON_HALF
jsr LOAD_FAC_FROM_YA
; ----------------------------------------------------------------------------
; EXPONENTIATION OPERATION
;
; ARG ^ FAC = EXP( LOG(ARG) * FAC )
; ----------------------------------------------------------------------------
FPWRT:
beq EXP
lda ARG
bne L3DD5
jmp STA_IN_FAC_SIGN_AND_EXP
L3DD5:
ldx #TEMP3
ldy #$00
jsr STORE_FAC_AT_YX_ROUNDED
lda ARGSIGN
bpl L3DEF
jsr INT
lda #TEMP3
ldy #$00
jsr FCOMP
bne L3DEF
tya
ldy CHARAC
L3DEF:
jsr MFA
tya
pha
jsr LOG
lda #TEMP3
ldy #$00
jsr FMULT
jsr EXP
pla
lsr a
bcc L3E0F
; ----------------------------------------------------------------------------
; NEGATE VALUE IN FAC
; ----------------------------------------------------------------------------
NEGOP:
lda FAC
beq L3E0F
lda FACSIGN
eor #$FF
sta FACSIGN
L3E0F:
rts
; ----------------------------------------------------------------------------
.ifdef CONFIG_SMALL
CON_LOG_E:
.byte $81,$38,$AA,$3B
POLY_EXP:
.byte $06
.byte $74,$63,$90,$8C
.byte $77,$23,$0C,$AB
.byte $7A,$1E,$94,$00
.byte $7C,$63,$42,$80
.byte $7E,$75,$FE,$D0
.byte $80,$31,$72,$15
.byte $81,$00,$00,$00
.else
CON_LOG_E:
.byte $81,$38,$AA,$3B,$29
POLY_EXP:
.byte $07
.byte $71,$34,$58,$3E,$56
.byte $74,$16,$7E,$B3,$1B
.byte $77,$2F,$EE,$E3,$85
.byte $7A,$1D,$84,$1C,$2A
.byte $7C,$63,$59,$58,$0A
.byte $7E,$75,$FD,$E7,$C6
.byte $80,$31,$72,$18,$10
.byte $81,$00,$00,$00,$00
.endif
; ----------------------------------------------------------------------------
; "EXP" FUNCTION
;
; FAC = E ^ FAC
; ----------------------------------------------------------------------------
EXP:
lda #<CON_LOG_E
ldy #>CON_LOG_E
jsr FMULT
lda FACEXTENSION
adc #$50
bcc L3E4E
jsr INCREMENT_MANTISSA
L3E4E:
sta ARGEXTENSION
jsr MAF
lda FAC
cmp #$88
bcc L3E5C
L3E59:
jsr OUTOFRNG
L3E5C:
jsr INT
lda CHARAC
clc
adc #$81
beq L3E59
sec
sbc #$01
pha
ldx #BYTES_FP
L3E6C:
lda ARG,x
ldy FAC,x
sta FAC,x
sty ARG,x
dex
bpl L3E6C
lda ARGEXTENSION
sta FACEXTENSION
jsr FSUBT
jsr NEGOP
lda #<POLY_EXP
ldy #>POLY_EXP
jsr POLYNOMIAL
lda #$00
sta SGNCPR
pla
jsr ADD_EXPONENTS1
rts
; ----------------------------------------------------------------------------
; ODD POLYNOMIAL SUBROUTINE
;
; F(X) = X * P(X^2)
;
; WHERE: X IS VALUE IN FAC
; Y,A POINTS AT COEFFICIENT TABLE
; FIRST BYTE OF COEFF. TABLE IS N
; COEFFICIENTS FOLLOW, HIGHEST POWER FIRST
;
; P(X^2) COMPUTED USING NORMAL POLYNOMIAL SUBROUTINE
; ----------------------------------------------------------------------------
POLYNOMIAL_ODD:
sta STRNG2
sty STRNG2+1
jsr STORE_FAC_IN_TEMP1_ROUNDED
lda #TEMP1X
jsr FMULT
jsr SERMAIN
lda #TEMP1X
ldy #$00
jmp FMULT
; ----------------------------------------------------------------------------
; NORMAL POLYNOMIAL SUBROUTINE
;
; P(X) = C(0)*X^N + C(1)*X^(N-1) + ... + C(N)
;
; WHERE: X IS VALUE IN FAC
; Y,A POINTS AT COEFFICIENT TABLE
; FIRST BYTE OF COEFF. TABLE IS N
; COEFFICIENTS FOLLOW, HIGHEST POWER FIRST
; ----------------------------------------------------------------------------
POLYNOMIAL:
sta STRNG2
sty STRNG2+1
SERMAIN:
jsr STORE_FAC_IN_TEMP2_ROUNDED
lda (STRNG2),y
sta SERLEN
ldy STRNG2
iny
tya
bne L3EBA
inc STRNG2+1
L3EBA:
sta STRNG2
ldy STRNG2+1
L3EBE:
jsr FMULT
lda STRNG2
ldy STRNG2+1
clc
adc #BYTES_FP
bcc L3ECB
iny
L3ECB:
sta STRNG2
sty STRNG2+1
jsr FADD
lda #TEMP2
ldy #$00
dec SERLEN
bne L3EBE
RTS19:
rts
|
6502-retro/6502-retro-os
| 1,229
|
apps/msbasic/sym1_loadsave.s
|
.segment "CODE"
SAVE:
beq L2739
sta P1L
jsr CHRGET
bne NULL-1
lda TXTTAB
ldy TXTTAB+1
sta P2L
sty P2H
lda VARTAB
ldy VARTAB+1
sta P3L
sty P3H
ldy #$80
jsr USR2
bcs LC6DD
lda #<SAVED
ldy #>SAVED
jmp STROUT
LOADED:
.byte "LOADED",CR,LF
.byte "OK",CR,LF,0
SAVED:
.byte "SAVED",CR,LF,0
LOAD:
beq L2739
sta $A64E
jsr CHRGET
bne L2738
ldy #$80
jsr USR3
bcs LC6EF
lda #<LOADED
ldy #>LOADED
jsr STROUT
ldx P3L
ldy P3H
txa
stx VARTAB
sty VARTAB+1
jmp FIX_LINKS
LC6DD:
lda #<BAD_SAVE
ldy #>BAD_SAVE
jmp STROUT
BAD_SAVE:
htasc "BAD SAVE"
.byte CR,LF,0
LC6EF:
lda #<BAD_LOAD
ldy #>BAD_LOAD
jsr STROUT
jsr SCRTCH
jmp RESTART
BAD_LOAD:
htasc "BAD LOAD"
.byte CR,LF,0
|
6502-retro/6502-retro-os
| 5,461
|
apps/msbasic/var.s
|
.segment "CODE"
; ----------------------------------------------------------------------------
; "DIM" STATEMENT
; ----------------------------------------------------------------------------
NXDIM:
jsr CHKCOM
DIM:
tax
jsr PTRGET2
jsr CHRGOT
bne NXDIM
rts
; ----------------------------------------------------------------------------
; PTRGET -- GENERAL VARIABLE SCAN
;
; SCANS VARIABLE NAME AT TXTPTR, AND SEARCHES THE
; VARTAB AND ARYTAB FOR THE NAME.
; IF NOT FOUND, CREATE VARIABLE OF APPROPRIATE TYPE.
; RETURN WITH ADDRESS IN VARPNT AND Y,A
;
; ACTUAL ACTIVITY CONTROLLED SOMEWHAT BY TWO FLAGS:
; DIMFLG -- NONZERO IF CALLED FROM "DIM"
; ELSE = 0
;
; SUBFLG -- = $00
; = $40 IF CALLED FROM "GETARYPT"
; ----------------------------------------------------------------------------
PTRGET:
ldx #$00
jsr CHRGOT
PTRGET2:
stx DIMFLG
PTRGET3:
sta VARNAM
jsr CHRGOT
jsr ISLETC
bcs NAMOK
SYNERR3:
jmp SYNERR
NAMOK:
ldx #$00
stx VALTYP
.ifndef CONFIG_SMALL
stx VALTYP+1
.endif
jsr CHRGET
bcc L2ECD
jsr ISLETC
bcc L2ED8
L2ECD:
tax
L2ECE:
jsr CHRGET
bcc L2ECE
jsr ISLETC
bcs L2ECE
L2ED8:
cmp #$24
.ifdef CONFIG_SMALL
bne L2EF9
.else
bne L2EE2
.endif
lda #$FF
sta VALTYP
.ifndef CONFIG_SMALL
bne L2EF2
L2EE2:
cmp #$25
bne L2EF9
lda SUBFLG
bne SYNERR3
lda #$80
sta VALTYP+1
ora VARNAM
sta VARNAM
L2EF2:
.endif
txa
ora #$80
tax
jsr CHRGET
L2EF9:
stx VARNAM+1
sec
ora SUBFLG
sbc #$28
bne L2F05
jmp ARRAY
L2F05:
lda #$00
sta SUBFLG
lda VARTAB
ldx VARTAB+1
ldy #$00
L2F0F:
stx LOWTR+1
L2F11:
sta LOWTR
cpx ARYTAB+1
bne L2F1B
cmp ARYTAB
beq NAMENOTFOUND
L2F1B:
lda VARNAM
cmp (LOWTR),y
bne L2F29
lda VARNAM+1
iny
cmp (LOWTR),y
beq SET_VARPNT_AND_YA
dey
L2F29:
clc
lda LOWTR
adc #BYTES_PER_VARIABLE
bcc L2F11
inx
bne L2F0F
; ----------------------------------------------------------------------------
; CHECK IF (A) IS ASCII LETTER A-Z
;
; RETURN CARRY = 1 IF A-Z
; = 0 IF NOT
; ----------------------------------------------------------------------------
ISLETC:
cmp #$41
bcc L2F3C
sbc #$5B
sec
sbc #$A5
L2F3C:
rts
; ----------------------------------------------------------------------------
; VARIABLE NOT FOUND, SO MAKE ONE
; ----------------------------------------------------------------------------
NAMENOTFOUND:
pla
pha
cmp #<FRM_VARIABLE_CALL
bne MAKENEWVARIABLE
.ifdef CONFIG_SAFE_NAMENOTFOUND
tsx
lda STACK+2,x
cmp #>FRM_VARIABLE_CALL
bne MAKENEWVARIABLE
.endif
LD015:
lda #<C_ZERO
ldy #>C_ZERO
rts
; ----------------------------------------------------------------------------
.ifndef CONFIG_2
C_ZERO:
.byte $00,$00
.endif
; ----------------------------------------------------------------------------
; MAKE A NEW SIMPLE VARIABLE
;
; MOVE ARRAYS UP 7 BYTES TO MAKE ROOM FOR NEW VARIABLE
; ENTER 7-BYTE VARIABLE DATA IN THE HOLE
; ----------------------------------------------------------------------------
MAKENEWVARIABLE:
.ifdef CONFIG_CBM_ALL
lda VARNAM
ldy VARNAM+1
cmp #$54
bne LD02F
cpy #$C9
beq LD015
cpy #$49
bne LD02F
LD02C:
jmp SYNERR
LD02F:
cmp #$53
bne LD037
cpy #$54
beq LD02C
LD037:
.endif
lda ARYTAB
ldy ARYTAB+1
sta LOWTR
sty LOWTR+1
lda STREND
ldy STREND+1
sta HIGHTR
sty HIGHTR+1
clc
adc #BYTES_PER_VARIABLE
bcc L2F68
iny
L2F68:
sta HIGHDS
sty HIGHDS+1
jsr BLTU
lda HIGHDS
ldy HIGHDS+1
iny
sta ARYTAB
sty ARYTAB+1
ldy #$00
lda VARNAM
sta (LOWTR),y
iny
lda VARNAM+1
sta (LOWTR),y
lda #$00
iny
sta (LOWTR),y
iny
sta (LOWTR),y
iny
sta (LOWTR),y
iny
sta (LOWTR),y
.ifndef CONFIG_SMALL
iny
sta (LOWTR),y
.endif
; ----------------------------------------------------------------------------
; PUT ADDRESS OF VALUE OF VARIABLE IN VARPNT AND Y,A
; ----------------------------------------------------------------------------
SET_VARPNT_AND_YA:
lda LOWTR
clc
adc #$02
ldy LOWTR+1
bcc L2F9E
iny
L2F9E:
sta VARPNT
sty VARPNT+1
rts
|
6502-retro/6502-retro-os
| 5,231
|
apps/msbasic/flow2.s
|
.segment "CODE"
; ----------------------------------------------------------------------------
; "RUN" COMMAND
; ----------------------------------------------------------------------------
RUN:
bne L27CF
jmp SETPTRS
L27CF:
jsr CLEARC
jmp L27E9
; ----------------------------------------------------------------------------
; "GOSUB" STATEMENT
;
; LEAVES 7 BYTES ON STACK:
; 2 -- RETURN ADDRESS (NEWSTT)
; 2 -- TXTPTR
; 2 -- LINE #
; 1 -- GOSUB TOKEN
; ----------------------------------------------------------------------------
GOSUB:
lda #$03
jsr CHKMEM
lda TXTPTR+1
pha
lda TXTPTR
pha
lda CURLIN+1
pha
lda CURLIN
pha
lda #TOKEN_GOSUB
pha
L27E9:
jsr CHRGOT
jsr GOTO
jmp NEWSTT
; ----------------------------------------------------------------------------
; "GOTO" STATEMENT
; ALSO USED BY "RUN" AND "GOSUB"
; ----------------------------------------------------------------------------
GOTO:
jsr LINGET
jsr REMN
lda CURLIN+1
cmp LINNUM+1
bcs L2809
tya
sec
adc TXTPTR
ldx TXTPTR+1
bcc L280D
inx
bcs L280D
L2809:
lda TXTTAB
ldx TXTTAB+1
L280D:
.ifdef KBD
jsr LF457
bne UNDERR
.else
jsr FL1
bcc UNDERR
.endif
lda LOWTRX
sbc #$01
sta TXTPTR
lda LOWTRX+1
sbc #$00
sta TXTPTR+1
L281E:
rts
; ----------------------------------------------------------------------------
; "POP" AND "RETURN" STATEMENTS
; ----------------------------------------------------------------------------
POP:
bne L281E
lda #$FF
.ifdef CONFIG_2A
sta FORPNT+1 ; bugfix, wrong in AppleSoft II
.else
sta FORPNT
.endif
jsr GTFORPNT
txs
cmp #TOKEN_GOSUB
beq RETURN
ldx #ERR_NOGOSUB
.byte $2C
UNDERR:
ldx #ERR_UNDEFSTAT
jmp ERROR
; ----------------------------------------------------------------------------
SYNERR2:
jmp SYNERR
; ----------------------------------------------------------------------------
RETURN:
pla
pla
sta CURLIN
pla
sta CURLIN+1
pla
sta TXTPTR
pla
sta TXTPTR+1
; ----------------------------------------------------------------------------
; "DATA" STATEMENT
; EXECUTED BY SKIPPING TO NEXT COLON OR EOL
; ----------------------------------------------------------------------------
DATA:
jsr DATAN
; ----------------------------------------------------------------------------
; ADD (Y) TO TXTPTR
; ----------------------------------------------------------------------------
ADDON:
tya
clc
adc TXTPTR
sta TXTPTR
bcc L2852
inc TXTPTR+1
L2852:
rts
; ----------------------------------------------------------------------------
; SCAN AHEAD TO NEXT ":" OR EOL
; ----------------------------------------------------------------------------
DATAN:
ldx #$3A
.byte $2C
REMN:
ldx #$00
stx CHARAC
ldy #$00
sty ENDCHR
L285E:
lda ENDCHR
ldx CHARAC
sta CHARAC
stx ENDCHR
L2866:
lda (TXTPTR),y
beq L2852
cmp ENDCHR
beq L2852
iny
cmp #$22
.ifndef CONFIG_11
beq L285E; old: swap & cont is faster
bne L2866
.else
bne L2866; new: cont is faster
beq L285E
.endif
; ----------------------------------------------------------------------------
; "IF" STATEMENT
; ----------------------------------------------------------------------------
IF:
jsr FRMEVL
jsr CHRGOT
cmp #TOKEN_GOTO
beq L2884
lda #TOKEN_THEN
jsr SYNCHR
L2884:
lda FAC
bne L288D
; ----------------------------------------------------------------------------
; "REM" STATEMENT, OR FALSE "IF" STATEMENT
; ----------------------------------------------------------------------------
REM:
jsr REMN
beq ADDON
L288D:
jsr CHRGOT
bcs L2895
jmp GOTO
L2895:
jmp EXECUTE_STATEMENT
; ----------------------------------------------------------------------------
; "ON" STATEMENT
;
; ON <EXP> GOTO <LIST>
; ON <EXP> GOSUB <LIST>
; ----------------------------------------------------------------------------
ON:
jsr GETBYT
pha
cmp #TOKEN_GOSUB
beq L28A4
L28A0:
cmp #TOKEN_GOTO
bne SYNERR2
L28A4:
dec FAC_LAST
bne L28AC
pla
jmp EXECUTE_STATEMENT1
L28AC:
jsr CHRGET
jsr LINGET
cmp #$2C
beq L28A4
pla
L28B7:
rts
|
6502-retro/6502-retro-os
| 2,627
|
apps/msbasic/apple_extra.s
|
.segment "EXTRA"
.byte 0,0,0
L2900:
jsr LFD6A
stx $33
ldx #$00
L2907:
lda $0200,x
and #$7F
cmp #$0D
bne L2912
lda #$00
L2912:
sta $0200,x
inx
bne L2907
ldx $33
rts
PLT:
jmp L29F0
L291E:
cmp #$47
bne L2925
jmp L29E0
L2925:
cmp #$43
bne L292B
beq L2988
L292B:
cmp #$50
beq L2930
inx
L2930:
stx $33
L2932:
jsr FRMEVL
jsr ROUND_FAC
jsr AYINT
lda FAC+4
ldx $33
sta $0300,x
dec $33
bmi L294Dx
lda #$2C
jsr SYNCHR
bpl L2932
L294Dx:
tay
pla
cmp #$43
bne L2957
tya
jmp LF864
L2957:
cmp #$50
bne L2962
tya
ldy $0301
jmp LF800
L2962:
pha
lda $0301
sta $2C
sta $2D
pla
cmp #$48
bne L2978
lda $0300
ldy $0302
jmp LF819
L2978:
cmp #$56
beq L297F
jmp SYNERR
L297F:
ldy $0300
lda $0302
jmp LF828
L2988:
dex
beq L2930
INLINX:
jsr OUTQUES
jsr OUTSP
ldx #$80
jmp INLIN1
.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
.byte 0,0,0,0,0,0,0,0,0,0
USR_FUNC:
jsr L29DA
lda FAC+3
sta FAC+5
jmp (FAC+4)
L29DA:
jmp (GOAYINT)
brk
brk
brk
L29E0:
pla
jmp LFB40
.byte 0,0,0,0,0,0,0,0,0,0,0,0
L29F0:
pha
ldx #$01
inc $B9
bne L29F9
inc $BA
L29F9:
jmp L291E
.byte $00,$00,$00,$00,$41,$53,$21,$D2
.byte $02,$FA,$00
lda $12
beq L2A0E
jmp (GOGIVEAYF)
L2A0E:
jsr LF689
.byte $15,$BC,$08,$10,$52,$45,$75,$10
.byte $CD,$00,$55,$15,$9E,$08,$10,$4C
.byte $45,$75,$10,$D4,$00,$55,$15,$0E
.byte $08,$10,$89,$10,$75,$15,$1C,$08
.byte $10,$1F,$10,$75,$00
jmp (GOGIVEAYF)
; ----------------------------------------------------------------------------
.byte 0,0,0,0,0,0
|
6502-retro/6502-retro-os
| 2,876
|
apps/msbasic/inline.s
|
.segment "CODE"
.ifndef CONFIG_NO_INPUTBUFFER_ZP
L2420:
.ifdef OSI
jsr OUTDO
.endif
dex
.ifdef AIM65
bmi L2423
jsr PSLS
jmp INLIN2
LB35F:
jsr OUTDO
.else
bpl INLIN2
.endif
L2423:
.ifdef OSI
jsr OUTDO
.endif
jsr CRDO
.endif
; ----------------------------------------------------------------------------
; READ A LINE, AND STRIP OFF SIGN BITS
; ----------------------------------------------------------------------------
.ifndef KBD
INLIN:
.ifdef APPLE
ldx #$DD
INLIN1:
stx $33
jsr L2900
cpx #$EF
bcs L0C32
ldx #$EF
L0C32:
lda #$00
sta INPUTBUFFER,x
ldx #<INPUTBUFFER-1
ldy #>INPUTBUFFER-1
rts
.endif
.ifndef APPLE
ldx #$00
INLIN2:
jsr GETLN
.ifdef AIM65
cmp #$1A
bne INLINAIM
jsr DU13
jmp INLIN
INLINAIM:
.endif
.ifndef CONFIG_NO_LINE_EDITING
cmp #$07
beq L2443
.endif
cmp #$0D
beq L2453
.ifndef CONFIG_NO_LINE_EDITING
cmp #$20
.ifdef AIM65
bcc L244E
.else
bcc INLIN2
.endif
.ifdef MICROTAN
cmp #$80
.else
.ifdef AIM65
cmp #$7F
beq L2420
.endif
cmp #$7D
.endif
bcs INLIN2
cmp #$40 ; @
.ifdef AIM65
beq LB35F
.else
beq L2423
.ifdef MICROTAN
cmp #$7F ; DEL
.else
cmp #$5F ; _
.endif
beq L2420
.endif
L2443:
.ifdef MICROTAN
cpx #$4F
.else
cpx #$47
.endif
bcs L244C
.endif
sta INPUTBUFFER,x
inx
.if .def(OSI) || .def(AIM65)
.byte $2C
.else
bne INLIN2
.endif
L244C:
.ifndef CONFIG_NO_LINE_EDITING
lda #$07 ; BEL
L244E:
jsr OUTDO
bne INLIN2
.endif
L2453:
jmp L29B9
.endif
.endif
.ifndef KBD
.ifndef APPLE
GETLN:
.ifdef CONFIG_FILE
jsr CHRIN
ldy CURDVC
bne L2465
.else
jsr MONRDKEY
.endif
.ifdef OSI
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
and #$7F
.endif
.endif
.ifdef APPLE
RDKEY:
jsr LFD0C
and #$7F
.endif
.ifdef SYM1
cmp #$14
.else
cmp #$0F
.endif
bne L2465
pha
lda Z14
eor #$FF
sta Z14
pla
L2465:
rts
.endif
|
6502-retro/6502-retro-os
| 1,476
|
apps/msbasic/error.s
|
init_error_table
.ifdef CONFIG_SMALL_ERROR
define_error ERR_NOFOR, "NF"
define_error ERR_SYNTAX, "SN"
define_error ERR_NOGOSUB, "RG"
define_error ERR_NODATA, "OD"
define_error ERR_ILLQTY, "FC"
define_error ERR_OVERFLOW, "OV"
define_error ERR_MEMFULL, "OM"
define_error ERR_UNDEFSTAT, "US"
define_error ERR_BADSUBS, "BS"
define_error ERR_REDIMD, "DD"
define_error ERR_ZERODIV, "/0"
define_error ERR_ILLDIR, "ID"
define_error ERR_BADTYPE, "TM"
define_error ERR_STRLONG, "LS"
define_error ERR_FRMCPX, "ST"
define_error ERR_CANTCONT, "CN"
define_error ERR_UNDEFFN, "UF"
.else
define_error ERR_NOFOR, "NEXT WITHOUT FOR"
define_error ERR_SYNTAX, "SYNTAX"
define_error ERR_NOGOSUB, "RETURN WITHOUT GOSUB"
define_error ERR_NODATA, "OUT OF DATA"
define_error ERR_ILLQTY, "ILLEGAL QUANTITY"
.ifdef CBM1
.byte 0,0,0,0,0
.endif
define_error ERR_OVERFLOW, "OVERFLOW"
define_error ERR_MEMFULL, "OUT OF MEMORY"
define_error ERR_UNDEFSTAT, "UNDEF'D STATEMENT"
define_error ERR_BADSUBS, "BAD SUBSCRIPT"
define_error ERR_REDIMD, "REDIM'D ARRAY"
define_error ERR_ZERODIV, "DIVISION BY ZERO"
define_error ERR_ILLDIR, "ILLEGAL DIRECT"
define_error ERR_BADTYPE, "TYPE MISMATCH"
define_error ERR_STRLONG, "STRING TOO LONG"
.ifdef CONFIG_FILE
.ifdef CBM1
define_error ERR_BADDATA, "BAD DATA"
.else
define_error ERR_BADDATA, "FILE DATA"
.endif
.endif
define_error ERR_FRMCPX, "FORMULA TOO COMPLEX"
define_error ERR_CANTCONT, "CAN'T CONTINUE"
define_error ERR_UNDEFFN, "UNDEF'D FUNCTION"
.endif
|
6502-retro/6502-retro-os
| 3,760
|
apps/msbasic/misc2.s
|
.segment "CODE"
; ----------------------------------------------------------------------------
; "FRE" FUNCTION
;
; COLLECTS GARBAGE AND RETURNS # BYTES OF MEMORY LEFT
; ----------------------------------------------------------------------------
FRE:
lda VALTYP
beq L3188
jsr FREFAC
L3188:
jsr GARBAG
sec
lda FRETOP
sbc STREND
tay
lda FRETOP+1
sbc STREND+1
; FALL INTO GIVAYF TO FLOAT THE VALUE
; NOTE THAT VALUES OVER 32767 WILL RETURN AS NEGATIVE
; ----------------------------------------------------------------------------
; FLOAT THE SIGNED INTEGER IN A,Y
; ----------------------------------------------------------------------------
GIVAYF:
ldx #$00
stx VALTYP
sta FAC+1
sty FAC+2
ldx #$90
jmp FLOAT1
POS:
ldy POSX
; ----------------------------------------------------------------------------
; FLOAT (Y) INTO FAC, GIVING VALUE 0-255
; ----------------------------------------------------------------------------
SNGFLT:
lda #$00
beq GIVAYF
; ----------------------------------------------------------------------------
; CHECK FOR DIRECT OR RUNNING MODE
; GIVING ERROR IF DIRECT MODE
; ----------------------------------------------------------------------------
ERRDIR:
ldx CURLIN+1
inx
bne RTS9
ldx #ERR_ILLDIR
.ifdef CONFIG_2
.byte $2C
LD288:
ldx #ERR_UNDEFFN
.endif
L31AF:
jmp ERROR
DEF:
jsr FNC
jsr ERRDIR
jsr CHKOPN
lda #$80
sta SUBFLG
jsr PTRGET
jsr CHKNUM
jsr CHKCLS
lda #TOKEN_EQUAL
jsr SYNCHR
.ifndef CONFIG_SMALL
pha
.endif
lda VARPNT+1
pha
lda VARPNT
pha
lda TXTPTR+1
pha
lda TXTPTR
pha
jsr DATA
jmp L3250
FNC:
lda #TOKEN_FN
jsr SYNCHR
ora #$80
sta SUBFLG
jsr PTRGET3
sta FNCNAM
sty FNCNAM+1
jmp CHKNUM
L31F3:
jsr FNC
lda FNCNAM+1
pha
lda FNCNAM
pha
jsr PARCHK
jsr CHKNUM
pla
sta FNCNAM
pla
sta FNCNAM+1
ldy #$02
.ifndef CONFIG_2
ldx #ERR_UNDEFFN
.endif
lda (FNCNAM),y
.ifndef CONFIG_2
beq L31AF
.endif
sta VARPNT
tax
iny
lda (FNCNAM),y
.ifdef CONFIG_2
beq LD288
.endif
sta VARPNT+1
.ifndef CONFIG_SMALL
iny
.endif
L3219:
lda (VARPNT),y
pha
dey
bpl L3219
ldy VARPNT+1
jsr STORE_FAC_AT_YX_ROUNDED
lda TXTPTR+1
pha
lda TXTPTR
pha
lda (FNCNAM),y
sta TXTPTR
iny
lda (FNCNAM),y
sta TXTPTR+1
lda VARPNT+1
pha
lda VARPNT
pha
jsr FRMNUM
pla
sta FNCNAM
pla
sta FNCNAM+1
jsr CHRGOT
beq L324A
jmp SYNERR
L324A:
pla
sta TXTPTR
pla
sta TXTPTR+1
L3250:
ldy #$00
pla
sta (FNCNAM),y
pla
iny
sta (FNCNAM),y
pla
iny
sta (FNCNAM),y
pla
iny
sta (FNCNAM),y
.ifndef CONFIG_SMALL
pla
iny
sta (FNCNAM),y
.endif
rts
|
6502-retro/6502-retro-os
| 9,952
|
apps/msbasic/input.s
|
.segment "CODE"
; ----------------------------------------------------------------------------
; INPUT CONVERSION ERROR: ILLEGAL CHARACTER
; IN NUMERIC FIELD. MUST DISTINGUISH
; BETWEEN INPUT, READ, AND GET
; ----------------------------------------------------------------------------
INPUTERR:
lda INPUTFLG
beq RESPERR ; INPUT
.ifndef SYM1
.ifndef CONFIG_SMALL
.ifdef CONFIG_10A
; without this, it treats GET errors
; like READ errors
bmi L2A63 ; READ
ldy #$FF ; GET
bne L2A67
L2A63:
.endif
.endif
.endif
.ifdef CONFIG_CBM1_PATCHES
jsr PATCH5
nop
.else
lda Z8C
ldy Z8C+1
.endif
L2A67:
sta CURLIN
sty CURLIN+1
SYNERR4:
jmp SYNERR
RESPERR:
.ifdef CONFIG_FILE
lda CURDVC
beq LCA8F
ldx #ERR_BADDATA
jmp ERROR
LCA8F:
.endif
lda #<ERRREENTRY
ldy #>ERRREENTRY
jsr STROUT
lda OLDTEXT
ldy OLDTEXT+1
sta TXTPTR
sty TXTPTR+1
RTS20:
rts
; ----------------------------------------------------------------------------
; "GET" STATEMENT
; ----------------------------------------------------------------------------
.ifndef CONFIG_SMALL
.ifndef SYM1
GET:
jsr ERRDIR
; CBM: if GET#, then switch input
.ifdef CONFIG_FILE
cmp #'#'
bne LCAB6
jsr CHRGET
jsr GETBYT
lda #','
jsr SYNCHR
jsr CHKIN
stx CURDVC
LCAB6:
.endif
ldx #<(INPUTBUFFER+1)
ldy #>(INPUTBUFFER+1)
.ifdef CONFIG_NO_INPUTBUFFER_ZP
lda #$00
sta INPUTBUFFER+1
.else
sty INPUTBUFFER+1
.endif
lda #$40
jsr PROCESS_INPUT_LIST
; CBM: if GET#, then switch input back
.ifdef CONFIG_FILE
ldx CURDVC
bne LCAD8
.endif
rts
.endif
.endif
; ----------------------------------------------------------------------------
; "INPUT#" STATEMENT
; ----------------------------------------------------------------------------
.ifdef CONFIG_FILE
INPUTH:
jsr GETBYT
lda #$2C
jsr SYNCHR
jsr CHKIN
stx CURDVC
jsr L2A9E
LCAD6:
lda CURDVC
LCAD8:
jsr CLRCH
ldx #$00
stx CURDVC
rts
LCAE0:
.endif
.ifdef SYM1
LC9B0:
jsr OUTQUES ; '?'
jsr OUTSP
jmp L2A9E
.endif
; ----------------------------------------------------------------------------
; "INPUT" STATEMENT
; ----------------------------------------------------------------------------
INPUT:
.ifndef KBD
lsr Z14
.endif
.ifdef AIM65
lda PRIFLG
sta ZBE
jsr LCFFA
.endif
cmp #$22
.ifdef SYM1
bne LC9B0
.else
bne L2A9E
.endif
jsr STRTXT
lda #$3B
jsr SYNCHR
jsr STRPRT
L2A9E:
jsr ERRDIR
lda #$2C
sta INPUTBUFFER-1
LCAF8:
.ifdef APPLE
jsr INLINX
.elseif .def(SYM1)
jsr INLIN
.else
jsr NXIN
.endif
.ifdef KBD
bmi L2ABE
.else
.ifdef CONFIG_FILE
lda CURDVC
beq LCB0C
lda Z96
and #$02
beq LCB0C
jsr LCAD6
jmp DATA
LCB0C:
.endif
lda INPUTBUFFER
bne L2ABE
.ifdef CONFIG_FILE
lda CURDVC
bne LCAF8
.endif
.ifdef CONFIG_CBM1_PATCHES
jmp PATCH1
.else
clc
jmp CONTROL_C_TYPED
.endif
.endif
NXIN:
.ifdef KBD
jsr INLIN
bmi RTS20
pla
jmp LE86C
.else
.ifdef CONFIG_FILE
lda CURDVC
bne LCB21
.endif
jsr OUTQUES ; '?'
jsr OUTSP
LCB21:
jmp INLIN
.endif
; ----------------------------------------------------------------------------
; "GETC" STATEMENT
; ----------------------------------------------------------------------------
.ifdef KBD
GETC:
jsr CONINT
jsr LF43D
jmp LE664
.endif
; ----------------------------------------------------------------------------
; "READ" STATEMENT
; ----------------------------------------------------------------------------
READ:
ldx DATPTR
ldy DATPTR+1
.ifdef CONFIG_NO_READ_Y_IS_ZERO_HACK
; AppleSoft II, too
lda #$98 ; READ
.byte $2C
L2ABE:
lda #$00 ; INPUT
.else
.byte $A9 ; LDA #$98
L2ABE:
tya
.endif
; ----------------------------------------------------------------------------
; PROCESS INPUT LIST
;
; (Y,X) IS ADDRESS OF INPUT DATA STRING
; (A) = VALUE FOR INPUTFLG: $00 FOR INPUT
; $40 FOR GET
; $98 FOR READ
; ----------------------------------------------------------------------------
PROCESS_INPUT_LIST:
sta INPUTFLG
stx INPTR
sty INPTR+1
PROCESS_INPUT_ITEM:
jsr PTRGET
sta FORPNT
sty FORPNT+1
lda TXTPTR
ldy TXTPTR+1
sta TXPSV
sty TXPSV+1
ldx INPTR
ldy INPTR+1
stx TXTPTR
sty TXTPTR+1
jsr CHRGOT
bne INSTART
bit INPUTFLG
.ifndef CONFIG_SMALL ; GET
.ifndef SYM1
bvc L2AF0
.ifdef MICROTAN
jsr MONRDKEY2
.elseif .def(AIM65)
jsr MONRDKEY2
.else
jsr MONRDKEY
.endif
.ifdef CONFIG_IO_MSB
and #$7F
.endif
sta INPUTBUFFER
; BUG: The beq/bne L2AF8 below is supposed
; to be always taken. For this to happen,
; the last load must be a 0 for beq
; and != 0 for bne. The original Microsoft
; code had ldx/ldy/bne here, which was only
; correct for a non-ZP INPUTBUFFER. Commodore
; fixed it in CBMBASIC V1 by swapping the
; ldx and the ldy. It was broken on KIM,
; but okay on APPLE and CBM2, because
; these used a non-ZP INPUTBUFFER.
; Microsoft fixed this somewhere after KIM
; and before MICROTAN, by using beq instead
; of bne in the ZP case.
.ifdef CBM1
ldy #>(INPUTBUFFER-1)
ldx #<(INPUTBUFFER-1)
.else
ldx #<(INPUTBUFFER-1)
ldy #>(INPUTBUFFER-1)
.endif
.if .def(CONFIG_2) && (!.def(CONFIG_NO_INPUTBUFFER_ZP))
beq L2AF8 ; always
.else
bne L2AF8 ; always
.endif
L2AF0:
.endif
.endif
bmi FINDATA
.ifdef CONFIG_FILE
lda CURDVC
bne LCB64
.endif
.ifdef KBD
jsr OUTQUESSP
.else
jsr OUTQUES
.endif
LCB64:
jsr NXIN
L2AF8:
stx TXTPTR
sty TXTPTR+1
; ----------------------------------------------------------------------------
INSTART:
jsr CHRGET
bit VALTYP
bpl L2B34
.ifndef CONFIG_SMALL ; GET
.ifndef SYM1
bit INPUTFLG
bvc L2B10
.ifdef CONFIG_CBM1_PATCHES
lda #$00
jsr PATCH4
nop
.else
inx
stx TXTPTR
lda #$00
sta CHARAC
beq L2B1C
.endif
L2B10:
.endif
.endif
sta CHARAC
cmp #$22
beq L2B1D
lda #$3A
sta CHARAC
lda #$2C
L2B1C:
clc
L2B1D:
sta ENDCHR
lda TXTPTR
ldy TXTPTR+1
adc #$00
bcc L2B28
iny
L2B28:
jsr STRLT2
jsr POINT
.ifdef CONFIG_SMALL
jsr LETSTRING
.else
jsr PUTSTR
.endif
jmp INPUT_MORE
; ----------------------------------------------------------------------------
L2B34:
jsr FIN
.ifdef CONFIG_SMALL
jsr SETFOR
.else
lda VALTYP+1
jsr LET2
.endif
; ----------------------------------------------------------------------------
INPUT_MORE:
jsr CHRGOT
beq L2B48
cmp #$2C
beq L2B48
jmp INPUTERR
L2B48:
lda TXTPTR
ldy TXTPTR+1
sta INPTR
sty INPTR+1
lda TXPSV
ldy TXPSV+1
sta TXTPTR
sty TXTPTR+1
jsr CHRGOT
beq INPDONE
jsr CHKCOM
jmp PROCESS_INPUT_ITEM
; ----------------------------------------------------------------------------
FINDATA:
jsr DATAN
iny
tax
bne L2B7C
ldx #ERR_NODATA
iny
lda (TXTPTR),y
beq GERR
iny
lda (TXTPTR),y
sta Z8C
iny
lda (TXTPTR),y
iny
sta Z8C+1
L2B7C:
lda (TXTPTR),y
tax
jsr ADDON
cpx #$83
bne FINDATA
jmp INSTART
; ---NO MORE INPUT REQUESTED------
INPDONE:
lda INPTR
ldy INPTR+1
ldx INPUTFLG
.if .def(CONFIG_SMALL) && (!.def(CONFIG_11))
beq L2B94 ; INPUT
.else
bpl L2B94; INPUT or GET
.endif
jmp SETDA
L2B94:
ldy #$00
.ifdef AIM65
jsr LB8B1
.endif
lda (INPTR),y
beq L2BA1
.ifdef CONFIG_FILE
lda CURDVC
bne L2BA1
.endif
lda #<ERREXTRA
ldy #>ERREXTRA
jmp STROUT
L2BA1:
rts
; ----------------------------------------------------------------------------
ERREXTRA:
.ifdef KBD
.byte "?Extra"
.else
.byte "?EXTRA IGNORED"
.endif
.byte $0D,$0A,$00
ERRREENTRY:
.ifdef KBD
.byte "What?"
.else
.byte "?REDO FROM START"
.endif
.byte $0D,$0A,$00
.ifdef KBD
LEA30:
.byte "B"
.byte $FD
.byte "GsBASIC"
.byte $00,$1B,$0D,$13
.byte " BASIC"
.endif
|
6502-retro/6502-retro-os
| 1,707
|
apps/msbasic/macros.s
|
; htasc - set the hi bit on the last byte of a string for termination
; (by Tom Greene)
.macro htasc str
.repeat .strlen(str)-1,I
.byte .strat(str,I)
.endrep
.byte .strat(str,.strlen(str)-1) | $80
.endmacro
; For every token, a byte gets put into segment "DUMMY".
; This way, we count up with every token. The DUMMY segment
; doesn't get linked into the binary.
.macro init_token_tables
.segment "VECTORS"
TOKEN_ADDRESS_TABLE:
.segment "KEYWORDS"
TOKEN_NAME_TABLE:
.segment "DUMMY"
DUMMY_START:
.endmacro
; optionally define token symbol
; count up token number
.macro define_token token
.segment "DUMMY"
.ifnblank token
token := <(*-DUMMY_START)+$80
.endif
.res 1; count up in any case
.endmacro
; lay down a keyword, optionally define a token symbol
.macro keyword key, token
.segment "KEYWORDS"
htasc key
define_token token
.endmacro
; lay down a keyword and an address (RTS style),
; optionally define a token symbol
.macro keyword_rts key, vec, token
.segment "VECTORS"
.word vec-1
keyword key, token
.endmacro
; lay down a keyword and an address,
; optionally define a token symbol
.macro keyword_addr key, vec, token
.segment "VECTORS"
.addr vec
keyword key, token
.endmacro
.macro count_tokens
.segment "DUMMY"
NUM_TOKENS := <(*-DUMMY_START)
.endmacro
.macro init_error_table
.segment "ERROR"
ERROR_MESSAGES:
.endmacro
.macro define_error error, msg
.segment "ERROR"
error := <(*-ERROR_MESSAGES)
htasc msg
.endmacro
;---------------------------------------------
; set the MSB of every byte of a string
.macro asc80 str
.repeat .strlen(str),I
.byte .strat(str,I)+$80
.endrep
.endmacro
|
6502-retro/6502-retro-os
| 2,098
|
apps/msbasic/zeropage.s
|
.feature org_per_seg
.zeropage
.org ZP_START1
GORESTART:
.res 3
GOSTROUT:
.res 3
GOAYINT:
.res 2
GOGIVEAYF:
.res 2
.org ZP_START2
Z15:
.res 1
.ifndef POSX; allow override
POSX:
.endif
.res 1
.ifndef Z17; allow override
Z17:
.endif
.res 1
.ifndef Z18; allow override
Z18:
.endif
.res 1
LINNUM:
.ifndef TXPSV; allow override
TXPSV:
.endif
.res 2
.ifndef INPUTBUFFER; allow override
INPUTBUFFER:
.endif
.org ZP_START3
CHARAC:
.res 1
ENDCHR:
.res 1
EOLPNTR:
.res 1
DIMFLG:
.res 1
VALTYP:
.ifdef CONFIG_SMALL
.res 1
.else
.res 2
.endif
DATAFLG:
.res 1
SUBFLG:
.res 1
INPUTFLG:
.res 1
CPRMASK:
.res 1
Z14:
.res 1
.org ZP_START4
TEMPPT:
.res 1
LASTPT:
.res 2
TEMPST:
.res 9
INDEX:
.res 2
DEST:
.res 2
RESULT:
.res BYTES_FP
RESULT_LAST = RESULT + BYTES_FP-1
TXTTAB:
.res 2
VARTAB:
.res 2
ARYTAB:
.res 2
STREND:
.res 2
FRETOP:
.res 2
FRESPC:
.res 2
MEMSIZ:
.res 2
CURLIN:
.res 2
OLDLIN:
.res 2
OLDTEXT:
.res 2
Z8C:
.res 2
DATPTR:
.res 2
INPTR:
.res 2
VARNAM:
.res 2
VARPNT:
.res 2
FORPNT:
.res 2
LASTOP:
.res 2
CPRTYP:
.res 1
FNCNAM:
TEMP3:
.res 2
DSCPTR:
.ifdef CONFIG_SMALL
.res 2
.else
.res 3
.endif
DSCLEN:
.res 2
.ifndef JMPADRS ; allow override
JMPADRS := DSCLEN + 1
.endif
Z52:
.res 1
ARGEXTENSION:
.ifndef CONFIG_SMALL
.res 1
.endif
TEMP1:
.res 1
HIGHDS:
.res 2
HIGHTR:
.res 2
.ifndef CONFIG_SMALL
TEMP2:
.res 1
.endif
INDX:
TMPEXP:
.ifdef CONFIG_SMALL
TEMP2:
.endif
.res 1
EXPON:
.res 1
LOWTR:
.ifndef LOWTRX ; allow override
LOWTRX:
.endif
.res 1
EXPSGN:
.res 1
FAC:
.res BYTES_FP
FAC_LAST = FAC + BYTES_FP-1
FACSIGN:
.res 1
SERLEN:
.res 1
SHIFTSIGNEXT:
.res 1
ARG:
.res BYTES_FP
ARG_LAST = ARG + BYTES_FP-1
ARGSIGN:
.res 1
STRNG1:
.res 2
SGNCPR = STRNG1
FACEXTENSION = STRNG1+1
STRNG2:
.res 2
.ifdef AIM65
ATN:
.res 3
ZBE:
.res 1
.endif
.ifdef SYM1
USR1:
.res 3
USR2:
.res 3
USR3:
.res 3
.endif
CHRGET:
TXTPTR = <(GENERIC_TXTPTR-GENERIC_CHRGET + CHRGET)
CHRGOT = <(GENERIC_CHRGOT-GENERIC_CHRGET + CHRGET)
CHRGOT2 = <(GENERIC_CHRGOT2-GENERIC_CHRGET + CHRGET)
RNDSEED = <(GENERIC_RNDSEED-GENERIC_CHRGET + CHRGET)
|
6502-retro/6502-retro-os
| 1,370
|
apps/msbasic/kim_loadsave.s
|
.segment "CODE"
SAVE:
tsx
stx INPUTFLG
lda #$37
sta $F2
lda #$FE
sta $17F9
lda TXTTAB
ldy TXTTAB+1
sta $17F5
sty $17F6
lda VARTAB
ldy VARTAB+1
sta $17F7
sty $17F8
jmp L1800
ldx INPUTFLG
txs
lda #<QT_SAVED
ldy #>QT_SAVED
jmp STROUT
QT_LOADED:
.byte "LOADED"
.byte $00
QT_SAVED:
.byte "SAVED"
.byte $0D,$0A,$00,$00,$00,$00,$00,$00
.byte $00,$00,$00,$00,$00,$00,$00,$00
.byte $00,$00,$00,$00,$00,$00,$00
LOAD:
lda TXTTAB
ldy TXTTAB+1
sta $17F5
sty $17F6
lda #$FF
sta $17F9
lda #<L27A6
ldy #>L27A6
sta GORESTART+1
sty GORESTART+2
jmp L1873
L27A6:
ldx #$FF
txs
lda #<RESTART
ldy #>RESTART
sta GORESTART+1
sty GORESTART+2
lda #<QT_LOADED
ldy #>QT_LOADED
jsr STROUT
ldx $17ED
ldy $17EE
txa
bne L27C2
nop
L27C2:
nop
stx VARTAB
sty VARTAB+1
jmp FIX_LINKS
|
6502-retro/6502-retro-os
| 17,381
|
apps/msbasic/eval.s
|
.segment "CODE"
; ----------------------------------------------------------------------------
; "NEXT" STATEMENT
; ----------------------------------------------------------------------------
NEXT:
bne NEXT1
ldy #$00
beq NEXT2
NEXT1:
jsr PTRGET
NEXT2:
sta FORPNT
sty FORPNT+1
jsr GTFORPNT
beq NEXT3
ldx #$00
GERR:
beq JERROR
NEXT3:
txs
.ifndef CONFIG_2
inx
inx
inx
inx
.endif
txa
.ifdef CONFIG_2
clc
adc #$04
pha
adc #BYTES_FP+1
sta DEST
pla
.else
inx
inx
inx
inx
inx
.ifndef CONFIG_SMALL
inx
.endif
stx DEST
.endif
ldy #>STACK
jsr LOAD_FAC_FROM_YA
tsx
lda STACK+BYTES_FP+4,x
sta FACSIGN
lda FORPNT
ldy FORPNT+1
jsr FADD
jsr SETFOR
ldy #>STACK
jsr FCOMP2
tsx
sec
sbc STACK+BYTES_FP+4,x
beq L2C22
lda STACK+2*BYTES_FP+5,x
sta CURLIN
lda STACK+2*BYTES_FP+6,x
sta CURLIN+1
lda STACK+2*BYTES_FP+8,x
sta TXTPTR
lda STACK+2*BYTES_FP+7,x
sta TXTPTR+1
L2C1F:
jmp NEWSTT
L2C22:
txa
adc #2*BYTES_FP+7
tax
txs
jsr CHRGOT
cmp #$2C
bne L2C1F
jsr CHRGET
jsr NEXT1
; ----------------------------------------------------------------------------
; EVALUATE EXPRESSION, MAKE SURE IT IS NUMERIC
; ----------------------------------------------------------------------------
FRMNUM:
jsr FRMEVL
; ----------------------------------------------------------------------------
; MAKE SURE (FAC) IS NUMERIC
; ----------------------------------------------------------------------------
CHKNUM:
clc
.byte $24
; ----------------------------------------------------------------------------
; MAKE SURE (FAC) IS STRING
; ----------------------------------------------------------------------------
CHKSTR:
sec
; ----------------------------------------------------------------------------
; MAKE SURE (FAC) IS CORRECT TYPE
; IF C=0, TYPE MUST BE NUMERIC
; IF C=1, TYPE MUST BE STRING
; ----------------------------------------------------------------------------
CHKVAL:
bit VALTYP
bmi L2C41
bcs L2C43
L2C40:
rts
L2C41:
bcs L2C40
L2C43:
ldx #ERR_BADTYPE
JERROR:
jmp ERROR
; ----------------------------------------------------------------------------
; EVALUATE THE EXPRESSION AT TXTPTR, LEAVING THE
; RESULT IN FAC. WORKS FOR BOTH STRING AND NUMERIC
; EXPRESSIONS.
; ----------------------------------------------------------------------------
FRMEVL:
ldx TXTPTR
bne L2C4E
dec TXTPTR+1
L2C4E:
dec TXTPTR
ldx #$00
.byte $24
FRMEVL1:
pha
txa
pha
lda #$01
jsr CHKMEM
jsr FRM_ELEMENT
lda #$00
sta CPRTYP
FRMEVL2:
jsr CHRGOT
L2C65:
sec
sbc #TOKEN_GREATER
bcc L2C81
cmp #$03
bcs L2C81
cmp #$01
rol a
eor #$01
eor CPRTYP
cmp CPRTYP
bcc SNTXERR
sta CPRTYP
jsr CHRGET
jmp L2C65
L2C81:
ldx CPRTYP
bne FRM_RELATIONAL
bcs L2D02
adc #$07
bcc L2D02
adc VALTYP
bne L2C92
jmp CAT
L2C92:
adc #$FF
sta INDEX
asl a
adc INDEX
tay
FRM_PRECEDENCE_TEST:
pla
cmp MATHTBL,y
bcs FRM_PERFORM1
jsr CHKNUM
L2CA3:
pha
L2CA4:
jsr FRM_RECURSE
pla
ldy LASTOP
bpl PREFNC
tax
beq GOEX
bne FRM_PERFORM2
; ----------------------------------------------------------------------------
; FOUND ONE OR MORE RELATIONAL OPERATORS <,=,>
; ----------------------------------------------------------------------------
FRM_RELATIONAL:
lsr VALTYP
txa
rol a
ldx TXTPTR
bne L2CBB
dec TXTPTR+1
L2CBB:
dec TXTPTR
ldy #$1B
sta CPRTYP
bne FRM_PRECEDENCE_TEST
PREFNC:
cmp MATHTBL,y
bcs FRM_PERFORM2
bcc L2CA3
; ----------------------------------------------------------------------------
; STACK THIS OPERATION AND CALL FRMEVL FOR
; ANOTHER ONE
; ----------------------------------------------------------------------------
FRM_RECURSE:
lda MATHTBL+2,y
pha
lda MATHTBL+1,y
pha
jsr FRM_STACK1
lda CPRTYP
jmp FRMEVL1
SNTXERR:
jmp SYNERR
; ----------------------------------------------------------------------------
; STACK (FAC)
; THREE ENTRY POINTS:
; 1, FROM FRMEVL
; 2, FROM "STEP"
; 3, FROM "FOR"
; ----------------------------------------------------------------------------
FRM_STACK1:
lda FACSIGN
ldx MATHTBL,y
; ----------------------------------------------------------------------------
; ENTER HERE FROM "STEP", TO PUSH STEP SIGN AND VALUE
; ----------------------------------------------------------------------------
FRM_STACK2:
tay
pla
sta INDEX
.ifndef CONFIG_2B
inc INDEX ; bug: assumes not on page boundary
; bug exists on AppleSoft II
.endif
pla
sta INDEX+1
.ifdef CONFIG_2B
inc INDEX
bne LEB69
inc INDEX+1
LEB69:
.endif
tya
pha
; ----------------------------------------------------------------------------
; ENTER HERE FROM "FOR", WITH (INDEX) = STEP,
; TO PUSH INITIAL VALUE OF "FOR" VARIABLE
; ----------------------------------------------------------------------------
FRM_STACK3:
jsr ROUND_FAC
.ifndef CONFIG_SMALL
lda FAC+4
pha
.endif
lda FAC+3
pha
lda FAC+2
pha
lda FAC+1
pha
lda FAC
pha
jmp (INDEX)
L2D02:
ldy #$FF
pla
GOEX:
beq EXIT
; ----------------------------------------------------------------------------
; PERFORM STACKED OPERATION
;
; (A) = PRECEDENCE BYTE
; STACK: 1 -- CPRMASK
; 5 -- (ARG)
; 2 -- ADDR OF PERFORMER
; ----------------------------------------------------------------------------
FRM_PERFORM1:
cmp #$64
beq L2D0E
jsr CHKNUM
L2D0E:
sty LASTOP
FRM_PERFORM2:
pla
lsr a
sta CPRMASK
pla
sta ARG
pla
sta ARG+1
pla
sta ARG+2
pla
sta ARG+3
pla
.ifndef CONFIG_SMALL
sta ARG+4
pla
.endif
sta ARGSIGN
eor FACSIGN
sta SGNCPR
EXIT:
lda FAC
rts
; ----------------------------------------------------------------------------
; GET ELEMENT IN EXPRESSION
;
; GET VALUE OF VARIABLE OR NUMBER AT TXTPNT, OR POINT
; TO STRING DESCRIPTOR IF A STRING, AND PUT IN FAC.
; ----------------------------------------------------------------------------
FRM_ELEMENT:
lda #$00
sta VALTYP
L2D31:
jsr CHRGET
bcs L2D39
L2D36:
jmp FIN
L2D39:
jsr ISLETC
bcs FRM_VARIABLE
.ifdef CONFIG_CBM_ALL
cmp #$FF
bne LCDC1
lda #<CON_PI
ldy #>CON_PI
jsr LOAD_FAC_FROM_YA
jmp CHRGET
CON_PI:
.byte $82,$49,$0f,$DA,$A1
LCDC1:
.endif
cmp #$2E
beq L2D36
cmp #TOKEN_MINUS
beq MIN
cmp #TOKEN_PLUS
beq L2D31
cmp #$22
bne NOT_
; ----------------------------------------------------------------------------
; STRING CONSTANT ELEMENT
;
; SET Y,A = (TXTPTR)+CARRY
; ----------------------------------------------------------------------------
STRTXT:
lda TXTPTR
ldy TXTPTR+1
adc #$00
bcc L2D57
iny
L2D57:
jsr STRLIT
jmp POINT
; ----------------------------------------------------------------------------
; "NOT" FUNCTION
; IF FAC=0, RETURN FAC=1
; IF FAC<>0, RETURN FAC=0
; ----------------------------------------------------------------------------
NOT_:
cmp #TOKEN_NOT
bne L2D74
ldy #$18
bne EQUL
; ----------------------------------------------------------------------------
; COMPARISON FOR EQUALITY (= OPERATOR)
; ALSO USED TO EVALUATE "NOT" FUNCTION
; ----------------------------------------------------------------------------
EQUOP:
jsr AYINT
lda FAC_LAST
eor #$FF
tay
lda FAC_LAST-1
eor #$FF
jmp GIVAYF
L2D74:
.ifdef SYM1
cmp #TOKEN_USR
bne LCC8A
jmp LCDBD
LCC8A:
cmp #$26
bne LCC91
jmp LCDFE
LCC91:
.endif
cmp #TOKEN_FN
bne L2D7B
jmp L31F3
L2D7B:
cmp #TOKEN_SGN
bcc PARCHK
jmp UNARY
; ----------------------------------------------------------------------------
; EVALUATE "(EXPRESSION)"
; ----------------------------------------------------------------------------
PARCHK:
jsr CHKOPN
jsr FRMEVL
CHKCLS:
lda #$29
.byte $2C
CHKOPN:
lda #$28
.byte $2C
CHKCOM:
lda #$2C
; ----------------------------------------------------------------------------
; UNLESS CHAR AT TXTPTR = (A), SYNTAX ERROR
; ----------------------------------------------------------------------------
SYNCHR: ; XXX all CBM code calls SYNCHR instead of CHKCOM
ldy #$00
cmp (TXTPTR),y
bne SYNERR
jmp CHRGET
; ----------------------------------------------------------------------------
SYNERR:
ldx #ERR_SYNTAX
jmp ERROR
; ----------------------------------------------------------------------------
MIN:
ldy #$15
EQUL:
pla
pla
jmp L2CA4
; ----------------------------------------------------------------------------
FRM_VARIABLE:
jsr PTRGET
FRM_VARIABLE_CALL = *-1
sta FAC_LAST-1
sty FAC_LAST
.ifdef CONFIG_CBM_ALL
lda VARNAM
ldy VARNAM+1
.endif
ldx VALTYP
beq L2DB1
.ifdef CONFIG_CBM_ALL
.ifdef CONFIG_CBM1_PATCHES
jmp PATCH2
clc
LCE3B:
.else
ldx #$00
stx STRNG1+1
bit FAC+4
bpl LCE53
cmp #$54 ; T
bne LCE53
.endif
cpy #$C9 ; I$
bne LCE53
jsr LCE76
sty EXPON
dey
sty STRNG2
ldy #$06
sty INDX
ldy #$24
jsr LDD3A
jmp LD353
LCE53:
.endif
.ifdef CONFIG_2
.ifndef CBM2
; bugfix?
; fixed on AppleSoft II, not on any CBM
ldx #$00
stx STRNG1+1
.endif
.endif
rts
L2DB1:
.ifndef CONFIG_SMALL
ldx VALTYP+1
bpl L2DC2
ldy #$00
lda (FAC+3),y
tax
iny
lda (FAC+3),y
tay
txa
jmp GIVAYF
L2DC2:
.endif
.ifdef CONFIG_CBM1_PATCHES
jmp PATCH3
.byte $19
.endif
.ifdef CBM2
bit FAC+4
bpl LCE90
cmp #$54
bne LCE82
.endif
.ifndef CONFIG_CBM_ALL
jmp LOAD_FAC_FROM_YA
.endif
.ifdef CONFIG_CBM_ALL
LCE69:
cpy #$49
.ifdef CBM1
bne LCE82
.else
bne LCE90
.endif
jsr LCE76
tya
ldx #$A0
jmp LDB21
LCE76:
.ifdef CBM1
lda #$FE
ldy #$01
.else
lda #$8B
ldy #$00
.endif
sei
jsr LOAD_FAC_FROM_YA
cli
sty FAC+1
rts
LCE82:
cmp #$53
bne LCE90
cpy #$54
bne LCE90
lda Z96
jmp FLOAT
LCE90:
lda FAC+3
ldy FAC+4
jmp LOAD_FAC_FROM_YA
.endif
; ----------------------------------------------------------------------------
UNARY:
asl a
pha
tax
jsr CHRGET
cpx #<(TOKEN_LEFTSTR*2-1)
bcc L2DEF
jsr CHKOPN
jsr FRMEVL
jsr CHKCOM
jsr CHKSTR
pla
tax
lda FAC_LAST
pha
lda FAC_LAST-1
pha
txa
pha
jsr GETBYT
pla
tay
txa
pha
jmp L2DF4
L2DEF:
jsr PARCHK
pla
tay
L2DF4:
lda UNFNC-TOKEN_SGN-TOKEN_SGN+$100,y
sta JMPADRS+1
lda UNFNC-TOKEN_SGN-TOKEN_SGN+$101,y
sta JMPADRS+2
.ifdef KBD
jsr LF47D
.else
jsr JMPADRS
.endif
jmp CHKNUM
; ----------------------------------------------------------------------------
OR:
ldy #$FF
.byte $2C
; ----------------------------------------------------------------------------
TAND:
ldy #$00
sty EOLPNTR
jsr AYINT
lda FAC_LAST-1
eor EOLPNTR
sta CHARAC
lda FAC_LAST
eor EOLPNTR
sta ENDCHR
jsr COPY_ARG_TO_FAC
jsr AYINT
lda FAC_LAST
eor EOLPNTR
and ENDCHR
eor EOLPNTR
tay
lda FAC_LAST-1
eor EOLPNTR
and CHARAC
eor EOLPNTR
jmp GIVAYF
; ----------------------------------------------------------------------------
; PERFORM RELATIONAL OPERATIONS
; ----------------------------------------------------------------------------
RELOPS:
jsr CHKVAL
bcs STRCMP
lda ARGSIGN
ora #$7F
and ARG+1
sta ARG+1
lda #<ARG
ldy #$00
jsr FCOMP
tax
jmp NUMCMP
; ----------------------------------------------------------------------------
; STRING COMPARISON
; ----------------------------------------------------------------------------
STRCMP:
lda #$00
sta VALTYP
dec CPRTYP
jsr FREFAC
sta FAC
stx FAC+1
sty FAC+2
lda ARG_LAST-1
ldy ARG_LAST
jsr FRETMP
stx ARG_LAST-1
sty ARG_LAST
tax
sec
sbc FAC
beq L2E74
lda #$01
bcc L2E74
ldx FAC
lda #$FF
L2E74:
sta FACSIGN
ldy #$FF
inx
STRCMP1:
iny
dex
bne L2E84
ldx FACSIGN
NUMCMP:
bmi CMPDONE
clc
bcc CMPDONE
L2E84:
lda (ARG_LAST-1),y
cmp (FAC+1),y
beq STRCMP1
ldx #$FF
bcs CMPDONE
ldx #$01
CMPDONE:
inx
txa
rol a
and CPRMASK
beq L2E99
lda #$FF
L2E99:
jmp FLOAT
.ifdef SYM1
LCDBD:
jsr CHRGET
jsr CHKOPN
jsr FRMEVL
jsr CHRGOT
cmp #$29
beq LCDF1
jsr AYINT
lda FAC+4
ldy FAC+3
sta USR+1
sty USR+2
LCDD8:
jsr CHKCOM
jsr FRMEVL
jsr CHRGOT
cmp #$29
beq LCDF1
jsr AYINT
lda FAC+3
pha
lda FAC+4
pha
jmp LCDD8
LCDF1:
jsr CHRGET
jsr AYINT
lda FAC+3
ldy FAC+4
jmp USR
LCDFE:
lda ZD4
pha
lda ZD3
pha
jsr CHRGET
cmp #$22
bne LCE49
jsr CHRGET
jsr LCE2B
tax
jsr CHRGOT
jsr LCE2B
pha
jsr CHRGOT
cmp #$22
bne LCE48
jsr CHRGET
pla
tay
pla
pla
txa
jmp GIVAYF
LCE2B:
jsr ASCNIB
bcs LCE47
pha
jsr CHRGET
jsr ASCNIB
sta FAC+4
bcs LCE46
jsr CHRGET
pla
asl a
asl a
asl a
asl a
ora FAC+4
rts
LCE46:
pla
LCE47:
pla
LCE48:
pla
LCE49:
pla
sta ZD3
pla
sta ZD4
jmp ZERO_FAC
.endif
|
6502-retro/6502-retro-os
| 1,032
|
apps/msbasic/defines_cbm1.s
|
; configuration
; oldest known version, no CONFIG_n
CONFIG_CBM_ALL := 1
CONFIG_CBM1_PATCHES := 1 ; ** don't turn off! **
CONFIG_DATAFLG := 1
CONFIG_FILE := 1; support PRINT#, INPUT#, GET#, CMD
CONFIG_NO_CR := 1; terminal doesn't need explicit CRs on line ends
CONFIG_NO_LINE_EDITING := 1; support for "@", "_", BEL etc.
CONFIG_PRINTNULLS := 1; whether PRINTNULLS does anything
CONFIG_SCRTCH_ORDER := 2
; zero page
ZP_START1 = $00
ZP_START2 = $04
ZP_START3 = $5A
ZP_START4 = $65
; extra ZP variables
CURDVC := $0003
TISTR := $0200
Z96 := $020C
USR := GORESTART
; constants
SPACE_FOR_GOSUB := $36
STACK_TOP := $FC
NULL_MAX := $0A
MAX_EXPON := 12 ; XXX override
RAMSTART2 := $0400
; magic memory locations
ENTROPY = $9044
; monitor functions
OPEN := $FFC0
CLOSE := $FFC3
CHKIN := $FFC6
CHKOUT := $FFC9
CLRCH := $FFCC
CHRIN := $FFCF
CHROUT := $FFD2
LOAD := $FFD5
SAVE := $FFD8
VERIFY := $FFDB
SYS := $FFDE
ISCNTC := $FFE1
GETIN := $FFE4
CLALL := $FFE7
LE7F3 := $E7F3; for CBM1
MONCOUT := CHROUT
MONRDKEY := GETIN
|
6502-retro/6502-retro-os
| 5,524
|
apps/msbasic/trig.s
|
.segment "CODE"
.ifndef SYM1
SIN_COS_TAN_ATN:
; ----------------------------------------------------------------------------
; "COS" FUNCTION
; ----------------------------------------------------------------------------
COS:
lda #<CON_PI_HALF
ldy #>CON_PI_HALF
jsr FADD
; ----------------------------------------------------------------------------
; "SIN" FUNCTION
; ----------------------------------------------------------------------------
SIN:
jsr COPY_FAC_TO_ARG_ROUNDED
lda #<CON_PI_DOUB
ldy #>CON_PI_DOUB
ldx ARGSIGN
jsr DIV
jsr COPY_FAC_TO_ARG_ROUNDED
jsr INT
lda #$00
sta STRNG1
jsr FSUBT
; ----------------------------------------------------------------------------
; (FAC) = ANGLE AS A FRACTION OF A FULL CIRCLE
;
; NOW FOLD THE RANGE INTO A QUARTER CIRCLE
;
; <<< THERE ARE MUCH SIMPLER WAYS TO DO THIS >>>
; ----------------------------------------------------------------------------
lda #<QUARTER
ldy #>QUARTER
jsr FSUB
lda FACSIGN
pha
bpl SIN1
jsr FADDH
lda FACSIGN
bmi L3F5B
lda CPRMASK
eor #$FF
sta CPRMASK
; ----------------------------------------------------------------------------
; IF FALL THRU, RANGE IS 0...1/2
; IF BRANCH HERE, RANGE IS 0...1/4
; ----------------------------------------------------------------------------
SIN1:
jsr NEGOP
; ----------------------------------------------------------------------------
; IF FALL THRU, RANGE IS -1/2...0
; IF BRANCH HERE, RANGE IS -1/4...0
; ----------------------------------------------------------------------------
L3F5B:
lda #<QUARTER
ldy #>QUARTER
jsr FADD
pla
bpl L3F68
jsr NEGOP
L3F68:
lda #<POLY_SIN
ldy #>POLY_SIN
jmp POLYNOMIAL_ODD
; ----------------------------------------------------------------------------
; "TAN" FUNCTION
;
; COMPUTE TAN(X) = SIN(X) / COS(X)
; ----------------------------------------------------------------------------
TAN:
jsr STORE_FAC_IN_TEMP1_ROUNDED
lda #$00
sta CPRMASK
jsr SIN
ldx #TEMP3
ldy #$00
jsr GOMOVMF
lda #TEMP1+(5-BYTES_FP)
ldy #$00
jsr LOAD_FAC_FROM_YA
lda #$00
sta FACSIGN
lda CPRMASK
jsr TAN1
lda #TEMP3
ldy #$00
jmp FDIV
TAN1:
pha
jmp SIN1
; ----------------------------------------------------------------------------
.ifdef CONFIG_SMALL
CON_PI_HALF:
.byte $81,$49,$0F,$DB
CON_PI_DOUB:
.byte $83,$49,$0F,$DB
QUARTER:
.byte $7F,$00,$00,$00
POLY_SIN:
.byte $04,$86,$1E,$D7,$FB,$87,$99,$26
.byte $65,$87,$23,$34,$58,$86,$A5,$5D
.byte $E1,$83,$49,$0F,$DB
.else
CON_PI_HALF:
.byte $81,$49,$0F,$DA,$A2
CON_PI_DOUB:
.byte $83,$49,$0F,$DA,$A2
QUARTER:
.byte $7F,$00,$00,$00,$00
POLY_SIN:
.byte $05,$84,$E6,$1A,$2D,$1B,$86,$28
.byte $07,$FB,$F8,$87,$99,$68,$89,$01
.byte $87,$23,$35,$DF,$E1,$86,$A5,$5D
.byte $E7,$28,$83,$49,$0F,$DA,$A2
.ifndef CONFIG_11
; no easter egg text before BASIC 1.1
.elseif !.def(CONFIG_2A)
; ASCII encoded easter egg
MICROSOFT:
.byte $A6,$D3,$C1,$C8,$D4,$C8,$D5,$C4
.byte $CE,$CA
.else
; PET encoded easter egg text since CBM2
MICROSOFT:
.byte $A1,$54,$46,$8F,$13,$8F,$52,$43
.byte $89,$CD
.endif
.endif
.ifndef AIM65
; ----------------------------------------------------------------------------
; "ATN" FUNCTION
; ----------------------------------------------------------------------------
ATN:
lda FACSIGN
pha
bpl L3FDB
jsr NEGOP
L3FDB:
lda FAC
pha
cmp #$81
bcc L3FE9
lda #<CON_ONE
ldy #>CON_ONE
jsr FDIV
; ----------------------------------------------------------------------------
; 0 <= X <= 1
; 0 <= ATN(X) <= PI/8
; ----------------------------------------------------------------------------
L3FE9:
lda #<POLY_ATN
ldy #>POLY_ATN
jsr POLYNOMIAL_ODD
pla
cmp #$81
bcc L3FFC
lda #<CON_PI_HALF
ldy #>CON_PI_HALF
jsr FSUB
L3FFC:
pla
bpl L4002
jmp NEGOP
L4002:
rts
; ----------------------------------------------------------------------------
POLY_ATN:
.ifdef CONFIG_SMALL
.byte $08
.byte $78,$3A,$C5,$37
.byte $7B,$83,$A2,$5C
.byte $7C,$2E,$DD,$4D
.byte $7D,$99,$B0,$1E
.byte $7D,$59,$ED,$24
.byte $7E,$91,$72,$00
.byte $7E,$4C,$B9,$73
.byte $7F,$AA,$AA,$53
.byte $81,$00,$00,$00
.else
.byte $0B
.byte $76,$B3,$83,$BD,$D3
.byte $79,$1E,$F4,$A6,$F5
.byte $7B,$83,$FC,$B0,$10
.byte $7C,$0C,$1F,$67,$CA
.byte $7C,$DE,$53,$CB,$C1
.byte $7D,$14,$64,$70,$4C
.byte $7D,$B7,$EA,$51,$7A
.byte $7D,$63,$30,$88,$7E
.byte $7E,$92,$44,$99,$3A
.byte $7E,$4C,$CC,$91,$C7
.byte $7F,$AA,$AA,$AA,$13
.byte $81,$00,$00,$00,$00
.endif
.if .def(CONFIG_11A) && (!.def(CONFIG_2))
.byte $00 ; XXX
.endif
.endif
.endif
|
6502-retro/6502-retro-os
| 1,462
|
apps/msbasic/misc3.s
|
; KBD specific patches
.segment "CODE"
.ifdef KBD
VARTAB_MINUS_2_TO_AY:
lda VARTAB
sec
sbc #$02
ldy VARTAB+1
bcs LF42C
dey
LF42C:
rts
; ----------------------------------------------------------------------------
GET_UPPER:
lda INPUTBUFFERX,x
LF430:
cmp #'a'
bcc LF43A
cmp #'z'+1
bcs LF43A
LF438:
sbc #$1F
LF43A:
rts
; ----------------------------------------------------------------------------
GETLN:
ldx #$5D
LF43D:
txa
and #$7F
cmp $0340
beq LF44D
sta $0340
lda #$03
jsr LDE48
LF44D:
jsr LDE7F
bne RTS4
cpx #$80
bcc LF44D
RTS4:
rts
; ----------------------------------------------------------------------------
LF457:
lda TXTTAB
ldx TXTTAB+1
LF45B:
sta JMPADRS+1
stx JMPADRS+2
ldy #$01
lda (JMPADRS+1),y
beq LF438
iny
iny
lda (JMPADRS+1),y
dey
cmp LINNUM+1
bne LF472
lda (JMPADRS+1),y
cmp LINNUM
LF472:
bcs LF43A
dey
lda (JMPADRS+1),y
tax
dey
lda (JMPADRS+1),y
bcc LF45B
LF47D:
jmp (JMPADRS+1)
.endif
|
6502-retro/6502-retro-os
| 17,355
|
apps/msbasic/program.s
|
; error
; line input, line editing
; tokenize
; detokenize
; BASIC program memory management
; MICROTAN has some nonstandard extension to LIST here
.segment "CODE"
MEMERR:
ldx #ERR_MEMFULL
; ----------------------------------------------------------------------------
; HANDLE AN ERROR
;
; (X)=OFFSET IN ERROR MESSAGE TABLE
; (ERRFLG) > 128 IF "ON ERR" TURNED ON
; (CURLIN+1) = $FF IF IN DIRECT MODE
; ----------------------------------------------------------------------------
ERROR:
lsr Z14
.ifdef CONFIG_FILE
lda CURDVC ; output
beq LC366 ; is screen
jsr CLRCH ; otherwise redirect output back to screen
lda #$00
sta CURDVC
LC366:
.endif
jsr CRDO
jsr OUTQUES
L2329:
lda ERROR_MESSAGES,x
.ifndef CONFIG_SMALL_ERROR
pha
and #$7F
.endif
jsr OUTDO
.ifdef CONFIG_SMALL_ERROR
lda ERROR_MESSAGES+1,x
.ifdef KBD
and #$7F
.endif
jsr OUTDO
.else
inx
pla
bpl L2329
.endif
jsr STKINI
lda #<QT_ERROR
ldy #>QT_ERROR
; ----------------------------------------------------------------------------
; PRINT STRING AT (Y,A)
; PRINT CURRENT LINE # UNLESS IN DIRECT MODE
; FALL INTO WARM RESTART
; ----------------------------------------------------------------------------
PRINT_ERROR_LINNUM:
jsr STROUT
ldy CURLIN+1
iny
beq RESTART
jsr INPRT
; ----------------------------------------------------------------------------
; WARM RESTART ENTRY
; ----------------------------------------------------------------------------
RESTART:
.ifdef KBD
jsr CRDO
nop
L2351X:
jsr OKPRT
L2351:
jsr INLIN
LE28E:
bpl RESTART
.else
lsr Z14
.ifndef AIM65
lda #<QT_OK
ldy #>QT_OK
.ifdef CONFIG_CBM_ALL
jsr STROUT
.else
jsr GOSTROUT
.endif
.else
jsr GORESTART
.endif
L2351:
jsr INLIN
.endif
stx TXTPTR
sty TXTPTR+1
jsr CHRGET
.ifdef CONFIG_11
; bug in pre-1.1: CHRGET sets Z on '\0'
; and ':' - a line starting with ':' in
; direct mode gets ignored
tax
.endif
.ifdef KBD
beq L2351X
.else
beq L2351
.endif
ldx #$FF
stx CURLIN+1
bcc NUMBERED_LINE
jsr PARSE_INPUT_LINE
jmp NEWSTT2
; ----------------------------------------------------------------------------
; HANDLE NUMBERED LINE
; ----------------------------------------------------------------------------
NUMBERED_LINE:
jsr LINGET
jsr PARSE_INPUT_LINE
sty EOLPNTR
.ifdef KBD
jsr FNDLIN2
lda JMPADRS+1
sta LOWTR
sta Z96
lda JMPADRS+2
sta LOWTR+1
sta Z96+1
lda LINNUM
sta L06FE
lda LINNUM+1
sta L06FE+1
inc LINNUM
bne LE2D2
inc LINNUM+1
bne LE2D2
jmp SYNERR
LE2D2:
jsr LF457
ldx #Z96
jsr CMPJMPADRS
bcs LE2FD
LE2DC:
ldx #$00
lda (JMPADRS+1,x)
sta (Z96,x)
inc JMPADRS+1
bne LE2E8
inc JMPADRS+2
LE2E8:
inc Z96
bne LE2EE
inc Z96+1
LE2EE:
ldx #VARTAB
jsr CMPJMPADRS
bne LE2DC
lda Z96
sta VARTAB
lda Z96+1
sta VARTAB+1
LE2FD:
jsr SETPTRS
jsr LE33D
lda INPUTBUFFER
LE306:
beq LE28E
cmp #$A5
beq LE306
clc
.else
jsr FNDLIN
bcc PUT_NEW_LINE
ldy #$01
lda (LOWTR),y
sta INDEX+1
lda VARTAB
sta INDEX
lda LOWTR+1
sta DEST+1
lda LOWTR
dey
sbc (LOWTR),y
clc
adc VARTAB
sta VARTAB
sta DEST
lda VARTAB+1
adc #$FF
sta VARTAB+1
sbc LOWTR+1
tax
sec
lda LOWTR
sbc VARTAB
tay
bcs L23A5
inx
dec DEST+1
L23A5:
clc
adc INDEX
bcc L23AD
dec INDEX+1
clc
L23AD:
lda (INDEX),y
sta (DEST),y
iny
bne L23AD
inc INDEX+1
inc DEST+1
dex
bne L23AD
.endif
; ----------------------------------------------------------------------------
PUT_NEW_LINE:
.ifndef KBD
.ifdef CONFIG_2
jsr SETPTRS
jsr LE33D
lda INPUTBUFFER
beq L2351
clc
.else
lda INPUTBUFFER
beq FIX_LINKS
lda MEMSIZ
ldy MEMSIZ+1
sta FRETOP
sty FRETOP+1
.endif
.endif
lda VARTAB
sta HIGHTR
adc EOLPNTR
sta HIGHDS
ldy VARTAB+1
sty HIGHTR+1
bcc L23D6
iny
L23D6:
sty HIGHDS+1
jsr BLTU
.ifdef CONFIG_INPUTBUFFER_0200
lda LINNUM
ldy LINNUM+1
sta INPUTBUFFER-2
sty INPUTBUFFER-1
.endif
lda STREND
ldy STREND+1
sta VARTAB
sty VARTAB+1
ldy EOLPNTR
dey
; ---COPY LINE INTO PROGRAM-------
L23E6:
lda INPUTBUFFER-4,y
sta (LOWTR),y
dey
bpl L23E6
; ----------------------------------------------------------------------------
; CLEAR ALL VARIABLES
; RE-ESTABLISH ALL FORWARD LINKS
; ----------------------------------------------------------------------------
FIX_LINKS:
jsr SETPTRS
.ifdef CONFIG_2
jsr LE33D
jmp L2351
LE33D:
.endif
lda TXTTAB
ldy TXTTAB+1
sta INDEX
sty INDEX+1
clc
L23FA:
ldy #$01
lda (INDEX),y
.ifdef CONFIG_2
beq RET3
.else
jeq L2351
.endif
ldy #$04
L2405:
iny
lda (INDEX),y
bne L2405
iny
tya
adc INDEX
tax
ldy #$00
sta (INDEX),y
lda INDEX+1
adc #$00
iny
sta (INDEX),y
stx INDEX
sta INDEX+1
bcc L23FA ; always
; ----------------------------------------------------------------------------
.ifdef KBD
.include "kbd_loadsave.s"
.endif
.ifdef CONFIG_2
; !!! kbd_loadsave.s requires an RTS here!
RET3:
rts
.endif
.include "inline.s"
; ----------------------------------------------------------------------------
; TOKENIZE THE INPUT LINE
; ----------------------------------------------------------------------------
PARSE_INPUT_LINE:
ldx TXTPTR
ldy #$04
sty DATAFLG
L246C:
lda INPUTBUFFERX,x
.ifdef CONFIG_CBM_ALL
bpl LC49E
cmp #$FF
beq L24AC
inx
bne L246C
LC49E:
.endif
cmp #$20
beq L24AC
sta ENDCHR
cmp #$22
beq L24D0
bit DATAFLG
bvs L24AC
cmp #$3F
bne L2484
lda #TOKEN_PRINT
bne L24AC
L2484:
cmp #$30
bcc L248C
cmp #$3C
bcc L24AC
; ----------------------------------------------------------------------------
; SEARCH TOKEN NAME TABLE FOR MATCH STARTING
; WITH CURRENT CHAR FROM INPUT LINE
; ----------------------------------------------------------------------------
L248C:
sty STRNG2
ldy #$00
sty EOLPNTR
dey
stx TXTPTR
dex
L2496:
iny
L2497:
inx
L2498:
.ifdef KBD
jsr GET_UPPER
.else
lda INPUTBUFFERX,x
.ifndef CONFIG_2
cmp #$20
beq L2497
.endif
.endif
sec
sbc TOKEN_NAME_TABLE,y
beq L2496
cmp #$80
bne L24D7
ora EOLPNTR
; ----------------------------------------------------------------------------
; STORE CHARACTER OR TOKEN IN OUTPUT LINE
; ----------------------------------------------------------------------------
L24AA:
ldy STRNG2
L24AC:
inx
iny
sta INPUTBUFFER-5,y
lda INPUTBUFFER-5,y
beq L24EA
sec
sbc #$3A
beq L24BF
cmp #$49
bne L24C1
L24BF:
sta DATAFLG
L24C1:
sec
sbc #TOKEN_REM-':'
bne L246C
sta ENDCHR
; ----------------------------------------------------------------------------
; HANDLE LITERAL (BETWEEN QUOTES) OR REMARK,
; BY COPYING CHARS UP TO ENDCHR.
; ----------------------------------------------------------------------------
L24C8:
lda INPUTBUFFERX,x
beq L24AC
cmp ENDCHR
beq L24AC
L24D0:
iny
sta INPUTBUFFER-5,y
inx
bne L24C8
; ----------------------------------------------------------------------------
; ADVANCE POINTER TO NEXT TOKEN NAME
; ----------------------------------------------------------------------------
L24D7:
ldx TXTPTR
inc EOLPNTR
L24DB:
iny
lda MATHTBL+28+1,y
bpl L24DB
lda TOKEN_NAME_TABLE,y
bne L2498
lda INPUTBUFFERX,x
bpl L24AA
; ---END OF LINE------------------
L24EA:
sta INPUTBUFFER-3,y
.ifdef CONFIG_NO_INPUTBUFFER_ZP
dec TXTPTR+1
.endif
lda #<INPUTBUFFER-1
sta TXTPTR
rts
; ----------------------------------------------------------------------------
; SEARCH FOR LINE
;
; (LINNUM) = LINE # TO FIND
; IF NOT FOUND: CARRY = 0
; LOWTR POINTS AT NEXT LINE
; IF FOUND: CARRY = 1
; LOWTR POINTS AT LINE
; ----------------------------------------------------------------------------
FNDLIN:
.ifdef KBD
jsr CHRGET
jmp LE444
LE440:
php
jsr LINGET
LE444:
jsr LF457
ldx #$FF
plp
beq LE464
jsr CHRGOT
beq L2520
cmp #$A5
bne L2520
jsr CHRGET
beq LE464
bcs LE461
jsr LINGET
beq L2520
LE461:
jmp SYNERR
LE464:
stx LINNUM
stx LINNUM+1
.else
lda TXTTAB
ldx TXTTAB+1
FL1:
ldy #$01
sta LOWTR
stx LOWTR+1
lda (LOWTR),y
beq L251F
iny
iny
lda LINNUM+1
cmp (LOWTR),y
bcc L2520
beq L250D
dey
bne L2516
L250D:
lda LINNUM
dey
cmp (LOWTR),y
bcc L2520
beq L2520
L2516:
dey
lda (LOWTR),y
tax
dey
lda (LOWTR),y
bcs FL1
L251F:
clc
.endif
L2520:
rts
; ----------------------------------------------------------------------------
; "NEW" STATEMENT
; ----------------------------------------------------------------------------
NEW:
bne L2520
SCRTCH:
lda #$00
tay
sta (TXTTAB),y
iny
sta (TXTTAB),y
lda TXTTAB
.ifdef CONFIG_2
clc
.endif
adc #$02
sta VARTAB
lda TXTTAB+1
adc #$00
sta VARTAB+1
; ----------------------------------------------------------------------------
SETPTRS:
jsr STXTPT
.ifdef CONFIG_11A
lda #$00
; ----------------------------------------------------------------------------
; "CLEAR" STATEMENT
; ----------------------------------------------------------------------------
CLEAR:
bne L256A
.endif
CLEARC:
.ifdef KBD
lda #<CONST_MEMSIZ
ldy #>CONST_MEMSIZ
.else
lda MEMSIZ
ldy MEMSIZ+1
.endif
sta FRETOP
sty FRETOP+1
.ifdef CONFIG_CBM_ALL
jsr CLALL
.endif
lda VARTAB
ldy VARTAB+1
sta ARYTAB
sty ARYTAB+1
sta STREND
sty STREND+1
jsr RESTORE
; ----------------------------------------------------------------------------
STKINI:
ldx #TEMPST
stx TEMPPT
pla
.ifdef CONFIG_2
tay
.else
sta STACK+STACK_TOP+1
.endif
pla
.ifndef CONFIG_2
sta STACK+STACK_TOP+2
.endif
ldx #STACK_TOP
txs
.ifdef CONFIG_2
pha
tya
pha
.endif
lda #$00
sta OLDTEXT+1
sta SUBFLG
L256A:
rts
; ----------------------------------------------------------------------------
; SET TXTPTR TO BEGINNING OF PROGRAM
; ----------------------------------------------------------------------------
STXTPT:
clc
lda TXTTAB
adc #$FF
sta TXTPTR
lda TXTTAB+1
adc #$FF
sta TXTPTR+1
rts
; ----------------------------------------------------------------------------
.ifdef KBD
LE4C0:
ldy #<LE444
ldx #>LE444
LE4C4:
jsr LFFD6
jsr LFFED
lda $0504
clc
adc #$08
sta $0504
rts
CMPJMPADRS:
lda 1,x
cmp JMPADRS+2
bne LE4DE
lda 0,x
cmp JMPADRS+1
LE4DE:
rts
.endif
; ----------------------------------------------------------------------------
; "LIST" STATEMENT
; ----------------------------------------------------------------------------
LIST:
.ifdef KBD
jsr LE440
bne LE4DE
pla
pla
L25A6:
jsr CRDO
.else
.ifdef AIM65
pha
lda #$00
LB4BF:
sta INPUTFLG
pla
.endif
.ifdef MICROTAN
php
jmp LE21C ; patch
LC57E:
.elseif .def(AIM65) || .def(SYM1)
php
jsr LINGET
LC57E:
.else
bcc L2581
beq L2581
cmp #TOKEN_MINUS
bne L256A
L2581:
jsr LINGET
.endif
jsr FNDLIN
.if .def(MICROTAN) || .def(AIM65) || .def(SYM1)
plp
beq L2598
.endif
jsr CHRGOT
.if .def(MICROTAN) || .def(AIM65) || .def(SYM1)
beq L25A6
.else
beq L2598
.endif
cmp #TOKEN_MINUS
bne L2520
jsr CHRGET
.if .def(MICROTAN) || .def(AIM65) || .def(SYM1)
beq L2598
jsr LINGET
beq L25A6
rts
.else
jsr LINGET
bne L2520
.endif
L2598:
.if !(.def(MICROTAN) || .def(AIM65) || .def(SYM1))
pla
pla
lda LINNUM
ora LINNUM+1
bne L25A6
.endif
lda #$FF
sta LINNUM
sta LINNUM+1
L25A6:
.if .def(MICROTAN) || .def(AIM65) || .def(SYM1)
pla
pla
.endif
L25A6X:
.endif
ldy #$01
.ifdef CONFIG_DATAFLG
sty DATAFLG
.endif
lda (LOWTRX),y
beq L25E5
.ifdef MICROTAN
jmp LE21F
LC5A9:
.else
jsr ISCNTC
.endif
.ifndef KBD
jsr CRDO
.endif
iny
lda (LOWTRX),y
tax
iny
lda (LOWTRX),y
cmp LINNUM+1
bne L25C1
cpx LINNUM
beq L25C3
L25C1:
bcs L25E5
; ---LIST ONE LINE----------------
L25C3:
sty FORPNT
jsr LINPRT
lda #$20
L25CA:
ldy FORPNT
and #$7F
L25CE:
jsr OUTDO
.ifdef CONFIG_DATAFLG
cmp #$22
bne LA519
lda DATAFLG
eor #$FF
sta DATAFLG
LA519:
.endif
iny
.ifdef CONFIG_11
beq L25E5
.endif
lda (LOWTRX),y
bne L25E8
tay
lda (LOWTRX),y
tax
iny
lda (LOWTRX),y
stx LOWTRX
sta LOWTRX+1
.if .def(MICROTAN) || .def(AIM65) || .def(SYM1)
bne L25A6X
.else
bne L25A6
.endif
L25E5:
.ifdef AIM65
lda INPUTFLG
beq L25E5a
jsr CRDO
jsr CRDO
lda #$1a
jsr OUTDO
jsr $e50a
L25E5a:
.endif
jmp RESTART
L25E8:
bpl L25CE
.ifdef CONFIG_DATAFLG
cmp #$FF
beq L25CE
bit DATAFLG
bmi L25CE
.endif
sec
sbc #$7F
tax
sty FORPNT
ldy #$FF
L25F2:
dex
beq L25FD
L25F5:
iny
lda TOKEN_NAME_TABLE,y
bpl L25F5
bmi L25F2
L25FD:
iny
lda TOKEN_NAME_TABLE,y
bmi L25CA
jsr OUTDO
bne L25FD ; always
|
6502-retro/6502-retro-os
| 2,777
|
apps/msbasic/poke.s
|
.segment "CODE"
.ifndef CONFIG_NO_POKE
; ----------------------------------------------------------------------------
; EVALUATE "EXP1,EXP2"
;
; CONVERT EXP1 TO 16-BIT NUMBER IN LINNUM
; CONVERT EXP2 TO 8-BIT NUMBER IN X-REG
; ----------------------------------------------------------------------------
GTNUM:
jsr FRMNUM
jsr GETADR
; ----------------------------------------------------------------------------
; EVALUATE ",EXPRESSION"
; CONVERT EXPRESSION TO SINGLE BYTE IN X-REG
; ----------------------------------------------------------------------------
COMBYTE:
jsr CHKCOM
jmp GETBYT
; ----------------------------------------------------------------------------
; CONVERT (FAC) TO A 16-BIT VALUE IN LINNUM
; ----------------------------------------------------------------------------
GETADR:
lda FACSIGN
.ifdef APPLE
nop ; PATCH
nop
.else
bmi GOIQ
.endif
lda FAC
cmp #$91
bcs GOIQ
jsr QINT
lda FAC_LAST-1
ldy FAC_LAST
sty LINNUM
sta LINNUM+1
rts
; ----------------------------------------------------------------------------
; "PEEK" FUNCTION
; ----------------------------------------------------------------------------
PEEK:
.ifdef CONFIG_PEEK_SAVE_LINNUM
lda LINNUM+1
pha
lda LINNUM
pha
.endif
jsr GETADR
ldy #$00
.ifdef CBM1
; disallow PEEK between $C000 and $DFFF
cmp #$C0
bcc LD6F3
cmp #$E1
bcc LD6F6
LD6F3:
.endif
.ifdef CBM2
nop ; patch that disables the compares above
nop
nop
nop
nop
nop
nop
nop
.endif
lda (LINNUM),y
tay
.ifdef CONFIG_PEEK_SAVE_LINNUM
pla
sta LINNUM
pla
sta LINNUM+1
.endif
LD6F6:
jmp SNGFLT
; ----------------------------------------------------------------------------
; "POKE" STATEMENT
; ----------------------------------------------------------------------------
POKE:
jsr GTNUM
txa
ldy #$00
sta (LINNUM),y
rts
; ----------------------------------------------------------------------------
; "WAIT" STATEMENT
; ----------------------------------------------------------------------------
WAIT:
jsr GTNUM
stx FORPNT
ldx #$00
jsr CHRGOT
.ifdef CONFIG_EASTER_EGG
beq EASTER_EGG
.else
beq L3628
.endif
jsr COMBYTE
L3628:
stx FORPNT+1
ldy #$00
L362C:
lda (LINNUM),y
eor FORPNT+1
and FORPNT
beq L362C
RTS3:
rts
.endif
|
6502-retro/6502-retro-os
| 3,751
|
apps/msbasic/token.s
|
init_token_tables
keyword_rts "END", END
keyword_rts "FOR", FOR
keyword_rts "NEXT", NEXT
keyword_rts "DATA", DATA
.ifdef CONFIG_FILE
keyword_rts "INPUT#", INPUTH
.endif
keyword_rts "INPUT", INPUT
keyword_rts "DIM", DIM
keyword_rts "READ", READ
.ifdef APPLE
keyword_rts "PLT", PLT
.else
keyword_rts "LET", LET
.endif
keyword_rts "GOTO", GOTO, TOKEN_GOTO
keyword_rts "RUN", RUN
keyword_rts "IF", IF
keyword_rts "RESTORE", RESTORE
keyword_rts "GOSUB", GOSUB, TOKEN_GOSUB
keyword_rts "RETURN", POP
.ifdef APPLE
keyword_rts "TEX", TEX, TOKEN_REM
.else
keyword_rts "REM", REM, TOKEN_REM
.endif
keyword_rts "STOP", STOP
keyword_rts "ON", ON
.ifdef CONFIG_NULL
keyword_rts "NULL", NULL
.endif
.ifdef KBD
keyword_rts "PLOD", PLOD
keyword_rts "PSAV", PSAV
keyword_rts "VLOD", VLOD
keyword_rts "VSAV", VSAV
.endif
.ifndef CONFIG_NO_POKE
keyword_rts "WAIT", WAIT
.endif
.ifdef RETRO
keyword_rts "BYE", BYE
.endif
.ifndef KBD
keyword_rts "LOAD", LOAD
keyword_rts "SAVE", SAVE
.endif
.ifdef CONFIG_CBM_ALL
keyword_rts "VERIFY", VERIFY
.endif
keyword_rts "DEF", DEF
.ifdef KBD
keyword_rts "SLOD", SLOD
.endif
.ifndef CONFIG_NO_POKE
keyword_rts "POKE", POKE
.endif
.ifdef CONFIG_FILE
keyword_rts "PRINT#", PRINTH
.endif
keyword_rts "PRINT", PRINT, TOKEN_PRINT
keyword_rts "CONT", CONT
keyword_rts "LIST", LIST
.ifdef CONFIG_CBM_ALL
keyword_rts "CLR", CLEAR
.else
keyword_rts "CLEAR", CLEAR
.endif
.ifdef CONFIG_FILE
keyword_rts "CMD", CMD
keyword_rts "SYS", SYS
keyword_rts "OPEN", OPEN
keyword_rts "CLOSE", CLOSE
.endif
.ifndef CONFIG_SMALL
keyword_rts "GET", GET
.endif
.ifdef KBD
keyword_rts "PRT", PRT
.endif
keyword_rts "NEW", NEW
count_tokens
keyword "TAB(", TOKEN_TAB
keyword "TO", TOKEN_TO
keyword "FN", TOKEN_FN
keyword "SPC(", TOKEN_SPC
keyword "THEN", TOKEN_THEN
keyword "NOT", TOKEN_NOT
keyword "STEP", TOKEN_STEP
keyword "+", TOKEN_PLUS
keyword "-", TOKEN_MINUS
keyword "*"
keyword "/"
.ifdef KBD
keyword "#"
.else
keyword "^"
.endif
keyword "AND"
keyword "OR"
keyword ">", TOKEN_GREATER
keyword "=", TOKEN_EQUAL
keyword "<"
.segment "VECTORS"
UNFNC:
keyword_addr "SGN", SGN, TOKEN_SGN
keyword_addr "INT", INT
keyword_addr "ABS", ABS
.ifdef KBD
keyword_addr "VER", VER
.endif
.ifndef CONFIG_NO_POKE
.ifdef CONFIG_RAM
keyword_addr "USR", IQERR
.else
keyword_addr "USR", USR, TOKEN_USR
.endif
.endif
keyword_addr "FRE", FRE
keyword_addr "POS", POS
keyword_addr "SQR", SQR
keyword_addr "RND", RND
keyword_addr "LOG", LOG
keyword_addr "EXP", EXP
.segment "VECTORS"
UNFNC_COS:
keyword_addr "COS", COS
.segment "VECTORS"
UNFNC_SIN:
keyword_addr "SIN", SIN
.segment "VECTORS"
UNFNC_TAN:
keyword_addr "TAN", TAN
.segment "VECTORS"
UNFNC_ATN:
keyword_addr "ATN", ATN
.ifdef KBD
keyword_addr "GETC", GETC
.endif
.ifndef CONFIG_NO_POKE
keyword_addr "PEEK", PEEK
.endif
keyword_addr "LEN", LEN
keyword_addr "STR$", STR
keyword_addr "VAL", VAL
keyword_addr "ASC", ASC
keyword_addr "CHR$", CHRSTR
keyword_addr "LEFT$", LEFTSTR, TOKEN_LEFTSTR
keyword_addr "RIGHT$", RIGHTSTR
keyword_addr "MID$", MIDSTR
.ifdef CONFIG_2
keyword "GO", TOKEN_GO
.endif
.segment "KEYWORDS"
.byte 0
.segment "VECTORS"
MATHTBL:
.byte $79
.word FADDT-1
.byte $79
.word FSUBT-1
.byte $7B
.word FMULTT-1
.byte $7B
.word FDIVT-1
.byte $7F
.word FPWRT-1
.byte $50
.word TAND-1
.byte $46
.word OR-1
.byte $7D
.word NEGOP-1
.byte $5A
.word EQUOP-1
.byte $64
.word RELOPS-1
|
6502-retro/6502-retro-os
| 16,180
|
apps/msbasic/microtan_extra.s
|
.byte 0,0,0,0,0,0,0,0,0
LE210:
jmp LE34A
LE213:
jmp LE34A
LE216:
jmp LE33C
LE219:
jmp LE252
LE21C:
jmp LE6AD
LE21F:
jmp LE6B9
LE222:
pla
tay
sta $5E
pla
sta $5F
pha
tya
pha
ldy #$03
LE22E:
lda ($5E),y
beq LE238
jsr LFE75
iny
bne LE22E
LE238:
jsr LFDFA
lda $01
cmp #$03
beq LE24C
cmp #$0D
beq LE24B
jsr LFE75
jmp LE238
LE24B:
rts
LE24C:
pla
pla
pla
jmp LE2D6
LE252:
tya
pha
jsr LE222
bcs LE260
.byte "FAST?"
.byte $0D,$00
LE260:
ldy #$00
sty $50
sty $31
lda $03E0
cmp #$59
beq LE26F
inc $50
LE26F:
pla
pha
beq LE28C
jsr LE222
bcs LE280
ora $5845
.byte "AM?"
.byte $0D,$00
LE280:
lda $03E0
cmp #$59
beq LE28C
pla
clc
adc #$01
pha
LE28C:
jsr LE222
bcs LE29D
ora $4946
.byte "LENAME?"
.byte $0D,$00
LE29D:
ldy #$FF
jsr LF006
bcs LE28C
cmp #$FF
bne LE28C
lda #$00
lda #$42
jsr LF003
jsr LF000
pla
bne LE2C3
ldy #$20
jsr LF009
jsr LF00C
jsr LF01E
jmp LE2D6
LE2C3:
pha
jsr LF01B
pla
clc
sbc #$00
jsr LF021
lda $1E
sta $9C
lda $1F
sta $9D
LE2D6:
jsr LFE73
cli
lda #$00
sta $BFCB
sta $BFC2
ldx #$00
LE2E4:
pla
sta $13,x
inx
cpx #$4D
bne LE2E4
rts
lda #$0F
sta $0C
lda #$00
sta $BFC2
sta $15
sta $16
jmp COLD_START
LE2FD:
pha
txa
pha
lda #$02
sta $14
lda #$00
LE306:
dex
bmi LE312
clc
adc #$20
bcc LE306
inc $14
bne LE306
LE312:
sta $13
pla
tax
pla
rts
LE318:
jsr LE2FD
sta ($13),y
rts
LE31E:
pha
txa
pha
ldx #$00
LE323:
lda $0220,x
sta $0200,x
inx
cpx #$A0
bne LE323
lda #$20
ldx #$1F
LE332:
sta $0280,x
dex
bpl LE332
pla
tax
LE33A:
pla
rts
LE33C:
pha
lda $16
beq LE346
bpl LE33A
jmp LE714
LE346:
pla
jmp LC7A5
LE34A:
lda $16
beq LE357
bmi LE353
jmp LE778
LE353:
lda #$00
sta $16
LE357:
lda $15
beq LE35E
jmp LE660
LE35E:
jsr LC764
cmp #$05
beq LE366
rts
LE366:
stx $0E
lda #$00
sta $33
sta $34
ldx #$FF
LE370:
inx
cpx $0E
beq LE3C8
lda $34
cmp #$19
bcs LE3A7
pha
lda $33
asl a
rol $34
asl a
rol $34
adc $33
sta $33
pla
adc $34
sta $34
asl $33
rol $34
lda $35,x
sec
sbc #$30
bmi LE3A7
cmp #$3A
bcs LE3A7
clc
adc $33
sta $33
bcc LE370
inc $34
bne LE370
LE3A7:
ldx #$00
LE3A9:
lda LE3B4,x
beq LE3C3
jsr LFE75
inx
bne LE3A9
LE3B4:
ora $4F4E
.byte " SUCH LINE"
.byte $0D,$00
LE3C3:
ldx #$00
lda #$0D
rts
LE3C8:
ldx #$09
LE3CA:
lda #$04
sta $45,x
dex
lda #$01
sta $45,x
dex
bpl LE3CA
sta $CE
lda #$04
sta $CF
stx $7D
stx $7B
LE3E0:
ldy #$03
lda ($CE),y
pha
dey
lda ($CE),y
pha
dey
lda ($CE),y
tax
dey
lda ($CE),y
sta $CE
stx $CF
sta $4F
stx $50
pla
tax
pla
cmp $34
bne LE403
cpx $33
beq LE419
LE403:
stx $7A
sta $7B
ldx #$00
LE409:
lda $47,x
sta $45,x
inx
cpx #$0A
bne LE409
iny
lda ($CE),y
beq LE3A7
bne LE3E0
LE419:
iny
lda ($CE),y
beq LE428
iny
lda ($CE),y
sta $7C
iny
lda ($CE),y
sta $7D
LE428:
ldx #$03
LE42A:
lda $7A,x
pha
dex
bpl LE42A
lda #$20
ldx #$0F
LE434:
ldy #$1F
LE436:
jsr LE318
dey
bpl LE436
dex
bpl LE434
ldx #$05
LE441:
ldy #$1F
lda #$2D
LE445:
jsr LE318
dey
bpl LE445
cpx #$09
beq LE453
ldx #$09
bne LE441
LE453:
lda $45
sta $CE
lda $46
sta $CF
LE45B:
txa
pha
lda #$00
sta $07
ldy #$02
lda ($CE),y
tax
iny
lda ($CE),y
cmp $34
beq LE473
bcc LE479
LE46F:
dec $07
bmi LE47B
LE473:
cpx $33
beq LE47B
bcs LE46F
LE479:
inc $07
LE47B:
sty $08
stx $D2
sta $D1
ldx #$90
sec
jsr FLOAT2
jsr FOUT
ldx #$00
LE48C:
lda $0100,x
beq LE496
sta $35,x
inx
bne LE48C
LE496:
lda #$20
LE498:
ldy $08
and #$7F
LE49C:
sta $35,x
beq LE4D0
inx
cpx #$4F
bcc LE4A9
lda #$00
beq LE49C
LE4A9:
iny
lda ($CE),y
bpl LE49C
sec
sbc #$7F
stx $09
tax
sty $08
ldy #$FF
LE4B8:
dex
beq LE4C3
LE4BB:
iny
lda TOKEN_NAME_TABLE,y
bpl LE4BB
bmi LE4B8
LE4C3:
ldx $09
LE4C5:
iny
lda TOKEN_NAME_TABLE,y
bmi LE498
sta $35,x
inx
bne LE4C5
LE4D0:
ldx #$00
stx $08
pla
tax
ldy #$00
lda $07
bne LE4E0
ldx #$06
bne LE4EE
LE4E0:
bpl LE4E9
LE4E2:
inx
cpx #$0E
beq LE529
bne LE4EE
LE4E9:
jsr LE31E
ldx #$04
LE4EE:
stx $09
LE4F0:
ldx $08
lda $35,x
beq LE50D
inx
stx $08
ldx $09
jsr LE318
iny
cpy #$20
bne LE4F0
ldy #$00
lda $07
beq LE4E2
bpl LE4E9
bmi LE4E2
LE50D:
ldy #$00
lda ($CE),y
pha
iny
lda ($CE),y
sta $CF
pla
sta $CE
lda ($CE),y
beq LE529
ldx $09
lda $07
bne LE526
ldx #$09
LE526:
jmp LE45B
LE529:
ldx #$00
LE52B:
lda $02C1,x
cmp #$20
beq LE53A
sta $03E1,x
inx
stx $0E
bne LE52B
LE53A:
ldx #$00
LE53C:
pla
sta $7A,x
inx
cpx #$04
bne LE53C
ldx #$06
ldy #$00
sty $01
LE54A:
jsr LE2FD
lda ($13),y
sta $82
lda #$FF
sta ($13),y
LE555:
lda #$40
sta $80
sta $81
LE55B:
lda $01
bne LE574
dec $80
bne LE55B
dec $81
bne LE55B
lda ($13),y
pha
lda $82
sta ($13),y
pla
sta $82
jmp LE555
LE574:
lda $82
bmi LE57A
sta ($13),y
LE57A:
lda $01
cmp #$18
bne LE584
dey
bpl LE584
iny
LE584:
cmp #$06
bne LE58D
cpy #$1F
beq LE58D
iny
LE58D:
cmp #$02
bne LE596
cpx #$06
beq LE596
dex
LE596:
cmp #$04
bne LE59F
cpx #$08
beq LE59F
inx
LE59F:
cmp #$7F
bne LE5B6
cpy #$00
bne LE5AB
cpx #$06
beq LE5B6
LE5AB:
dey
bpl LE5BA
ldy #$1F
dex
jsr LE2FD
bne LE5BA
LE5B6:
cmp #$05
bne LE5D5
LE5BA:
pha
tya
pha
LE5BD:
tya
clc
adc $13
cmp #$1F
beq LE5CE
iny
lda ($13),y
dey
sta ($13),y
iny
bne LE5BD
LE5CE:
lda #$20
sta ($13),y
pla
tay
pla
LE5D5:
cmp #$1B
beq LE641
cmp #$0D
beq LE657
cmp #$0A
beq LE631
cmp #$03
beq LE645
cmp #$0B
beq LE627
cmp #$09
beq LE63D
cmp #$20
bcc LE620
cmp #$7E
bcs LE620
pha
tya
pha
lda ($13),y
LE5FA:
sta $80
tya
clc
adc $13
cmp #$1F
beq LE60F
iny
lda ($13),y
pha
lda $80
sta ($13),y
pla
bne LE5FA
LE60F:
pla
tay
pla
sta ($13),y
cpy #$1F
bne LE61F
cpx #$08
beq LE620
inx
ldy #$FF
LE61F:
iny
LE620:
lda #$00
sta $01
jmp LE54A
LE627:
ldx #$5F
lda #$20
LE62B:
sta $02C0,x
dex
bpl LE62B
LE631:
ldx #$02
LE633:
lda $7A,x
sta $13
inx
lda $7A,x
jmp LE659
LE63D:
ldx #$00
stx $0E
LE641:
ldx #$00
beq LE633
LE645:
jsr LFE73
ldx #$00
lda #$00
sta $16
LE64E:
sta $15
ldy #$00
sty $03
lda #$0D
rts
LE657:
lda #$FF
LE659:
sta $14
lda #$01
pha
bne LE685
LE660:
cmp #$03
beq LE69E
cmp #$02
beq LE681
ldx $03C0
cpx #$20
bne LE645
ldx #$FF
LE671:
inx
cpx $0E
bne LE67A
lda #$02
bne LE64E
LE67A:
lda $03E1,x
sta $35,x
bne LE671
LE681:
tax
inx
txa
pha
LE685:
ldx #$4F
LE687:
lda $02C0,x
sta $35,x
dex
bpl LE687
ldx #$4F
LE691:
lda $02BF,x
cmp #$20
bne LE69B
dex
bne LE691
LE69B:
pla
bne LE64E
LE69E:
ldx $14
cpx #$FF
beq LE645
stx $34
lda $13
sta $33
jmp LE3C8
LE6AD:
pha
lda #$05
sta $0E
pla
jsr LINGET
jmp LC57E
LE6B9:
lda $0E
bmi LE6D1
dec $0E
bne LE6D1
jsr LFDFA
lda #$82
sta $0E
lda $01
cmp #$0A
beq LE6D1
sec
rol $0E
LE6D1:
jsr ISCNTC
jmp LC5A9
LE6D7:
ldx #$FF
LE6D9:
jsr LE6E2
dey
bne LE6D9
dex
bne LE6D9
LE6E2:
rts
LE6E3:
lda #$0C
LE6E5:
ldx #$FF
tay
lda $01
cmp #$03
beq LE6E2
tya
LE6EF:
pha
lda $BFC0
LE6F3:
lda $BFCD
and #$08
beq LE6F3
lda $BFC9
pha
lda #$FF
sta $BFC9
pla
cmp #$FC
pla
bcc LE6E5
dex
bne LE6EF
dey
bne LE6EF
rts
LE710:
lda #$06
bne LE6E5
LE714:
stx $13
sty $14
lda $16
cmp #$FD
beq LE749
lda #$00
sta $BFCB
lda #$20
sta $BFC0
lda #$40
sta $BFC2
jsr LE6D7
jsr LF000
lda $16
cmp #$FF
bne LE740
ldy #$20
jsr LF009
dec $16
LE740:
ldy #$10
ldx #$FF
jsr LF009
dec $16
LE749:
pla
sei
pha
cmp #$0A
beq LE771
ldx $0E
stx $50
jsr LF00F
cli
lda $01
cmp #$03
beq LE771
pla
pha
cmp #$0D
bne LE771
lda #$00
sta $16
sta $BFCB
jsr LE6D7
sta $BFC2
LE771:
ldx $13
ldy $14
cli
pla
rts
LE778:
lda #$40
sta $BFC0
jsr LF000
cli
lda $16
cmp #$01
bne LE78A
jsr LE6E3
LE78A:
jsr LE710
lda $01
cmp #$03
beq LE7CE
LE793:
lda $50
pha
lda $51
pha
lda $0E
sta $50
sei
jsr LF018
cli
tay
pla
sta $51
pla
sta $50
bcs LE7BD
lda #$00
sta $16
ldx #$06
LE7B1:
lda LE7DC,x ; "PARITY"
jsr LFE75
dex
bpl LE7B1
inx
beq LE7CE
LE7BD:
lda $01
cmp #$03
beq LE7CE
cpy #$0D
beq LE7CE
sty $35,x
inx
cpx #$4F
bne LE793
LE7CE:
lda #$00
sta $BFCB
sta $BFC2
sta $16
cli
lda #$0D
rts
LE7DC:
.byte "YTIRAP"
.byte $0D,$FF,$FF,$FF,$FF,$FF,$FF,$FF
.byte $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF
.byte $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF
.byte $FF,$FF,$FF,$FF,$FF,$FF
|
6502-retro/6502-retro-os
| 7,565
|
apps/msbasic/print.s
|
.segment "CODE"
.ifdef AIM65
PRINT:
lda PRIFLG
sta ZBE
jsr L297E
LB8B1:
lda ZBE
sta PRIFLG
rts
.endif
PRSTRING:
jsr STRPRT
L297E:
jsr CHRGOT
; ----------------------------------------------------------------------------
; "PRINT" STATEMENT
; ----------------------------------------------------------------------------
.ifndef AIM65
PRINT:
.endif
beq CRDO
PRINT2:
beq L29DD
.ifdef AIM65
jsr LB89D
beq L29DD
.endif
cmp #TOKEN_TAB
beq L29F5
cmp #TOKEN_SPC
.ifdef CONFIG_2
clc ; also AppleSoft II
.endif
beq L29F5
cmp #','
; Pre-KIM had no CLC. KIM added the CLC
; here. Post-KIM moved the CLC up...
; (makes no sense on KIM, liveness = 0)
.if .def(CONFIG_11A) && (!.def(CONFIG_2))
clc
.endif
beq L29DE
cmp #$3B
beq L2A0D
jsr FRMEVL
bit VALTYP
bmi PRSTRING
jsr FOUT
jsr STRLIT
.ifndef CONFIG_NO_CR
ldy #$00
lda (FAC_LAST-1),y
clc
adc POSX
.ifdef KBD
cmp #$28
.else
cmp Z17
.endif
bcc L29B1
jsr CRDO
L29B1:
.endif
jsr STRPRT
.ifdef KBD
jmp L297E
.else
jsr OUTSP
bne L297E ; branch always
.endif
.ifdef KBD
; PATCHES
LE86C:
pla
jmp CONTROL_C_TYPED
LE870:
jsr GETBYT
txa
LE874:
beq LE878
bpl LE8F2
LE878:
jmp IQERR
; PATCHES
.endif
.ifndef KBD
L29B9:
.ifdef CBM2
lda #$00
sta INPUTBUFFER,x
ldx #<(INPUTBUFFER-1)
ldy #>(INPUTBUFFER-1)
.else
.ifndef APPLE
ldy #$00
sty INPUTBUFFER,x
ldx #LINNUM+1
.endif
.if .def(MICROTAN) || .def(SYM1)
bne CRDO2
.endif
.endif
.ifdef CONFIG_FILE
lda CURDVC
bne L29DD
.endif
.endif
CRDO:
.if .def(CONFIG_PRINTNULLS) && .def(CONFIG_FILE)
lda CURDVC
bne LC9D8
sta POSX
LC9D8:
.endif
lda #CRLF_1
.ifndef CONFIG_CBM_ALL
sta POSX
.endif
jsr OUTDO
CRDO2:
lda #CRLF_2
jsr OUTDO
PRINTNULLS:
.if .def(KBD) || .def(AIM65)
lda #$00
sta POSX
eor #$FF
.else
.if .def(CONFIG_NULL) || .def(CONFIG_PRINTNULLS)
.ifdef CONFIG_FILE
; Although there is no statement for it,
; CBM1 had NULL support and ignores
; it when not targeting the screen,
; CBM2 dropped it completely.
lda CURDVC
bne L29DD
.endif
txa
pha
ldx Z15
beq L29D9
.ifdef SYM1
lda #$FF
.else
lda #$00
.endif
L29D3:
jsr OUTDO
dex
bne L29D3
L29D9:
stx POSX
pla
tax
.else
.ifndef CONFIG_2
lda #$00
sta POSX
.endif
eor #$FF
.endif
.endif
L29DD:
rts
L29DE:
lda POSX
.ifndef CONFIG_NO_CR
.ifdef KBD
cmp #$1A
.else
cmp Z18
.endif
bcc L29EA
jsr CRDO
jmp L2A0D
L29EA:
.endif
sec
L29EB:
.if .def(CONFIG_CBM_ALL) || .def(AIM65)
sbc #$0A
.else
.ifdef KBD
sbc #$0D
.else
sbc #$0E
.endif
.endif
bcs L29EB
eor #$FF
adc #$01
bne L2A08
L29F5:
.ifdef CONFIG_11A
php
.else
pha
.endif
jsr GTBYTC
cmp #')'
.ifdef CONFIG_11A
.ifdef CONFIG_2
bne SYNERR4
.else
jne SYNERR
.endif
plp
bcc L2A09
.else
.ifdef CONFIG_11
jne SYNERR
.else
bne SYNERR4
.endif
pla
cmp #TOKEN_TAB
.ifdef CONFIG_11
bne L2A09
.else
bne L2A0A
.endif
.endif
txa
sbc POSX
bcc L2A0D
.ifndef CONFIG_11
beq L2A0D
.endif
L2A08:
tax
.ifdef CONFIG_11
L2A09:
inx
.endif
L2A0A:
.ifndef CONFIG_11
jsr OUTSP
.endif
dex
.ifndef CONFIG_11
bne L2A0A
.else
bne L2A13
.endif
L2A0D:
jsr CHRGET
jmp PRINT2
.ifdef CONFIG_11
L2A13:
jsr OUTSP
bne L2A0A
.endif
; ----------------------------------------------------------------------------
; PRINT STRING AT (Y,A)
; ----------------------------------------------------------------------------
STROUT:
jsr STRLIT
; ----------------------------------------------------------------------------
; PRINT STRING AT (FACMO,FACLO)
; ----------------------------------------------------------------------------
STRPRT:
jsr FREFAC
tax
ldy #$00
inx
L2A22:
dex
beq L29DD
lda (INDEX),y
jsr OUTDO
iny
cmp #$0D
bne L2A22
jsr PRINTNULLS
jmp L2A22
; ----------------------------------------------------------------------------
OUTSP:
.ifdef CONFIG_FILE
.ifndef CBM1
; on non-screen devices, print SPACE
; instead of CRSR RIGHT
lda CURDVC
beq LCA40
lda #$20
.byte $2C
LCA40:
.endif
lda #$1D ; CRSR RIGHT
.else
lda #$20
.endif
.byte $2C
OUTQUES:
lda #$3F
; ----------------------------------------------------------------------------
; PRINT CHAR FROM (A)
; ----------------------------------------------------------------------------
OUTDO:
.ifndef KBD
bit Z14
bmi L2A56
.endif
.if .def(CONFIG_PRINT_CR) || .def(CBM1)
; Commodore forgot to remove this in CBM1
pha
.endif
.ifdef CBM1
cmp #$1D ; CRSR RIGHT
beq LCA6A
cmp #$9D ; CRSR LEFT
beq LCA5A
cmp #$14 ; DEL
bne LCA64
LCA5A:
lda POSX
beq L2A4E
lda CURDVC
bne L2A4E
dec POSX
LCA64:
and #$7F
.endif
.ifndef CBM2
cmp #$20
bcc L2A4E
.endif
LCA6A:
.ifdef CONFIG_CBM1_PATCHES
lda CURDVC
jsr PATCH6
nop
.endif
.ifdef CONFIG_PRINT_CR
lda POSX
cmp Z17
bne L2A4C
.ifdef AIM65
lda #$00
sta POSX
.elseif .def(APPLE)
nop ; PATCH!
nop ; don't print CR
nop
.else
jsr CRDO
.endif
L2A4C:
.endif
.ifndef CONFIG_CBM_ALL
inc POSX
.endif
L2A4E:
.if .def(CONFIG_PRINT_CR) || .def(CBM1)
; Commodore forgot to remove this in CBM1
pla
.endif
.ifdef CONFIG_MONCOUT_DESTROYS_Y
sty DIMFLG
.endif
.ifdef CONFIG_IO_MSB
ora #$80
.endif
jsr MONCOUT
.ifdef CONFIG_IO_MSB
and #$7F
.endif
.ifdef CONFIG_MONCOUT_DESTROYS_Y
ldy DIMFLG
.endif
.ifdef OSI
nop
nop
nop
nop
.endif
L2A56:
and #$FF
LE8F2:
rts
; ----------------------------------------------------------------------------
; ???
; ----------------------------------------------------------------------------
.ifdef KBD
LE8F3:
pha
lda $047F
clc
beq LE900
lda #$00
sta $047F
sec
LE900:
pla
rts
.endif
|
6502-retro/6502-retro-os
| 2,939
|
apps/msbasic/rnd.s
|
.segment "CODE"
; ----------------------------------------------------------------------------
; "RND" FUNCTION
; ----------------------------------------------------------------------------
.ifdef KBD
RND:
ldx #$10
jsr SIGN
beq LFC26
bmi LFC10
lda RNDSEED
ldy RNDSEED+1
LFBFA:
sta FAC+2
sty FAC+1
LFBFE:
asl a
asl a
eor FAC+2
asl a
eor FAC+1
asl a
asl a
asl a
asl a
eor FAC+1
asl a
rol FAC+2
rol FAC+1
LFC10:
lda FAC+2
dex
bne LFBFE
sta RNDSEED
sta FAC+3
lda FAC+1
sta RNDSEED+1
lda #$80
sta FAC
stx FACSIGN
jmp NORMALIZE_FAC2
LFC26:
ldy $03CA
lda $03C7
ora #$01
GOMOVMF:
bne LFBFA
.byte $F0
.else
; <<< THESE ARE MISSING ONE BYTE FOR FP VALUES >>>
; (non CONFIG_SMALL)
CONRND1:
.byte $98,$35,$44,$7A
CONRND2:
.byte $68,$28,$B1,$46
RND:
jsr SIGN
.ifdef CONFIG_CBM_ALL
bmi L3F01
bne LDF63
lda ENTROPY
sta FAC+1
lda ENTROPY+4
sta FAC+2
lda ENTROPY+1
sta FAC+3
lda ENTROPY+5
sta FAC+4
jmp LDF88
LDF63:
.else
tax
bmi L3F01
.endif
lda #<RNDSEED
ldy #>RNDSEED
jsr LOAD_FAC_FROM_YA
.ifndef CONFIG_CBM_ALL
txa
beq RTS19
.endif
lda #<CONRND1
ldy #>CONRND1
jsr FMULT
lda #<CONRND2
ldy #>CONRND2
jsr FADD
L3F01:
ldx FAC_LAST
lda FAC+1
sta FAC_LAST
stx FAC+1
.ifdef CONFIG_CBM_ALL
ldx FAC+2
lda FAC+3
sta FAC+2
stx FAC+3
LDF88:
.endif
lda #$00
sta FACSIGN
lda FAC
sta FACEXTENSION
lda #$80
sta FAC
jsr NORMALIZE_FAC2
ldx #<RNDSEED
ldy #>RNDSEED
GOMOVMF:
jmp STORE_FAC_AT_YX_ROUNDED
.endif
.segment "CHRGET"
; ----------------------------------------------------------------------------
; INITIAL VALUE FOR RANDOM NUMBER, ALSO COPIED
; IN ALONG WITH CHRGET, BUT ERRONEOUSLY:
; <<< THE LAST BYTE IS NOT COPIED >>>
; (on all non-CONFIG_SMALL)
; ----------------------------------------------------------------------------
GENERIC_RNDSEED:
.ifndef KBD
; random number seed
.ifdef CONFIG_SMALL
.byte $80,$4F,$C7,$52
.else
.ifdef CONFIG_11
.byte $80,$4F,$C7,$52,$58
.else
.byte $80,$4F,$C7,$52,$59
.endif
.endif
.endif
GENERIC_CHRGET_END:
|
6502-retro/6502-retro-os
| 6,515
|
apps/msbasic/kbd_extra.s
|
.segment "EXTRA"
stx SHIFTSIGNEXT
stx $0800
inx
stx Z17
stx Z18
stx TXTTAB
lda #$08
sta TXTTAB+1
jsr SCRTCH
sta STACK+255
LFD81:
jsr PRIMM
.byte $1B,$06,$01,$0C
.byte "INTELLIVISION BASIC"
.byte $0D,$0A,$0A
.byte "Copyright Microsoft, Mattel 1980"
.byte $0D,$0A,$00
sta $0435
sta $8F
ldy #$0F
lda #$FF
sta ($04),y
jsr LDE8C
.byte $0C ; NOP $xxxx
jmp RESTART
OUTQUESSP:
jsr OUTQUES
jmp OUTSP
INLIN:
ldy #$FF
LFDDC:
iny
LFDDD:
jsr GETLN
cmp #$03 ; CTRL+C
beq LFDF7
cmp #$20
bcs LFDEC ; no control char
sbc #$09
bne LFDDD
LFDEC:
sta INPUTBUFFER,y
tax
bne LFDDC
jsr CRDO2
ldy #$06
LFDF7:
tax
clc
rts
LFDFA:
bit $8F
bmi LFE01
jsr LDE48
LFE01:
bit $8F
bvc LFE10
jmp LDE53
LFE08:
jsr LFDFA
LFE0B:
jsr LDE24
bne LFE08
LFE10:
rts
VSAV:
jsr GARBAG
lda FRETOP
sta $00
lda FRETOP+1
.byte $85
LFE1B:
ora ($A5,x)
.byte $2F
sta $02
lda STREND+1
sta $03
ldy #$00
LFE26:
lda ($00),y
sta ($02),y
inc $02
bne LFE30
inc $03
LFE30:
inc $00
bne LFE26
inc $01
bit $01
bvc LFE26
ldx VARTAB
ldy VARTAB+1
lda #$01
bne LFE50
PSAV:
lda VARTAB
sta $02
lda VARTAB+1
sta $03
ldx #$01
ldy #$08
lda #$02
LFE50:
sta $0513
stx $0503
stx $00
sty $0504
sty $01
ldy #$0D
lda #$00
LFE61:
sta $0504,y
dey
bne LFE61
sty $0500
lda #$40
sta $0505
lda $02
sec
sbc $00
sta $00
lda $03
sbc $01
sta $01
lsr a
lsr a
lsr a
sta $03
jsr LE870
sta $02
jsr CHRGOT
beq LFEA6
cmp #$2C
beq L40FA
jmp SYNERR
L40FA:
jsr CHRGET
jsr LE870
sec
sbc $02
cmp $03
bpl LFEBF
lda #$27
sta JMPADRS
jmp LFFBD
LFEA6:
lda $02
clc
adc $03
jsr LE874
pha
jsr LFE0B
jsr L6874
.byte $72
adc $00,x
pla
tax
lda #$00
jsr LINPRT
LFEBF:
ldx #$07
LBF83:
dex
lda VARTAB,x
sec
sbc TXTTAB,x
sta $051B,x
lda VARTAB+1,x
sbc TXTTAB+1,x
sta $051C,x
dex
bpl LBF83
txa
sbc FRETOP
sta $0521
lda #>CONST_MEMSIZ
sbc FRETOP+1
sta $0522
lda FRETOP
sta $0523
lda FRETOP+1
sta $0524
ldx $02
jsr LFFDD
jsr LFFD1
lda $01
ldx #$05
LFEF7:
stx $0511
ldy #$E4
sec
sbc #$08
sta $01
bpl LFF15
adc #$08
asl $00
rol a
asl $00
rol a
asl $00
rol a
adc #$01
sta $0505
ldy #$00
LFF15:
sty $0512
jsr LE4C0
ldx #$00
lda $01
bpl LFEF7
LFF21:
rts
VLOD:
jsr LFFD1
stx JMPADRS
lda VARTAB
ldy VARTAB+1
ldx #$01
jsr LFF64
ldx #$00
ldy #$02
LFF34:
jsr LE39A
iny
iny
inx
inx
cpx #$05
bmi LFF34
lda STREND
sta LOWTR
lda STREND+1
sta LOWTR+1
lda FRETOP
sta HIGHTR
lda FRETOP+1
sta HIGHTR+1
lda #<CONST_MEMSIZ
sta HIGHDS
lda #>CONST_MEMSIZ
sta HIGHDS+1
lda $0523
sta FRETOP
lda $0524
sta FRETOP+1
jmp BLTU2
LFF64:
sta $9A
sty $9B
stx $00
jsr LE870
jsr LFFDD
lda JMPADRS
beq LFF7F
lda #$01
sta $9A
lda #$08
sta $9B
jsr STXTPT
LFF7F:
lda $9A
sta $0503
lda $9B
sta $0504
lda #$ED
sta $0512
lda #$05
sta $01
LFF92:
ldx $0512
beq LFF21
ldy #$04
jsr LE4C4
lda $01
cmp $0511
bne LFFB2
lda #$00
sta $01
lda $00
cmp $0513
beq LFF92
lda #$18
bne LFFB8
LFFB2:
lda #$27
bne LFFB8
LFFB6:
lda #$3C
LFFB8:
sta JMPADRS
jsr CLEARC
LFFBD:
jsr VARTAB_MINUS_2_TO_AY
sta $9A
sty $9B
lda #$00
tay
sta ($9A),y
iny
sta ($9A),y
ldx JMPADRS
jmp ERROR
LFFD1:
ldx #$00
LFFD3:
lda #$02
.byte $2C
LFFD6:
lda #$03
jsr LDE8C
asl FACSIGN
LFFDD:
jsr CHRGOT
beq LFFE5
jmp SYNERR
LFFE5:
lda #$0D
ldy #$00
jsr LDE8C
.byte $06
LFFED:
lda $034C
bmi LFFED
ldy #$01
lda ($04),y
bne LFFB6
rts
.byte $FF
; NMI
.addr LC000
; RESET
.addr LC000
; IRQ
.addr LC009
|
6502-retro/6502-retro-os
| 1,305
|
apps/msbasic/microtan_loadsave.s
|
.segment "CODE"
SAVE:
ldy #$00
beq LC74D
LC74B:
ldy #$01
LC74D:
ldx #$4C
LC74F:
lda $13,x
pha
dex
bpl LC74F
ldx #$03
LC757:
lda TXTTAB,x
sta GOSTROUT+2,x
dex
bpl LC757
jmp LE219
nop
nop
nop
LC764:
tya
pha
ldy $03
lda #$FF
sta ($0A),y
pla
tay
jsr LFDFA
lda $01
jsr LC7A5
rts
.byte "DED"
.byte $0D,$0A
.byte "OK"
.byte $0D,$0A,$00
.byte "SAVED"
.byte $0D,$0A,$00
LOAD:
jsr LC74B
ldx #$FF
tsx
lda #$4F
jsr LFE75
lda #$4B
jsr LFE75
jsr LFE73
lda VARTAB
tax
ldy VARTAB+1
jmp FIX_LINKS
nop
LC7A5:
pha
cmp #$0A
beq LC7AD
jsr LFE75
LC7AD:
tya
pha
ldy $03
lda #$20
sta ($0A),y
pla
tay
pla
rts
inc $8A17
stx VARTAB
sty VARTAB+1
jmp FIX_LINKS
|
74hc595/LPC1114-Synthesizer
| 4,892
|
kernel.S
|
@ vim:noet:sw=8:ts=8:ai:syn=armasm
@ LPC1114 Synthesizer
@ Matt Sarnoff (msarnoff.org)
@ November 24, 2013
@
@ Sound generation kernel.
@ The SysTick handler is executed from RAM for super speed!
@ This function makes heavy (ab)use of self-modifying code;
@ many of the instructions are changed by the C code to vary parameters
@ without branching.
@ DO NOT MODIFY UNLESS YOU KNOW WHAT YOU DOING!!1
@ Changing/adding/removing instructions without changing the corresponding
@ constants in sound.c will probably cause the CPU to lock up.
.data
_SysTick_Handler:
mov r3, #0 @ sample accumulator
adr r0, osc0 @ point to first oscillator
silence:
b stop_oscillators @ modifiable; becomes a nop when envelope != 0
osc_update_base:
@ Update all oscillators
@ Self-modifying code is used to change the waveform, volume, and duty cycle
.rept 4
ldmia r0, {r0, r1, r2}
add r2, r1
stmia r0!, {r2}
mov r1, #255 @ precompute the constant 0x1FE00000
lsl r1, #21 @ TODO: this is suboptimal
@ ----- begin modifiable code
asr r2, #23
sub r2, #0 @ subtract duty cycle to get a bitmask
eor r2, r1 @ leaves junk in the lower bits but it's too insignificant to matter
@ ----- end modifiable code
add r3, r2
.endr
@ When sawtooth wave is selected, the "modifiable code" sections
@ will be replaced with the following instructions:
@ asr r2, #2
@ nop
@ nop
filter_bypass_control:
nop @ modifiable
@ b filter_bypass
@ Chamberlin state-variable filter
@ L = D2 + F1*D1
@ H = I - L - Q1*D1
@ B = F1*H + D1
@ D1 = B
@ D2 = L
@ F1 is an unsigned 16.16 fixed point number limited to the range [0, 1]
@ Q1 is an unsigned 16.16 fixed point number limited to the range [0, 2]
@ L, H, B, D1, and D2 are signed 20.12 fixed-point numbers;
@ their range is limited to [-8, 8) to prevent overflow during multiplication
@ I (input) is a 28-bit binary fraction and must be adjusted
filter:
@ shift oscillator output down to 20.12 for input to filter
asr r3, #19
@ compute lowpass output
ldmia r0, {r0, r1, r2} @ get D2, frequency, D1
mul r1, r2 @ D1*F1; 20.12 * 16.16
asr r1, #16 @ shift result back to 20.12
add r0, r1 @ r0 = L = D2 + D1*F1
mov r12, r0 @ save L
@ r12 now contains lowpass output
@ compute highpass output
sub r3, r0 @ r3 = H = I - L
adr r0, _filter_cutoff
ldmia r0, {r0, r1, r2} @ get frequency, D1, Q
mul r2, r1 @ D1*Q1; 20.12 * 16.16
asr r2, #16 @ shift result back to 20.12
sub r3, r2 @ r3 = H = I - L - D1*Q1
@ r12 = lowpass output
@ r3 = highpass output
@ r0 = frequency
@ r1 = D1
@ compute bandpass output
mul r0, r3 @ r0 = B = H*F1; 20.12 * 16.16
asr r0, #16 @ shift result back to 20.12
add r0, r1 @ r0 = B = H*F1 + D1
mov r1, r12 @ bring back lowpass output
@ r1 = lowpass output
@ r3 = highpass output
@ r0 = bandpass output
@ store the new delay values
adr r2, filter_d2
str r1, [r2, #0] @ D2 = L
str r0, [r2, #8] @ D1 = B
@ choose an output
filter_mode_control:
mov r3, r1 @ modifiable
@ Clip
ldr r0, clip_threshold
cmp r3, r0
bgt clip
neg r0, r0
cmp r3, r0
blt clip
apply_envelope:
volume_control:
mov r0, #255 @ modifiable
add r0, #1
mul r3, r0
lsr r3, #10
@ Send 12-bit sample in r3 to DAC
dacout:
adr r0, output_port
ldmia r0, {r0, r1, r2}
add r3, r1 @ convert 2's complement to offset
orr r3, r2 @ set /GA and /SHDN bits
strh r3, [r0] @ send to DAC
bx lr
filter_bypass:
asr r3, #18 @ shift down to 12 bits for DAC
b apply_envelope
clip:
mov r3, r0
b apply_envelope
stop_oscillators:
str r3, [r0, #osc0ph-osc0] @ zero out all phase accumulators
str r3, [r0, #osc1ph-osc0]
str r3, [r0, #osc2ph-osc0]
str r3, [r0, #osc3ph-osc0]
str r3, [r0, #filter_d2-osc0]
str r3, [r0, #filter_d1-osc0]
b dacout
.align 4
@ oscillator states
@ 3 words per oscillator (phase pointer, frequency, phase)
@ the phase pointer allows r0 to point to the phase word after an ldm
oscillators:
osc0: .word osc0ph
osc0fr: .word 0
osc0ph: .word 0
osc1: .word osc1ph
osc1fr: .word 0
osc1ph: .word 0
osc2: .word osc2ph
osc2fr: .word 0
osc2ph: .word 0
osc3: .word osc3ph
osc3fr: .word 0
osc3ph: .word 0
@ filter state and parameters
filter_d2:
.word 0
_filter_cutoff:
.word 0xffff @ 16.16 unsigned fixed point, in the range [0, 1]
filter_d1:
.word 0
filter_q:
.word 0x10000 @ 16.16 unsigned fixed point, in the range [0, 2)
clip_threshold:
.word 0x1fff
@ constants used for DAC output
output_port:
.word 0x40040008 @ SPI data register
offset:
.word 0x00000800 @ convert 2's complement to offset
dac_bits:
.word 0x00003000 @ /GA and /SHDN bits
.global oscillators
.global osc_update_base
.global filter_cutoff
.global filter_q
.global filter_mode_control
.global filter_bypass_control
.global volume_control
.global silence
.set filter_cutoff, _filter_cutoff
@ make sure the thumb bit is set in the vector table
.global SysTick_Handler
.thumb_set SysTick_Handler, _SysTick_Handler
|
74hc595/Amethyst
| 34,933
|
assets/amscii_font_8x8.S
|
.section .progmem.assets
.balign 256
.global amscii_font_8x8
.type amscii_font_8x8, @object
amscii_font_8x8:
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b11110000
.byte 0b11110000
.byte 0b11110000
.byte 0b11110000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b10000000
.byte 0b00000001
.byte 0b10000000
.byte 0b00000001
.byte 0b10000001
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00011000
.byte 0b00011000
.byte 0b00011000
.byte 0b00011000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00011000
.byte 0b00011000
.byte 0b00011000
.byte 0b00011000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b01100000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b01100000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b11111111
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b11111100
.byte 0b00000000
.byte 0b00000000
.byte 0b01111000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b11000000
.byte 0b00000110
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b11111100
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b01000100
.byte 0b01010101
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b00001111
.byte 0b00001111
.byte 0b00001111
.byte 0b00001111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b01111111
.byte 0b11111110
.byte 0b11111111
.byte 0b11111111
.byte 0b01111110
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11100111
.byte 0b11100111
.byte 0b11100111
.byte 0b11100111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11100111
.byte 0b11100111
.byte 0b11100111
.byte 0b11100111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b10011111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b10011111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b00000000
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b00000011
.byte 0b11111111
.byte 0b11111111
.byte 0b10000111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b00111111
.byte 0b11111001
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b00000011
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b10111011
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b11110000
.byte 0b11110000
.byte 0b11110000
.byte 0b11110000
.byte 0b00010000
.byte 0b00000000
.byte 0b00000000
.byte 0b00111100
.byte 0b01000000
.byte 0b00000010
.byte 0b11000000
.byte 0b00000011
.byte 0b01000010
.byte 0b00001000
.byte 0b00010000
.byte 0b00000000
.byte 0b00011000
.byte 0b00011000
.byte 0b00011000
.byte 0b00011000
.byte 0b00011000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00011000
.byte 0b00011000
.byte 0b00011000
.byte 0b00011000
.byte 0b00000000
.byte 0b00011000
.byte 0b00000000
.byte 0b01101100
.byte 0b00010000
.byte 0b01100011
.byte 0b00111011
.byte 0b00000000
.byte 0b00001100
.byte 0b01100000
.byte 0b00000000
.byte 0b00000000
.byte 0b00110000
.byte 0b00000000
.byte 0b00011000
.byte 0b10000000
.byte 0b01111100
.byte 0b01111110
.byte 0b11111110
.byte 0b01111100
.byte 0b00001100
.byte 0b01111100
.byte 0b01111100
.byte 0b00110000
.byte 0b01111100
.byte 0b01111100
.byte 0b00011000
.byte 0b00110000
.byte 0b00001100
.byte 0b00000000
.byte 0b01100000
.byte 0b00011000
.byte 0b01111100
.byte 0b11000110
.byte 0b11111100
.byte 0b00111100
.byte 0b11111000
.byte 0b11111110
.byte 0b11000000
.byte 0b00111110
.byte 0b11000110
.byte 0b01111110
.byte 0b01111100
.byte 0b11000110
.byte 0b11111110
.byte 0b11000110
.byte 0b11000110
.byte 0b00111000
.byte 0b11000000
.byte 0b00110110
.byte 0b11000110
.byte 0b01111100
.byte 0b00011000
.byte 0b01111100
.byte 0b00010000
.byte 0b11000110
.byte 0b11000110
.byte 0b00011000
.byte 0b11111110
.byte 0b00111100
.byte 0b00000010
.byte 0b01111000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b01111110
.byte 0b11111100
.byte 0b01111100
.byte 0b01111110
.byte 0b01111100
.byte 0b01100000
.byte 0b00000110
.byte 0b11000110
.byte 0b00011000
.byte 0b11001100
.byte 0b11000110
.byte 0b00001100
.byte 0b11000110
.byte 0b11000110
.byte 0b01111100
.byte 0b11000000
.byte 0b00000110
.byte 0b11000000
.byte 0b11111100
.byte 0b00111100
.byte 0b01111110
.byte 0b00010000
.byte 0b01101100
.byte 0b11000110
.byte 0b00000110
.byte 0b11111110
.byte 0b00011100
.byte 0b00011000
.byte 0b01110000
.byte 0b00000000
.byte 0b00010001
.byte 0b01010101
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b00001111
.byte 0b00001111
.byte 0b00001111
.byte 0b00001111
.byte 0b11101111
.byte 0b11111111
.byte 0b11111111
.byte 0b11000011
.byte 0b10111111
.byte 0b11111101
.byte 0b01111111
.byte 0b11111110
.byte 0b10111101
.byte 0b11110111
.byte 0b11101111
.byte 0b11111111
.byte 0b11100111
.byte 0b11100111
.byte 0b11100111
.byte 0b11100111
.byte 0b11100111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11100111
.byte 0b11100111
.byte 0b11100111
.byte 0b11100111
.byte 0b11111111
.byte 0b11100111
.byte 0b11111111
.byte 0b10010011
.byte 0b11101111
.byte 0b10011100
.byte 0b11000100
.byte 0b11111111
.byte 0b11110011
.byte 0b10011111
.byte 0b11111111
.byte 0b11111111
.byte 0b11001111
.byte 0b11111111
.byte 0b11100111
.byte 0b01111111
.byte 0b10000011
.byte 0b10000001
.byte 0b00000001
.byte 0b10000011
.byte 0b11110011
.byte 0b10000011
.byte 0b10000011
.byte 0b11001111
.byte 0b10000011
.byte 0b10000011
.byte 0b11100111
.byte 0b11001111
.byte 0b11110011
.byte 0b11111111
.byte 0b10011111
.byte 0b11100111
.byte 0b10000011
.byte 0b00111001
.byte 0b00000011
.byte 0b11000011
.byte 0b00000111
.byte 0b00000001
.byte 0b00111111
.byte 0b11000001
.byte 0b00111001
.byte 0b10000001
.byte 0b10000011
.byte 0b00111001
.byte 0b00000001
.byte 0b00111001
.byte 0b00111001
.byte 0b11000111
.byte 0b00111111
.byte 0b11001001
.byte 0b00111001
.byte 0b10000011
.byte 0b11100111
.byte 0b10000011
.byte 0b11101111
.byte 0b00111001
.byte 0b00111001
.byte 0b11100111
.byte 0b00000001
.byte 0b11000011
.byte 0b11111101
.byte 0b10000111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b10000001
.byte 0b00000011
.byte 0b10000011
.byte 0b10000001
.byte 0b10000011
.byte 0b10011111
.byte 0b11111001
.byte 0b00111001
.byte 0b11100111
.byte 0b00110011
.byte 0b00111001
.byte 0b11110011
.byte 0b00111001
.byte 0b00111001
.byte 0b10000011
.byte 0b00111111
.byte 0b11111001
.byte 0b00111111
.byte 0b00000011
.byte 0b11000011
.byte 0b10000001
.byte 0b11101111
.byte 0b10010011
.byte 0b00111001
.byte 0b11111001
.byte 0b00000001
.byte 0b11100011
.byte 0b11100111
.byte 0b10001111
.byte 0b11111111
.byte 0b11101110
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b11110000
.byte 0b11110000
.byte 0b11110000
.byte 0b11110000
.byte 0b00111000
.byte 0b00000000
.byte 0b00011000
.byte 0b01100110
.byte 0b00100000
.byte 0b00000100
.byte 0b11100000
.byte 0b00000111
.byte 0b00100100
.byte 0b00001100
.byte 0b00110000
.byte 0b00000000
.byte 0b00111100
.byte 0b00011000
.byte 0b00011000
.byte 0b00011000
.byte 0b00011000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00011000
.byte 0b00011000
.byte 0b00011000
.byte 0b00011000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b01101100
.byte 0b11111100
.byte 0b00110011
.byte 0b01100110
.byte 0b00000000
.byte 0b00011000
.byte 0b00110000
.byte 0b01101100
.byte 0b00011000
.byte 0b00011000
.byte 0b00000000
.byte 0b00011000
.byte 0b11000000
.byte 0b11000110
.byte 0b00011000
.byte 0b11000000
.byte 0b11000110
.byte 0b00001100
.byte 0b11000110
.byte 0b11000110
.byte 0b00110000
.byte 0b11000110
.byte 0b11000110
.byte 0b00011000
.byte 0b00011000
.byte 0b00011000
.byte 0b01111110
.byte 0b00110000
.byte 0b00000000
.byte 0b11000000
.byte 0b11000110
.byte 0b11000110
.byte 0b01100110
.byte 0b11001100
.byte 0b11000000
.byte 0b11000000
.byte 0b01100110
.byte 0b11000110
.byte 0b00011000
.byte 0b11000110
.byte 0b11001100
.byte 0b11000000
.byte 0b11000110
.byte 0b11001110
.byte 0b01101100
.byte 0b11000000
.byte 0b01101100
.byte 0b11001100
.byte 0b11000110
.byte 0b00011000
.byte 0b11000110
.byte 0b00111000
.byte 0b11101110
.byte 0b11000110
.byte 0b00011000
.byte 0b01100000
.byte 0b00110000
.byte 0b00000110
.byte 0b00011000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b11000110
.byte 0b11000110
.byte 0b11000110
.byte 0b11000110
.byte 0b11000000
.byte 0b01100000
.byte 0b01111110
.byte 0b11000110
.byte 0b00011000
.byte 0b00001100
.byte 0b11001100
.byte 0b00011000
.byte 0b11000110
.byte 0b11000110
.byte 0b11000110
.byte 0b11111100
.byte 0b01111110
.byte 0b11000000
.byte 0b00000110
.byte 0b01100110
.byte 0b11000110
.byte 0b00111000
.byte 0b11111110
.byte 0b01101100
.byte 0b01111110
.byte 0b01100000
.byte 0b00110000
.byte 0b00011000
.byte 0b00011000
.byte 0b00000000
.byte 0b01000100
.byte 0b01010101
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b00001111
.byte 0b00001111
.byte 0b00001111
.byte 0b00001111
.byte 0b11000111
.byte 0b11111111
.byte 0b11100111
.byte 0b10011001
.byte 0b11011111
.byte 0b11111011
.byte 0b00111111
.byte 0b11111100
.byte 0b11011011
.byte 0b11110011
.byte 0b11001111
.byte 0b11111111
.byte 0b11000011
.byte 0b11100111
.byte 0b11100111
.byte 0b11100111
.byte 0b11100111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11100111
.byte 0b11100111
.byte 0b11100111
.byte 0b11100111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b10010011
.byte 0b00000011
.byte 0b11001100
.byte 0b10011001
.byte 0b11111111
.byte 0b11100111
.byte 0b11001111
.byte 0b10010011
.byte 0b11100111
.byte 0b11100111
.byte 0b11111111
.byte 0b11100111
.byte 0b00111111
.byte 0b00111001
.byte 0b11100111
.byte 0b00111111
.byte 0b00111001
.byte 0b11110011
.byte 0b00111001
.byte 0b00111001
.byte 0b11001111
.byte 0b00111001
.byte 0b00111001
.byte 0b11100111
.byte 0b11100111
.byte 0b11100111
.byte 0b10000001
.byte 0b11001111
.byte 0b11111111
.byte 0b00111111
.byte 0b00111001
.byte 0b00111001
.byte 0b10011001
.byte 0b00110011
.byte 0b00111111
.byte 0b00111111
.byte 0b10011001
.byte 0b00111001
.byte 0b11100111
.byte 0b00111001
.byte 0b00110011
.byte 0b00111111
.byte 0b00111001
.byte 0b00110001
.byte 0b10010011
.byte 0b00111111
.byte 0b10010011
.byte 0b00110011
.byte 0b00111001
.byte 0b11100111
.byte 0b00111001
.byte 0b11000111
.byte 0b00010001
.byte 0b00111001
.byte 0b11100111
.byte 0b10011111
.byte 0b11001111
.byte 0b11111001
.byte 0b11100111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b00111001
.byte 0b00111001
.byte 0b00111001
.byte 0b00111001
.byte 0b00111111
.byte 0b10011111
.byte 0b10000001
.byte 0b00111001
.byte 0b11100111
.byte 0b11110011
.byte 0b00110011
.byte 0b11100111
.byte 0b00111001
.byte 0b00111001
.byte 0b00111001
.byte 0b00000011
.byte 0b10000001
.byte 0b00111111
.byte 0b11111001
.byte 0b10011001
.byte 0b00111001
.byte 0b11000111
.byte 0b00000001
.byte 0b10010011
.byte 0b10000001
.byte 0b10011111
.byte 0b11001111
.byte 0b11100111
.byte 0b11100111
.byte 0b11111111
.byte 0b10111011
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b11110000
.byte 0b11110000
.byte 0b11110000
.byte 0b11110000
.byte 0b01111100
.byte 0b00011000
.byte 0b00111100
.byte 0b01000010
.byte 0b00010000
.byte 0b00001000
.byte 0b11110000
.byte 0b00001111
.byte 0b00011000
.byte 0b11111110
.byte 0b01111111
.byte 0b11111111
.byte 0b01111110
.byte 0b00011111
.byte 0b11111000
.byte 0b11111111
.byte 0b00011000
.byte 0b00011111
.byte 0b11111000
.byte 0b11111111
.byte 0b00011000
.byte 0b00011111
.byte 0b11111000
.byte 0b11111111
.byte 0b00000000
.byte 0b00011000
.byte 0b00000000
.byte 0b11111110
.byte 0b00010110
.byte 0b00011000
.byte 0b01101110
.byte 0b00000000
.byte 0b00110000
.byte 0b00011000
.byte 0b00111000
.byte 0b00011000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b01100000
.byte 0b11100110
.byte 0b00011000
.byte 0b01110000
.byte 0b00000110
.byte 0b11111110
.byte 0b00000110
.byte 0b11000110
.byte 0b00011000
.byte 0b11000110
.byte 0b00000110
.byte 0b00000000
.byte 0b00000000
.byte 0b00110000
.byte 0b00000000
.byte 0b00011000
.byte 0b00011000
.byte 0b11011110
.byte 0b11111110
.byte 0b11000110
.byte 0b11000000
.byte 0b11000110
.byte 0b11000000
.byte 0b11000000
.byte 0b11000110
.byte 0b11000110
.byte 0b00011000
.byte 0b11000110
.byte 0b11011000
.byte 0b11000000
.byte 0b11000110
.byte 0b11011110
.byte 0b11000110
.byte 0b11000000
.byte 0b11011010
.byte 0b11011000
.byte 0b00000110
.byte 0b00011000
.byte 0b11000110
.byte 0b01101100
.byte 0b11111110
.byte 0b01101100
.byte 0b00011000
.byte 0b00110000
.byte 0b00110000
.byte 0b00001100
.byte 0b00011000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b01111110
.byte 0b11000110
.byte 0b11000000
.byte 0b11000110
.byte 0b11111110
.byte 0b01100000
.byte 0b11000110
.byte 0b11000110
.byte 0b00011000
.byte 0b00001100
.byte 0b11111000
.byte 0b00011000
.byte 0b11010110
.byte 0b11000110
.byte 0b11000110
.byte 0b11000110
.byte 0b11000110
.byte 0b11000000
.byte 0b01111100
.byte 0b01100000
.byte 0b11000110
.byte 0b01101100
.byte 0b11010110
.byte 0b00111000
.byte 0b11000110
.byte 0b00111000
.byte 0b00110000
.byte 0b00011000
.byte 0b00011000
.byte 0b00000000
.byte 0b00010001
.byte 0b01010101
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b00001111
.byte 0b00001111
.byte 0b00001111
.byte 0b00001111
.byte 0b10000011
.byte 0b11100111
.byte 0b11000011
.byte 0b10111101
.byte 0b11101111
.byte 0b11110111
.byte 0b00011111
.byte 0b11111000
.byte 0b11100111
.byte 0b00000001
.byte 0b10000000
.byte 0b00000000
.byte 0b10000001
.byte 0b11100000
.byte 0b00000111
.byte 0b00000000
.byte 0b11100111
.byte 0b11100000
.byte 0b00000111
.byte 0b00000000
.byte 0b11100111
.byte 0b11100000
.byte 0b00000111
.byte 0b00000000
.byte 0b11111111
.byte 0b11100111
.byte 0b11111111
.byte 0b00000001
.byte 0b11101001
.byte 0b11100111
.byte 0b10010001
.byte 0b11111111
.byte 0b11001111
.byte 0b11100111
.byte 0b11000111
.byte 0b11100111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b10011111
.byte 0b00011001
.byte 0b11100111
.byte 0b10001111
.byte 0b11111001
.byte 0b00000001
.byte 0b11111001
.byte 0b00111001
.byte 0b11100111
.byte 0b00111001
.byte 0b11111001
.byte 0b11111111
.byte 0b11111111
.byte 0b11001111
.byte 0b11111111
.byte 0b11100111
.byte 0b11100111
.byte 0b00100001
.byte 0b00000001
.byte 0b00111001
.byte 0b00111111
.byte 0b00111001
.byte 0b00111111
.byte 0b00111111
.byte 0b00111001
.byte 0b00111001
.byte 0b11100111
.byte 0b00111001
.byte 0b00100111
.byte 0b00111111
.byte 0b00111001
.byte 0b00100001
.byte 0b00111001
.byte 0b00111111
.byte 0b00100101
.byte 0b00100111
.byte 0b11111001
.byte 0b11100111
.byte 0b00111001
.byte 0b10010011
.byte 0b00000001
.byte 0b10010011
.byte 0b11100111
.byte 0b11001111
.byte 0b11001111
.byte 0b11110011
.byte 0b11100111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b10000001
.byte 0b00111001
.byte 0b00111111
.byte 0b00111001
.byte 0b00000001
.byte 0b10011111
.byte 0b00111001
.byte 0b00111001
.byte 0b11100111
.byte 0b11110011
.byte 0b00000111
.byte 0b11100111
.byte 0b00101001
.byte 0b00111001
.byte 0b00111001
.byte 0b00111001
.byte 0b00111001
.byte 0b00111111
.byte 0b10000011
.byte 0b10011111
.byte 0b00111001
.byte 0b10010011
.byte 0b00101001
.byte 0b11000111
.byte 0b00111001
.byte 0b11000111
.byte 0b11001111
.byte 0b11100111
.byte 0b11100111
.byte 0b11111111
.byte 0b11101110
.byte 0b00000000
.byte 0b11110000
.byte 0b00001111
.byte 0b11111111
.byte 0b00000000
.byte 0b11110000
.byte 0b00001111
.byte 0b11111111
.byte 0b11111110
.byte 0b00011000
.byte 0b00111100
.byte 0b01000010
.byte 0b00001000
.byte 0b00010000
.byte 0b11111000
.byte 0b00011111
.byte 0b00011000
.byte 0b11111110
.byte 0b01111111
.byte 0b11111111
.byte 0b00011000
.byte 0b00011111
.byte 0b11111000
.byte 0b11111111
.byte 0b01111110
.byte 0b00011111
.byte 0b11111000
.byte 0b11111111
.byte 0b00011000
.byte 0b00011111
.byte 0b11111000
.byte 0b11111111
.byte 0b00000000
.byte 0b00011000
.byte 0b00000000
.byte 0b01101100
.byte 0b01111100
.byte 0b00001100
.byte 0b00111011
.byte 0b00000000
.byte 0b00110000
.byte 0b00011000
.byte 0b11111110
.byte 0b01111110
.byte 0b00000000
.byte 0b01111110
.byte 0b00000000
.byte 0b00110000
.byte 0b11000110
.byte 0b00011000
.byte 0b00011100
.byte 0b00111100
.byte 0b11001100
.byte 0b00000110
.byte 0b11111100
.byte 0b00001100
.byte 0b01111100
.byte 0b01111110
.byte 0b00011000
.byte 0b00011000
.byte 0b01100000
.byte 0b00000000
.byte 0b00001100
.byte 0b00001100
.byte 0b11010110
.byte 0b11000110
.byte 0b11111000
.byte 0b11000000
.byte 0b11000110
.byte 0b11111000
.byte 0b11111000
.byte 0b11001110
.byte 0b11111110
.byte 0b00011000
.byte 0b00000110
.byte 0b11110000
.byte 0b11000000
.byte 0b11010110
.byte 0b11111110
.byte 0b11000110
.byte 0b11111100
.byte 0b11000110
.byte 0b11111100
.byte 0b01111100
.byte 0b00011000
.byte 0b11000110
.byte 0b01101100
.byte 0b11010110
.byte 0b00111000
.byte 0b00111100
.byte 0b00011000
.byte 0b00110000
.byte 0b00011000
.byte 0b00011000
.byte 0b11000110
.byte 0b00000000
.byte 0b00000000
.byte 0b00000110
.byte 0b11000110
.byte 0b11000110
.byte 0b11000110
.byte 0b11000110
.byte 0b11111000
.byte 0b11000110
.byte 0b11000110
.byte 0b00011000
.byte 0b00001100
.byte 0b11001100
.byte 0b00011000
.byte 0b11111110
.byte 0b11000110
.byte 0b11000110
.byte 0b11000110
.byte 0b11000110
.byte 0b11000110
.byte 0b11000000
.byte 0b01100000
.byte 0b11000110
.byte 0b11000110
.byte 0b11000110
.byte 0b01101100
.byte 0b11000110
.byte 0b00001100
.byte 0b11100000
.byte 0b00011000
.byte 0b00001110
.byte 0b11011100
.byte 0b01000100
.byte 0b01010101
.byte 0b00001111
.byte 0b11110000
.byte 0b00000000
.byte 0b11111111
.byte 0b00001111
.byte 0b11110000
.byte 0b00000000
.byte 0b00000001
.byte 0b11100111
.byte 0b11000011
.byte 0b10111101
.byte 0b11110111
.byte 0b11101111
.byte 0b00001111
.byte 0b11110000
.byte 0b11100111
.byte 0b00000001
.byte 0b10000000
.byte 0b00000000
.byte 0b11100111
.byte 0b11100000
.byte 0b00000111
.byte 0b00000000
.byte 0b10000001
.byte 0b11100000
.byte 0b00000111
.byte 0b00000000
.byte 0b11100111
.byte 0b11100000
.byte 0b00000111
.byte 0b00000000
.byte 0b11111111
.byte 0b11100111
.byte 0b11111111
.byte 0b10010011
.byte 0b10000011
.byte 0b11110011
.byte 0b11000100
.byte 0b11111111
.byte 0b11001111
.byte 0b11100111
.byte 0b00000001
.byte 0b10000001
.byte 0b11111111
.byte 0b10000001
.byte 0b11111111
.byte 0b11001111
.byte 0b00111001
.byte 0b11100111
.byte 0b11100011
.byte 0b11000011
.byte 0b00110011
.byte 0b11111001
.byte 0b00000011
.byte 0b11110011
.byte 0b10000011
.byte 0b10000001
.byte 0b11100111
.byte 0b11100111
.byte 0b10011111
.byte 0b11111111
.byte 0b11110011
.byte 0b11110011
.byte 0b00101001
.byte 0b00111001
.byte 0b00000111
.byte 0b00111111
.byte 0b00111001
.byte 0b00000111
.byte 0b00000111
.byte 0b00110001
.byte 0b00000001
.byte 0b11100111
.byte 0b11111001
.byte 0b00001111
.byte 0b00111111
.byte 0b00101001
.byte 0b00000001
.byte 0b00111001
.byte 0b00000011
.byte 0b00111001
.byte 0b00000011
.byte 0b10000011
.byte 0b11100111
.byte 0b00111001
.byte 0b10010011
.byte 0b00101001
.byte 0b11000111
.byte 0b11000011
.byte 0b11100111
.byte 0b11001111
.byte 0b11100111
.byte 0b11100111
.byte 0b00111001
.byte 0b11111111
.byte 0b11111111
.byte 0b11111001
.byte 0b00111001
.byte 0b00111001
.byte 0b00111001
.byte 0b00111001
.byte 0b00000111
.byte 0b00111001
.byte 0b00111001
.byte 0b11100111
.byte 0b11110011
.byte 0b00110011
.byte 0b11100111
.byte 0b00000001
.byte 0b00111001
.byte 0b00111001
.byte 0b00111001
.byte 0b00111001
.byte 0b00111001
.byte 0b00111111
.byte 0b10011111
.byte 0b00111001
.byte 0b00111001
.byte 0b00111001
.byte 0b10010011
.byte 0b00111001
.byte 0b11110011
.byte 0b00011111
.byte 0b11100111
.byte 0b11110001
.byte 0b00100011
.byte 0b10111011
.byte 0b00000000
.byte 0b11110000
.byte 0b00001111
.byte 0b11111111
.byte 0b00000000
.byte 0b11110000
.byte 0b00001111
.byte 0b11111111
.byte 0b11111110
.byte 0b00000000
.byte 0b00011000
.byte 0b01100110
.byte 0b00000100
.byte 0b00100000
.byte 0b11111100
.byte 0b00111111
.byte 0b00100100
.byte 0b00001100
.byte 0b00110000
.byte 0b00000000
.byte 0b00011000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00111100
.byte 0b00011000
.byte 0b00011000
.byte 0b00011000
.byte 0b00011000
.byte 0b00011000
.byte 0b00011000
.byte 0b00011000
.byte 0b00000000
.byte 0b00011000
.byte 0b01101100
.byte 0b11111110
.byte 0b11010000
.byte 0b01100110
.byte 0b00011100
.byte 0b00110000
.byte 0b00110000
.byte 0b00011000
.byte 0b00111000
.byte 0b00011000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00011000
.byte 0b11001110
.byte 0b00011000
.byte 0b00000110
.byte 0b00000110
.byte 0b01101100
.byte 0b11111100
.byte 0b11000000
.byte 0b00000110
.byte 0b11000110
.byte 0b11000110
.byte 0b00011000
.byte 0b00011000
.byte 0b00110000
.byte 0b01111110
.byte 0b00011000
.byte 0b00000110
.byte 0b11011110
.byte 0b11000110
.byte 0b11000110
.byte 0b11000000
.byte 0b11000110
.byte 0b11000000
.byte 0b11000000
.byte 0b11000000
.byte 0b11000110
.byte 0b00011000
.byte 0b00000110
.byte 0b11011000
.byte 0b11000000
.byte 0b11111110
.byte 0b11110110
.byte 0b11000110
.byte 0b11000110
.byte 0b11000110
.byte 0b11000110
.byte 0b11000000
.byte 0b00011000
.byte 0b11000110
.byte 0b11000110
.byte 0b11000110
.byte 0b01101100
.byte 0b01100110
.byte 0b00001100
.byte 0b00110000
.byte 0b00110000
.byte 0b00011000
.byte 0b01101100
.byte 0b00000000
.byte 0b00001100
.byte 0b01111100
.byte 0b11111100
.byte 0b01111100
.byte 0b01111110
.byte 0b01111100
.byte 0b01100000
.byte 0b01111110
.byte 0b11111100
.byte 0b00011000
.byte 0b00001100
.byte 0b11000110
.byte 0b00011000
.byte 0b01101100
.byte 0b11111100
.byte 0b01111100
.byte 0b11111100
.byte 0b01111110
.byte 0b11111100
.byte 0b01111100
.byte 0b11111100
.byte 0b11000110
.byte 0b11000110
.byte 0b11000110
.byte 0b11000110
.byte 0b11000110
.byte 0b11111110
.byte 0b00110000
.byte 0b00011000
.byte 0b00011000
.byte 0b01110110
.byte 0b00010001
.byte 0b01010101
.byte 0b00001111
.byte 0b11110000
.byte 0b00000000
.byte 0b11111111
.byte 0b00001111
.byte 0b11110000
.byte 0b00000000
.byte 0b00000001
.byte 0b11111111
.byte 0b11100111
.byte 0b10011001
.byte 0b11111011
.byte 0b11011111
.byte 0b00000111
.byte 0b11100000
.byte 0b11011011
.byte 0b11110011
.byte 0b11001111
.byte 0b11111111
.byte 0b11100111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11000011
.byte 0b11100111
.byte 0b11100111
.byte 0b11100111
.byte 0b11100111
.byte 0b11100111
.byte 0b11100111
.byte 0b11100111
.byte 0b11111111
.byte 0b11100111
.byte 0b10010011
.byte 0b00000001
.byte 0b00101111
.byte 0b10011001
.byte 0b11100011
.byte 0b11001111
.byte 0b11001111
.byte 0b11100111
.byte 0b11000111
.byte 0b11100111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11100111
.byte 0b00110001
.byte 0b11100111
.byte 0b11111001
.byte 0b11111001
.byte 0b10010011
.byte 0b00000011
.byte 0b00111111
.byte 0b11111001
.byte 0b00111001
.byte 0b00111001
.byte 0b11100111
.byte 0b11100111
.byte 0b11001111
.byte 0b10000001
.byte 0b11100111
.byte 0b11111001
.byte 0b00100001
.byte 0b00111001
.byte 0b00111001
.byte 0b00111111
.byte 0b00111001
.byte 0b00111111
.byte 0b00111111
.byte 0b00111111
.byte 0b00111001
.byte 0b11100111
.byte 0b11111001
.byte 0b00100111
.byte 0b00111111
.byte 0b00000001
.byte 0b00001001
.byte 0b00111001
.byte 0b00111001
.byte 0b00111001
.byte 0b00111001
.byte 0b00111111
.byte 0b11100111
.byte 0b00111001
.byte 0b00111001
.byte 0b00111001
.byte 0b10010011
.byte 0b10011001
.byte 0b11110011
.byte 0b11001111
.byte 0b11001111
.byte 0b11100111
.byte 0b10010011
.byte 0b11111111
.byte 0b11110011
.byte 0b10000011
.byte 0b00000011
.byte 0b10000011
.byte 0b10000001
.byte 0b10000011
.byte 0b10011111
.byte 0b10000001
.byte 0b00000011
.byte 0b11100111
.byte 0b11110011
.byte 0b00111001
.byte 0b11100111
.byte 0b10010011
.byte 0b00000011
.byte 0b10000011
.byte 0b00000011
.byte 0b10000001
.byte 0b00000011
.byte 0b10000011
.byte 0b00000011
.byte 0b00111001
.byte 0b00111001
.byte 0b00111001
.byte 0b00111001
.byte 0b00111001
.byte 0b00000001
.byte 0b11001111
.byte 0b11100111
.byte 0b11100111
.byte 0b10001001
.byte 0b11101110
.byte 0b00000000
.byte 0b11110000
.byte 0b00001111
.byte 0b11111111
.byte 0b00000000
.byte 0b11110000
.byte 0b00001111
.byte 0b11111111
.byte 0b01101100
.byte 0b00000000
.byte 0b00000000
.byte 0b00111100
.byte 0b00000010
.byte 0b01000000
.byte 0b11111110
.byte 0b01111111
.byte 0b01000010
.byte 0b00001000
.byte 0b00010000
.byte 0b00000000
.byte 0b00011000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00011000
.byte 0b00011000
.byte 0b00011000
.byte 0b00011000
.byte 0b00011000
.byte 0b00011000
.byte 0b00011000
.byte 0b00011000
.byte 0b00000000
.byte 0b00011000
.byte 0b01101100
.byte 0b01101100
.byte 0b01111110
.byte 0b01100011
.byte 0b00110110
.byte 0b00011000
.byte 0b00011000
.byte 0b00110000
.byte 0b01101100
.byte 0b00011000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00001100
.byte 0b11000110
.byte 0b01111000
.byte 0b11000110
.byte 0b11000110
.byte 0b00111100
.byte 0b11000000
.byte 0b11000110
.byte 0b11000110
.byte 0b11000110
.byte 0b11000110
.byte 0b00000000
.byte 0b00000000
.byte 0b00011000
.byte 0b00000000
.byte 0b00110000
.byte 0b11000110
.byte 0b11000110
.byte 0b01101100
.byte 0b11000110
.byte 0b01100110
.byte 0b11001100
.byte 0b11000000
.byte 0b11000000
.byte 0b01100000
.byte 0b11000110
.byte 0b00011000
.byte 0b00000110
.byte 0b11001100
.byte 0b11000000
.byte 0b11101110
.byte 0b11100110
.byte 0b01101100
.byte 0b11000110
.byte 0b01101100
.byte 0b11000110
.byte 0b11000110
.byte 0b00011000
.byte 0b11000110
.byte 0b11000110
.byte 0b11000110
.byte 0b11000110
.byte 0b01100110
.byte 0b00000110
.byte 0b00110000
.byte 0b01100000
.byte 0b00011000
.byte 0b00111000
.byte 0b00000000
.byte 0b00011000
.byte 0b00000000
.byte 0b11000000
.byte 0b00000000
.byte 0b00000110
.byte 0b00000000
.byte 0b01100110
.byte 0b00000000
.byte 0b11000000
.byte 0b00000000
.byte 0b00000000
.byte 0b11000000
.byte 0b00011000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b01100000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00110000
.byte 0b00011000
.byte 0b00011000
.byte 0b00000000
.byte 0b01000100
.byte 0b01010101
.byte 0b00001111
.byte 0b11110000
.byte 0b00000000
.byte 0b11111111
.byte 0b00001111
.byte 0b11110000
.byte 0b00000000
.byte 0b10010011
.byte 0b11111111
.byte 0b11111111
.byte 0b11000011
.byte 0b11111101
.byte 0b10111111
.byte 0b00000011
.byte 0b11000000
.byte 0b10111101
.byte 0b11110111
.byte 0b11101111
.byte 0b11111111
.byte 0b11100111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11100111
.byte 0b11100111
.byte 0b11100111
.byte 0b11100111
.byte 0b11100111
.byte 0b11100111
.byte 0b11100111
.byte 0b11100111
.byte 0b11111111
.byte 0b11100111
.byte 0b10010011
.byte 0b10010011
.byte 0b10000001
.byte 0b10011100
.byte 0b11001001
.byte 0b11100111
.byte 0b11100111
.byte 0b11001111
.byte 0b10010011
.byte 0b11100111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11110011
.byte 0b00111001
.byte 0b10000111
.byte 0b00111001
.byte 0b00111001
.byte 0b11000011
.byte 0b00111111
.byte 0b00111001
.byte 0b00111001
.byte 0b00111001
.byte 0b00111001
.byte 0b11111111
.byte 0b11111111
.byte 0b11100111
.byte 0b11111111
.byte 0b11001111
.byte 0b00111001
.byte 0b00111001
.byte 0b10010011
.byte 0b00111001
.byte 0b10011001
.byte 0b00110011
.byte 0b00111111
.byte 0b00111111
.byte 0b10011111
.byte 0b00111001
.byte 0b11100111
.byte 0b11111001
.byte 0b00110011
.byte 0b00111111
.byte 0b00010001
.byte 0b00011001
.byte 0b10010011
.byte 0b00111001
.byte 0b10010011
.byte 0b00111001
.byte 0b00111001
.byte 0b11100111
.byte 0b00111001
.byte 0b00111001
.byte 0b00111001
.byte 0b00111001
.byte 0b10011001
.byte 0b11111001
.byte 0b11001111
.byte 0b10011111
.byte 0b11100111
.byte 0b11000111
.byte 0b11111111
.byte 0b11100111
.byte 0b11111111
.byte 0b00111111
.byte 0b11111111
.byte 0b11111001
.byte 0b11111111
.byte 0b10011001
.byte 0b11111111
.byte 0b00111111
.byte 0b11111111
.byte 0b11111111
.byte 0b00111111
.byte 0b11100111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b10011111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11001111
.byte 0b11100111
.byte 0b11100111
.byte 0b11111111
.byte 0b10111011
.byte 0b00000000
.byte 0b11110000
.byte 0b00001111
.byte 0b11111111
.byte 0b00000000
.byte 0b11110000
.byte 0b00001111
.byte 0b11111111
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000001
.byte 0b10000000
.byte 0b11111111
.byte 0b11111111
.byte 0b10000001
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00011000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00011000
.byte 0b00011000
.byte 0b00011000
.byte 0b00011000
.byte 0b00011000
.byte 0b00011000
.byte 0b00011000
.byte 0b00000000
.byte 0b00011000
.byte 0b01101100
.byte 0b01101100
.byte 0b00010000
.byte 0b00000000
.byte 0b00011100
.byte 0b00011000
.byte 0b00001100
.byte 0b01100000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000110
.byte 0b01111100
.byte 0b00011000
.byte 0b01111100
.byte 0b01111100
.byte 0b00011100
.byte 0b11111110
.byte 0b01111100
.byte 0b11111110
.byte 0b01111100
.byte 0b01111100
.byte 0b00000000
.byte 0b00000000
.byte 0b00001100
.byte 0b00000000
.byte 0b01100000
.byte 0b01111100
.byte 0b01111100
.byte 0b00111000
.byte 0b11111100
.byte 0b00111100
.byte 0b11111000
.byte 0b11111110
.byte 0b11111110
.byte 0b00111110
.byte 0b11000110
.byte 0b01111110
.byte 0b00000110
.byte 0b11000110
.byte 0b11000000
.byte 0b11000110
.byte 0b11000110
.byte 0b00111000
.byte 0b11111100
.byte 0b00111000
.byte 0b11111100
.byte 0b01111100
.byte 0b01111110
.byte 0b11000110
.byte 0b11000110
.byte 0b11000110
.byte 0b11000110
.byte 0b01100110
.byte 0b11111110
.byte 0b00111100
.byte 0b11000000
.byte 0b01111000
.byte 0b00010000
.byte 0b00000000
.byte 0b00110000
.byte 0b00000000
.byte 0b11000000
.byte 0b00000000
.byte 0b00000110
.byte 0b00000000
.byte 0b00111100
.byte 0b00000000
.byte 0b11000000
.byte 0b00011000
.byte 0b00001100
.byte 0b11000000
.byte 0b00011000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b01100000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00011100
.byte 0b00011000
.byte 0b01110000
.byte 0b00000000
.byte 0b00010001
.byte 0b01010101
.byte 0b00001111
.byte 0b11110000
.byte 0b00000000
.byte 0b11111111
.byte 0b00001111
.byte 0b11110000
.byte 0b00000000
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111110
.byte 0b01111111
.byte 0b00000001
.byte 0b10000000
.byte 0b01111110
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11100111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11100111
.byte 0b11100111
.byte 0b11100111
.byte 0b11100111
.byte 0b11100111
.byte 0b11100111
.byte 0b11100111
.byte 0b11111111
.byte 0b11100111
.byte 0b10010011
.byte 0b10010011
.byte 0b11101111
.byte 0b11111111
.byte 0b11100011
.byte 0b11100111
.byte 0b11110011
.byte 0b10011111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111001
.byte 0b10000011
.byte 0b11100111
.byte 0b10000011
.byte 0b10000011
.byte 0b11100011
.byte 0b00000001
.byte 0b10000011
.byte 0b00000001
.byte 0b10000011
.byte 0b10000011
.byte 0b11111111
.byte 0b11111111
.byte 0b11110011
.byte 0b11111111
.byte 0b10011111
.byte 0b10000011
.byte 0b10000011
.byte 0b11000111
.byte 0b00000011
.byte 0b11000011
.byte 0b00000111
.byte 0b00000001
.byte 0b00000001
.byte 0b11000001
.byte 0b00111001
.byte 0b10000001
.byte 0b11111001
.byte 0b00111001
.byte 0b00111111
.byte 0b00111001
.byte 0b00111001
.byte 0b11000111
.byte 0b00000011
.byte 0b11000111
.byte 0b00000011
.byte 0b10000011
.byte 0b10000001
.byte 0b00111001
.byte 0b00111001
.byte 0b00111001
.byte 0b00111001
.byte 0b10011001
.byte 0b00000001
.byte 0b11000011
.byte 0b00111111
.byte 0b10000111
.byte 0b11101111
.byte 0b11111111
.byte 0b11001111
.byte 0b11111111
.byte 0b00111111
.byte 0b11111111
.byte 0b11111001
.byte 0b11111111
.byte 0b11000011
.byte 0b11111111
.byte 0b00111111
.byte 0b11100111
.byte 0b11110011
.byte 0b00111111
.byte 0b11100111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b10011111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11100011
.byte 0b11100111
.byte 0b10001111
.byte 0b11111111
.byte 0b11101110
|
74hc595/Amethyst
| 165,591
|
assets/bitspreadtable.S
|
.section .progmem.assets
.balign 256
.global bitspreadtable
.type bitspreadtable, @object
bitspreadtable:
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00000011
.byte 0b00000011
.byte 0b00000011
.byte 0b00000011
.byte 0b00000011
.byte 0b00000011
.byte 0b00000011
.byte 0b00000011
.byte 0b00000011
.byte 0b00000011
.byte 0b00000011
.byte 0b00000011
.byte 0b00000011
.byte 0b00000011
.byte 0b00000011
.byte 0b00000011
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010010
.byte 0b00010010
.byte 0b00010010
.byte 0b00010010
.byte 0b00010010
.byte 0b00010010
.byte 0b00010010
.byte 0b00010010
.byte 0b00010010
.byte 0b00010010
.byte 0b00010010
.byte 0b00010010
.byte 0b00010010
.byte 0b00010010
.byte 0b00010010
.byte 0b00010010
.byte 0b00010011
.byte 0b00010011
.byte 0b00010011
.byte 0b00010011
.byte 0b00010011
.byte 0b00010011
.byte 0b00010011
.byte 0b00010011
.byte 0b00010011
.byte 0b00010011
.byte 0b00010011
.byte 0b00010011
.byte 0b00010011
.byte 0b00010011
.byte 0b00010011
.byte 0b00010011
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100001
.byte 0b00100001
.byte 0b00100001
.byte 0b00100001
.byte 0b00100001
.byte 0b00100001
.byte 0b00100001
.byte 0b00100001
.byte 0b00100001
.byte 0b00100001
.byte 0b00100001
.byte 0b00100001
.byte 0b00100001
.byte 0b00100001
.byte 0b00100001
.byte 0b00100001
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100011
.byte 0b00100011
.byte 0b00100011
.byte 0b00100011
.byte 0b00100011
.byte 0b00100011
.byte 0b00100011
.byte 0b00100011
.byte 0b00100011
.byte 0b00100011
.byte 0b00100011
.byte 0b00100011
.byte 0b00100011
.byte 0b00100011
.byte 0b00100011
.byte 0b00100011
.byte 0b00110000
.byte 0b00110000
.byte 0b00110000
.byte 0b00110000
.byte 0b00110000
.byte 0b00110000
.byte 0b00110000
.byte 0b00110000
.byte 0b00110000
.byte 0b00110000
.byte 0b00110000
.byte 0b00110000
.byte 0b00110000
.byte 0b00110000
.byte 0b00110000
.byte 0b00110000
.byte 0b00110001
.byte 0b00110001
.byte 0b00110001
.byte 0b00110001
.byte 0b00110001
.byte 0b00110001
.byte 0b00110001
.byte 0b00110001
.byte 0b00110001
.byte 0b00110001
.byte 0b00110001
.byte 0b00110001
.byte 0b00110001
.byte 0b00110001
.byte 0b00110001
.byte 0b00110001
.byte 0b00110010
.byte 0b00110010
.byte 0b00110010
.byte 0b00110010
.byte 0b00110010
.byte 0b00110010
.byte 0b00110010
.byte 0b00110010
.byte 0b00110010
.byte 0b00110010
.byte 0b00110010
.byte 0b00110010
.byte 0b00110010
.byte 0b00110010
.byte 0b00110010
.byte 0b00110010
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000101
.byte 0b00000101
.byte 0b00000101
.byte 0b00000101
.byte 0b00000101
.byte 0b00000101
.byte 0b00000101
.byte 0b00000101
.byte 0b00000101
.byte 0b00000101
.byte 0b00000101
.byte 0b00000101
.byte 0b00000101
.byte 0b00000101
.byte 0b00000101
.byte 0b00000101
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010100
.byte 0b00010100
.byte 0b00010100
.byte 0b00010100
.byte 0b00010100
.byte 0b00010100
.byte 0b00010100
.byte 0b00010100
.byte 0b00010100
.byte 0b00010100
.byte 0b00010100
.byte 0b00010100
.byte 0b00010100
.byte 0b00010100
.byte 0b00010100
.byte 0b00010100
.byte 0b00010101
.byte 0b00010101
.byte 0b00010101
.byte 0b00010101
.byte 0b00010101
.byte 0b00010101
.byte 0b00010101
.byte 0b00010101
.byte 0b00010101
.byte 0b00010101
.byte 0b00010101
.byte 0b00010101
.byte 0b00010101
.byte 0b00010101
.byte 0b00010101
.byte 0b00010101
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000001
.byte 0b01000001
.byte 0b01000001
.byte 0b01000001
.byte 0b01000001
.byte 0b01000001
.byte 0b01000001
.byte 0b01000001
.byte 0b01000001
.byte 0b01000001
.byte 0b01000001
.byte 0b01000001
.byte 0b01000001
.byte 0b01000001
.byte 0b01000001
.byte 0b01000001
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000101
.byte 0b01000101
.byte 0b01000101
.byte 0b01000101
.byte 0b01000101
.byte 0b01000101
.byte 0b01000101
.byte 0b01000101
.byte 0b01000101
.byte 0b01000101
.byte 0b01000101
.byte 0b01000101
.byte 0b01000101
.byte 0b01000101
.byte 0b01000101
.byte 0b01000101
.byte 0b01010000
.byte 0b01010000
.byte 0b01010000
.byte 0b01010000
.byte 0b01010000
.byte 0b01010000
.byte 0b01010000
.byte 0b01010000
.byte 0b01010000
.byte 0b01010000
.byte 0b01010000
.byte 0b01010000
.byte 0b01010000
.byte 0b01010000
.byte 0b01010000
.byte 0b01010000
.byte 0b01010001
.byte 0b01010001
.byte 0b01010001
.byte 0b01010001
.byte 0b01010001
.byte 0b01010001
.byte 0b01010001
.byte 0b01010001
.byte 0b01010001
.byte 0b01010001
.byte 0b01010001
.byte 0b01010001
.byte 0b01010001
.byte 0b01010001
.byte 0b01010001
.byte 0b01010001
.byte 0b01010100
.byte 0b01010100
.byte 0b01010100
.byte 0b01010100
.byte 0b01010100
.byte 0b01010100
.byte 0b01010100
.byte 0b01010100
.byte 0b01010100
.byte 0b01010100
.byte 0b01010100
.byte 0b01010100
.byte 0b01010100
.byte 0b01010100
.byte 0b01010100
.byte 0b01010100
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000110
.byte 0b00000110
.byte 0b00000110
.byte 0b00000110
.byte 0b00000110
.byte 0b00000110
.byte 0b00000110
.byte 0b00000110
.byte 0b00000110
.byte 0b00000110
.byte 0b00000110
.byte 0b00000110
.byte 0b00000110
.byte 0b00000110
.byte 0b00000110
.byte 0b00000110
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100100
.byte 0b00100100
.byte 0b00100100
.byte 0b00100100
.byte 0b00100100
.byte 0b00100100
.byte 0b00100100
.byte 0b00100100
.byte 0b00100100
.byte 0b00100100
.byte 0b00100100
.byte 0b00100100
.byte 0b00100100
.byte 0b00100100
.byte 0b00100100
.byte 0b00100100
.byte 0b00100110
.byte 0b00100110
.byte 0b00100110
.byte 0b00100110
.byte 0b00100110
.byte 0b00100110
.byte 0b00100110
.byte 0b00100110
.byte 0b00100110
.byte 0b00100110
.byte 0b00100110
.byte 0b00100110
.byte 0b00100110
.byte 0b00100110
.byte 0b00100110
.byte 0b00100110
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000010
.byte 0b01000010
.byte 0b01000010
.byte 0b01000010
.byte 0b01000010
.byte 0b01000010
.byte 0b01000010
.byte 0b01000010
.byte 0b01000010
.byte 0b01000010
.byte 0b01000010
.byte 0b01000010
.byte 0b01000010
.byte 0b01000010
.byte 0b01000010
.byte 0b01000010
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000110
.byte 0b01000110
.byte 0b01000110
.byte 0b01000110
.byte 0b01000110
.byte 0b01000110
.byte 0b01000110
.byte 0b01000110
.byte 0b01000110
.byte 0b01000110
.byte 0b01000110
.byte 0b01000110
.byte 0b01000110
.byte 0b01000110
.byte 0b01000110
.byte 0b01000110
.byte 0b01100000
.byte 0b01100000
.byte 0b01100000
.byte 0b01100000
.byte 0b01100000
.byte 0b01100000
.byte 0b01100000
.byte 0b01100000
.byte 0b01100000
.byte 0b01100000
.byte 0b01100000
.byte 0b01100000
.byte 0b01100000
.byte 0b01100000
.byte 0b01100000
.byte 0b01100000
.byte 0b01100010
.byte 0b01100010
.byte 0b01100010
.byte 0b01100010
.byte 0b01100010
.byte 0b01100010
.byte 0b01100010
.byte 0b01100010
.byte 0b01100010
.byte 0b01100010
.byte 0b01100010
.byte 0b01100010
.byte 0b01100010
.byte 0b01100010
.byte 0b01100010
.byte 0b01100010
.byte 0b01100100
.byte 0b01100100
.byte 0b01100100
.byte 0b01100100
.byte 0b01100100
.byte 0b01100100
.byte 0b01100100
.byte 0b01100100
.byte 0b01100100
.byte 0b01100100
.byte 0b01100100
.byte 0b01100100
.byte 0b01100100
.byte 0b01100100
.byte 0b01100100
.byte 0b01100100
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000011
.byte 0b00000011
.byte 0b00000011
.byte 0b00000011
.byte 0b00000011
.byte 0b00000011
.byte 0b00000011
.byte 0b00000011
.byte 0b00000011
.byte 0b00000011
.byte 0b00000011
.byte 0b00000011
.byte 0b00000011
.byte 0b00000011
.byte 0b00000011
.byte 0b00000011
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000111
.byte 0b00000111
.byte 0b00000111
.byte 0b00000111
.byte 0b00000111
.byte 0b00000111
.byte 0b00000111
.byte 0b00000111
.byte 0b00000111
.byte 0b00000111
.byte 0b00000111
.byte 0b00000111
.byte 0b00000111
.byte 0b00000111
.byte 0b00000111
.byte 0b00000111
.byte 0b00110000
.byte 0b00110000
.byte 0b00110000
.byte 0b00110000
.byte 0b00110000
.byte 0b00110000
.byte 0b00110000
.byte 0b00110000
.byte 0b00110000
.byte 0b00110000
.byte 0b00110000
.byte 0b00110000
.byte 0b00110000
.byte 0b00110000
.byte 0b00110000
.byte 0b00110000
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110100
.byte 0b00110100
.byte 0b00110100
.byte 0b00110100
.byte 0b00110100
.byte 0b00110100
.byte 0b00110100
.byte 0b00110100
.byte 0b00110100
.byte 0b00110100
.byte 0b00110100
.byte 0b00110100
.byte 0b00110100
.byte 0b00110100
.byte 0b00110100
.byte 0b00110100
.byte 0b00110111
.byte 0b00110111
.byte 0b00110111
.byte 0b00110111
.byte 0b00110111
.byte 0b00110111
.byte 0b00110111
.byte 0b00110111
.byte 0b00110111
.byte 0b00110111
.byte 0b00110111
.byte 0b00110111
.byte 0b00110111
.byte 0b00110111
.byte 0b00110111
.byte 0b00110111
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000011
.byte 0b01000011
.byte 0b01000011
.byte 0b01000011
.byte 0b01000011
.byte 0b01000011
.byte 0b01000011
.byte 0b01000011
.byte 0b01000011
.byte 0b01000011
.byte 0b01000011
.byte 0b01000011
.byte 0b01000011
.byte 0b01000011
.byte 0b01000011
.byte 0b01000011
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000111
.byte 0b01000111
.byte 0b01000111
.byte 0b01000111
.byte 0b01000111
.byte 0b01000111
.byte 0b01000111
.byte 0b01000111
.byte 0b01000111
.byte 0b01000111
.byte 0b01000111
.byte 0b01000111
.byte 0b01000111
.byte 0b01000111
.byte 0b01000111
.byte 0b01000111
.byte 0b01110000
.byte 0b01110000
.byte 0b01110000
.byte 0b01110000
.byte 0b01110000
.byte 0b01110000
.byte 0b01110000
.byte 0b01110000
.byte 0b01110000
.byte 0b01110000
.byte 0b01110000
.byte 0b01110000
.byte 0b01110000
.byte 0b01110000
.byte 0b01110000
.byte 0b01110000
.byte 0b01110011
.byte 0b01110011
.byte 0b01110011
.byte 0b01110011
.byte 0b01110011
.byte 0b01110011
.byte 0b01110011
.byte 0b01110011
.byte 0b01110011
.byte 0b01110011
.byte 0b01110011
.byte 0b01110011
.byte 0b01110011
.byte 0b01110011
.byte 0b01110011
.byte 0b01110011
.byte 0b01110100
.byte 0b01110100
.byte 0b01110100
.byte 0b01110100
.byte 0b01110100
.byte 0b01110100
.byte 0b01110100
.byte 0b01110100
.byte 0b01110100
.byte 0b01110100
.byte 0b01110100
.byte 0b01110100
.byte 0b01110100
.byte 0b01110100
.byte 0b01110100
.byte 0b01110100
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001001
.byte 0b00001001
.byte 0b00001001
.byte 0b00001001
.byte 0b00001001
.byte 0b00001001
.byte 0b00001001
.byte 0b00001001
.byte 0b00001001
.byte 0b00001001
.byte 0b00001001
.byte 0b00001001
.byte 0b00001001
.byte 0b00001001
.byte 0b00001001
.byte 0b00001001
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00011000
.byte 0b00011000
.byte 0b00011000
.byte 0b00011000
.byte 0b00011000
.byte 0b00011000
.byte 0b00011000
.byte 0b00011000
.byte 0b00011000
.byte 0b00011000
.byte 0b00011000
.byte 0b00011000
.byte 0b00011000
.byte 0b00011000
.byte 0b00011000
.byte 0b00011000
.byte 0b00011001
.byte 0b00011001
.byte 0b00011001
.byte 0b00011001
.byte 0b00011001
.byte 0b00011001
.byte 0b00011001
.byte 0b00011001
.byte 0b00011001
.byte 0b00011001
.byte 0b00011001
.byte 0b00011001
.byte 0b00011001
.byte 0b00011001
.byte 0b00011001
.byte 0b00011001
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000001
.byte 0b10000001
.byte 0b10000001
.byte 0b10000001
.byte 0b10000001
.byte 0b10000001
.byte 0b10000001
.byte 0b10000001
.byte 0b10000001
.byte 0b10000001
.byte 0b10000001
.byte 0b10000001
.byte 0b10000001
.byte 0b10000001
.byte 0b10000001
.byte 0b10000001
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001001
.byte 0b10001001
.byte 0b10001001
.byte 0b10001001
.byte 0b10001001
.byte 0b10001001
.byte 0b10001001
.byte 0b10001001
.byte 0b10001001
.byte 0b10001001
.byte 0b10001001
.byte 0b10001001
.byte 0b10001001
.byte 0b10001001
.byte 0b10001001
.byte 0b10001001
.byte 0b10010000
.byte 0b10010000
.byte 0b10010000
.byte 0b10010000
.byte 0b10010000
.byte 0b10010000
.byte 0b10010000
.byte 0b10010000
.byte 0b10010000
.byte 0b10010000
.byte 0b10010000
.byte 0b10010000
.byte 0b10010000
.byte 0b10010000
.byte 0b10010000
.byte 0b10010000
.byte 0b10010001
.byte 0b10010001
.byte 0b10010001
.byte 0b10010001
.byte 0b10010001
.byte 0b10010001
.byte 0b10010001
.byte 0b10010001
.byte 0b10010001
.byte 0b10010001
.byte 0b10010001
.byte 0b10010001
.byte 0b10010001
.byte 0b10010001
.byte 0b10010001
.byte 0b10010001
.byte 0b10011000
.byte 0b10011000
.byte 0b10011000
.byte 0b10011000
.byte 0b10011000
.byte 0b10011000
.byte 0b10011000
.byte 0b10011000
.byte 0b10011000
.byte 0b10011000
.byte 0b10011000
.byte 0b10011000
.byte 0b10011000
.byte 0b10011000
.byte 0b10011000
.byte 0b10011000
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00000010
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001010
.byte 0b00001010
.byte 0b00001010
.byte 0b00001010
.byte 0b00001010
.byte 0b00001010
.byte 0b00001010
.byte 0b00001010
.byte 0b00001010
.byte 0b00001010
.byte 0b00001010
.byte 0b00001010
.byte 0b00001010
.byte 0b00001010
.byte 0b00001010
.byte 0b00001010
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100000
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00101000
.byte 0b00101000
.byte 0b00101000
.byte 0b00101000
.byte 0b00101000
.byte 0b00101000
.byte 0b00101000
.byte 0b00101000
.byte 0b00101000
.byte 0b00101000
.byte 0b00101000
.byte 0b00101000
.byte 0b00101000
.byte 0b00101000
.byte 0b00101000
.byte 0b00101000
.byte 0b00101010
.byte 0b00101010
.byte 0b00101010
.byte 0b00101010
.byte 0b00101010
.byte 0b00101010
.byte 0b00101010
.byte 0b00101010
.byte 0b00101010
.byte 0b00101010
.byte 0b00101010
.byte 0b00101010
.byte 0b00101010
.byte 0b00101010
.byte 0b00101010
.byte 0b00101010
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000010
.byte 0b10000010
.byte 0b10000010
.byte 0b10000010
.byte 0b10000010
.byte 0b10000010
.byte 0b10000010
.byte 0b10000010
.byte 0b10000010
.byte 0b10000010
.byte 0b10000010
.byte 0b10000010
.byte 0b10000010
.byte 0b10000010
.byte 0b10000010
.byte 0b10000010
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001010
.byte 0b10001010
.byte 0b10001010
.byte 0b10001010
.byte 0b10001010
.byte 0b10001010
.byte 0b10001010
.byte 0b10001010
.byte 0b10001010
.byte 0b10001010
.byte 0b10001010
.byte 0b10001010
.byte 0b10001010
.byte 0b10001010
.byte 0b10001010
.byte 0b10001010
.byte 0b10100000
.byte 0b10100000
.byte 0b10100000
.byte 0b10100000
.byte 0b10100000
.byte 0b10100000
.byte 0b10100000
.byte 0b10100000
.byte 0b10100000
.byte 0b10100000
.byte 0b10100000
.byte 0b10100000
.byte 0b10100000
.byte 0b10100000
.byte 0b10100000
.byte 0b10100000
.byte 0b10100010
.byte 0b10100010
.byte 0b10100010
.byte 0b10100010
.byte 0b10100010
.byte 0b10100010
.byte 0b10100010
.byte 0b10100010
.byte 0b10100010
.byte 0b10100010
.byte 0b10100010
.byte 0b10100010
.byte 0b10100010
.byte 0b10100010
.byte 0b10100010
.byte 0b10100010
.byte 0b10101000
.byte 0b10101000
.byte 0b10101000
.byte 0b10101000
.byte 0b10101000
.byte 0b10101000
.byte 0b10101000
.byte 0b10101000
.byte 0b10101000
.byte 0b10101000
.byte 0b10101000
.byte 0b10101000
.byte 0b10101000
.byte 0b10101000
.byte 0b10101000
.byte 0b10101000
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00000001
.byte 0b00001010
.byte 0b00001010
.byte 0b00001010
.byte 0b00001010
.byte 0b00001010
.byte 0b00001010
.byte 0b00001010
.byte 0b00001010
.byte 0b00001010
.byte 0b00001010
.byte 0b00001010
.byte 0b00001010
.byte 0b00001010
.byte 0b00001010
.byte 0b00001010
.byte 0b00001010
.byte 0b00001011
.byte 0b00001011
.byte 0b00001011
.byte 0b00001011
.byte 0b00001011
.byte 0b00001011
.byte 0b00001011
.byte 0b00001011
.byte 0b00001011
.byte 0b00001011
.byte 0b00001011
.byte 0b00001011
.byte 0b00001011
.byte 0b00001011
.byte 0b00001011
.byte 0b00001011
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010000
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00011010
.byte 0b00011010
.byte 0b00011010
.byte 0b00011010
.byte 0b00011010
.byte 0b00011010
.byte 0b00011010
.byte 0b00011010
.byte 0b00011010
.byte 0b00011010
.byte 0b00011010
.byte 0b00011010
.byte 0b00011010
.byte 0b00011010
.byte 0b00011010
.byte 0b00011010
.byte 0b00011011
.byte 0b00011011
.byte 0b00011011
.byte 0b00011011
.byte 0b00011011
.byte 0b00011011
.byte 0b00011011
.byte 0b00011011
.byte 0b00011011
.byte 0b00011011
.byte 0b00011011
.byte 0b00011011
.byte 0b00011011
.byte 0b00011011
.byte 0b00011011
.byte 0b00011011
.byte 0b10100000
.byte 0b10100000
.byte 0b10100000
.byte 0b10100000
.byte 0b10100000
.byte 0b10100000
.byte 0b10100000
.byte 0b10100000
.byte 0b10100000
.byte 0b10100000
.byte 0b10100000
.byte 0b10100000
.byte 0b10100000
.byte 0b10100000
.byte 0b10100000
.byte 0b10100000
.byte 0b10100001
.byte 0b10100001
.byte 0b10100001
.byte 0b10100001
.byte 0b10100001
.byte 0b10100001
.byte 0b10100001
.byte 0b10100001
.byte 0b10100001
.byte 0b10100001
.byte 0b10100001
.byte 0b10100001
.byte 0b10100001
.byte 0b10100001
.byte 0b10100001
.byte 0b10100001
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101011
.byte 0b10101011
.byte 0b10101011
.byte 0b10101011
.byte 0b10101011
.byte 0b10101011
.byte 0b10101011
.byte 0b10101011
.byte 0b10101011
.byte 0b10101011
.byte 0b10101011
.byte 0b10101011
.byte 0b10101011
.byte 0b10101011
.byte 0b10101011
.byte 0b10101011
.byte 0b10110000
.byte 0b10110000
.byte 0b10110000
.byte 0b10110000
.byte 0b10110000
.byte 0b10110000
.byte 0b10110000
.byte 0b10110000
.byte 0b10110000
.byte 0b10110000
.byte 0b10110000
.byte 0b10110000
.byte 0b10110000
.byte 0b10110000
.byte 0b10110000
.byte 0b10110000
.byte 0b10110001
.byte 0b10110001
.byte 0b10110001
.byte 0b10110001
.byte 0b10110001
.byte 0b10110001
.byte 0b10110001
.byte 0b10110001
.byte 0b10110001
.byte 0b10110001
.byte 0b10110001
.byte 0b10110001
.byte 0b10110001
.byte 0b10110001
.byte 0b10110001
.byte 0b10110001
.byte 0b10111010
.byte 0b10111010
.byte 0b10111010
.byte 0b10111010
.byte 0b10111010
.byte 0b10111010
.byte 0b10111010
.byte 0b10111010
.byte 0b10111010
.byte 0b10111010
.byte 0b10111010
.byte 0b10111010
.byte 0b10111010
.byte 0b10111010
.byte 0b10111010
.byte 0b10111010
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00000100
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001100
.byte 0b00001100
.byte 0b00001100
.byte 0b00001100
.byte 0b00001100
.byte 0b00001100
.byte 0b00001100
.byte 0b00001100
.byte 0b00001100
.byte 0b00001100
.byte 0b00001100
.byte 0b00001100
.byte 0b00001100
.byte 0b00001100
.byte 0b00001100
.byte 0b00001100
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000000
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01001000
.byte 0b01001000
.byte 0b01001000
.byte 0b01001000
.byte 0b01001000
.byte 0b01001000
.byte 0b01001000
.byte 0b01001000
.byte 0b01001000
.byte 0b01001000
.byte 0b01001000
.byte 0b01001000
.byte 0b01001000
.byte 0b01001000
.byte 0b01001000
.byte 0b01001000
.byte 0b01001100
.byte 0b01001100
.byte 0b01001100
.byte 0b01001100
.byte 0b01001100
.byte 0b01001100
.byte 0b01001100
.byte 0b01001100
.byte 0b01001100
.byte 0b01001100
.byte 0b01001100
.byte 0b01001100
.byte 0b01001100
.byte 0b01001100
.byte 0b01001100
.byte 0b01001100
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000100
.byte 0b10000100
.byte 0b10000100
.byte 0b10000100
.byte 0b10000100
.byte 0b10000100
.byte 0b10000100
.byte 0b10000100
.byte 0b10000100
.byte 0b10000100
.byte 0b10000100
.byte 0b10000100
.byte 0b10000100
.byte 0b10000100
.byte 0b10000100
.byte 0b10000100
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001100
.byte 0b10001100
.byte 0b10001100
.byte 0b10001100
.byte 0b10001100
.byte 0b10001100
.byte 0b10001100
.byte 0b10001100
.byte 0b10001100
.byte 0b10001100
.byte 0b10001100
.byte 0b10001100
.byte 0b10001100
.byte 0b10001100
.byte 0b10001100
.byte 0b10001100
.byte 0b11000000
.byte 0b11000000
.byte 0b11000000
.byte 0b11000000
.byte 0b11000000
.byte 0b11000000
.byte 0b11000000
.byte 0b11000000
.byte 0b11000000
.byte 0b11000000
.byte 0b11000000
.byte 0b11000000
.byte 0b11000000
.byte 0b11000000
.byte 0b11000000
.byte 0b11000000
.byte 0b11000100
.byte 0b11000100
.byte 0b11000100
.byte 0b11000100
.byte 0b11000100
.byte 0b11000100
.byte 0b11000100
.byte 0b11000100
.byte 0b11000100
.byte 0b11000100
.byte 0b11000100
.byte 0b11000100
.byte 0b11000100
.byte 0b11000100
.byte 0b11000100
.byte 0b11000100
.byte 0b11001000
.byte 0b11001000
.byte 0b11001000
.byte 0b11001000
.byte 0b11001000
.byte 0b11001000
.byte 0b11001000
.byte 0b11001000
.byte 0b11001000
.byte 0b11001000
.byte 0b11001000
.byte 0b11001000
.byte 0b11001000
.byte 0b11001000
.byte 0b11001000
.byte 0b11001000
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000101
.byte 0b00000101
.byte 0b00000101
.byte 0b00000101
.byte 0b00000101
.byte 0b00000101
.byte 0b00000101
.byte 0b00000101
.byte 0b00000101
.byte 0b00000101
.byte 0b00000101
.byte 0b00000101
.byte 0b00000101
.byte 0b00000101
.byte 0b00000101
.byte 0b00000101
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001101
.byte 0b00001101
.byte 0b00001101
.byte 0b00001101
.byte 0b00001101
.byte 0b00001101
.byte 0b00001101
.byte 0b00001101
.byte 0b00001101
.byte 0b00001101
.byte 0b00001101
.byte 0b00001101
.byte 0b00001101
.byte 0b00001101
.byte 0b00001101
.byte 0b00001101
.byte 0b01010000
.byte 0b01010000
.byte 0b01010000
.byte 0b01010000
.byte 0b01010000
.byte 0b01010000
.byte 0b01010000
.byte 0b01010000
.byte 0b01010000
.byte 0b01010000
.byte 0b01010000
.byte 0b01010000
.byte 0b01010000
.byte 0b01010000
.byte 0b01010000
.byte 0b01010000
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01011000
.byte 0b01011000
.byte 0b01011000
.byte 0b01011000
.byte 0b01011000
.byte 0b01011000
.byte 0b01011000
.byte 0b01011000
.byte 0b01011000
.byte 0b01011000
.byte 0b01011000
.byte 0b01011000
.byte 0b01011000
.byte 0b01011000
.byte 0b01011000
.byte 0b01011000
.byte 0b01011101
.byte 0b01011101
.byte 0b01011101
.byte 0b01011101
.byte 0b01011101
.byte 0b01011101
.byte 0b01011101
.byte 0b01011101
.byte 0b01011101
.byte 0b01011101
.byte 0b01011101
.byte 0b01011101
.byte 0b01011101
.byte 0b01011101
.byte 0b01011101
.byte 0b01011101
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000101
.byte 0b10000101
.byte 0b10000101
.byte 0b10000101
.byte 0b10000101
.byte 0b10000101
.byte 0b10000101
.byte 0b10000101
.byte 0b10000101
.byte 0b10000101
.byte 0b10000101
.byte 0b10000101
.byte 0b10000101
.byte 0b10000101
.byte 0b10000101
.byte 0b10000101
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001101
.byte 0b10001101
.byte 0b10001101
.byte 0b10001101
.byte 0b10001101
.byte 0b10001101
.byte 0b10001101
.byte 0b10001101
.byte 0b10001101
.byte 0b10001101
.byte 0b10001101
.byte 0b10001101
.byte 0b10001101
.byte 0b10001101
.byte 0b10001101
.byte 0b10001101
.byte 0b11010000
.byte 0b11010000
.byte 0b11010000
.byte 0b11010000
.byte 0b11010000
.byte 0b11010000
.byte 0b11010000
.byte 0b11010000
.byte 0b11010000
.byte 0b11010000
.byte 0b11010000
.byte 0b11010000
.byte 0b11010000
.byte 0b11010000
.byte 0b11010000
.byte 0b11010000
.byte 0b11010101
.byte 0b11010101
.byte 0b11010101
.byte 0b11010101
.byte 0b11010101
.byte 0b11010101
.byte 0b11010101
.byte 0b11010101
.byte 0b11010101
.byte 0b11010101
.byte 0b11010101
.byte 0b11010101
.byte 0b11010101
.byte 0b11010101
.byte 0b11010101
.byte 0b11010101
.byte 0b11011000
.byte 0b11011000
.byte 0b11011000
.byte 0b11011000
.byte 0b11011000
.byte 0b11011000
.byte 0b11011000
.byte 0b11011000
.byte 0b11011000
.byte 0b11011000
.byte 0b11011000
.byte 0b11011000
.byte 0b11011000
.byte 0b11011000
.byte 0b11011000
.byte 0b11011000
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000110
.byte 0b00000110
.byte 0b00000110
.byte 0b00000110
.byte 0b00000110
.byte 0b00000110
.byte 0b00000110
.byte 0b00000110
.byte 0b00000110
.byte 0b00000110
.byte 0b00000110
.byte 0b00000110
.byte 0b00000110
.byte 0b00000110
.byte 0b00000110
.byte 0b00000110
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001000
.byte 0b00001110
.byte 0b00001110
.byte 0b00001110
.byte 0b00001110
.byte 0b00001110
.byte 0b00001110
.byte 0b00001110
.byte 0b00001110
.byte 0b00001110
.byte 0b00001110
.byte 0b00001110
.byte 0b00001110
.byte 0b00001110
.byte 0b00001110
.byte 0b00001110
.byte 0b00001110
.byte 0b01100000
.byte 0b01100000
.byte 0b01100000
.byte 0b01100000
.byte 0b01100000
.byte 0b01100000
.byte 0b01100000
.byte 0b01100000
.byte 0b01100000
.byte 0b01100000
.byte 0b01100000
.byte 0b01100000
.byte 0b01100000
.byte 0b01100000
.byte 0b01100000
.byte 0b01100000
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01101000
.byte 0b01101000
.byte 0b01101000
.byte 0b01101000
.byte 0b01101000
.byte 0b01101000
.byte 0b01101000
.byte 0b01101000
.byte 0b01101000
.byte 0b01101000
.byte 0b01101000
.byte 0b01101000
.byte 0b01101000
.byte 0b01101000
.byte 0b01101000
.byte 0b01101000
.byte 0b01101110
.byte 0b01101110
.byte 0b01101110
.byte 0b01101110
.byte 0b01101110
.byte 0b01101110
.byte 0b01101110
.byte 0b01101110
.byte 0b01101110
.byte 0b01101110
.byte 0b01101110
.byte 0b01101110
.byte 0b01101110
.byte 0b01101110
.byte 0b01101110
.byte 0b01101110
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000000
.byte 0b10000110
.byte 0b10000110
.byte 0b10000110
.byte 0b10000110
.byte 0b10000110
.byte 0b10000110
.byte 0b10000110
.byte 0b10000110
.byte 0b10000110
.byte 0b10000110
.byte 0b10000110
.byte 0b10000110
.byte 0b10000110
.byte 0b10000110
.byte 0b10000110
.byte 0b10000110
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001110
.byte 0b10001110
.byte 0b10001110
.byte 0b10001110
.byte 0b10001110
.byte 0b10001110
.byte 0b10001110
.byte 0b10001110
.byte 0b10001110
.byte 0b10001110
.byte 0b10001110
.byte 0b10001110
.byte 0b10001110
.byte 0b10001110
.byte 0b10001110
.byte 0b10001110
.byte 0b11100000
.byte 0b11100000
.byte 0b11100000
.byte 0b11100000
.byte 0b11100000
.byte 0b11100000
.byte 0b11100000
.byte 0b11100000
.byte 0b11100000
.byte 0b11100000
.byte 0b11100000
.byte 0b11100000
.byte 0b11100000
.byte 0b11100000
.byte 0b11100000
.byte 0b11100000
.byte 0b11100110
.byte 0b11100110
.byte 0b11100110
.byte 0b11100110
.byte 0b11100110
.byte 0b11100110
.byte 0b11100110
.byte 0b11100110
.byte 0b11100110
.byte 0b11100110
.byte 0b11100110
.byte 0b11100110
.byte 0b11100110
.byte 0b11100110
.byte 0b11100110
.byte 0b11100110
.byte 0b11101000
.byte 0b11101000
.byte 0b11101000
.byte 0b11101000
.byte 0b11101000
.byte 0b11101000
.byte 0b11101000
.byte 0b11101000
.byte 0b11101000
.byte 0b11101000
.byte 0b11101000
.byte 0b11101000
.byte 0b11101000
.byte 0b11101000
.byte 0b11101000
.byte 0b11101000
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000011
.byte 0b00000011
.byte 0b00000011
.byte 0b00000011
.byte 0b00000011
.byte 0b00000011
.byte 0b00000011
.byte 0b00000011
.byte 0b00000011
.byte 0b00000011
.byte 0b00000011
.byte 0b00000011
.byte 0b00000011
.byte 0b00000011
.byte 0b00000011
.byte 0b00000011
.byte 0b00001100
.byte 0b00001100
.byte 0b00001100
.byte 0b00001100
.byte 0b00001100
.byte 0b00001100
.byte 0b00001100
.byte 0b00001100
.byte 0b00001100
.byte 0b00001100
.byte 0b00001100
.byte 0b00001100
.byte 0b00001100
.byte 0b00001100
.byte 0b00001100
.byte 0b00001100
.byte 0b00001111
.byte 0b00001111
.byte 0b00001111
.byte 0b00001111
.byte 0b00001111
.byte 0b00001111
.byte 0b00001111
.byte 0b00001111
.byte 0b00001111
.byte 0b00001111
.byte 0b00001111
.byte 0b00001111
.byte 0b00001111
.byte 0b00001111
.byte 0b00001111
.byte 0b00001111
.byte 0b00110000
.byte 0b00110000
.byte 0b00110000
.byte 0b00110000
.byte 0b00110000
.byte 0b00110000
.byte 0b00110000
.byte 0b00110000
.byte 0b00110000
.byte 0b00110000
.byte 0b00110000
.byte 0b00110000
.byte 0b00110000
.byte 0b00110000
.byte 0b00110000
.byte 0b00110000
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00111100
.byte 0b00111100
.byte 0b00111100
.byte 0b00111100
.byte 0b00111100
.byte 0b00111100
.byte 0b00111100
.byte 0b00111100
.byte 0b00111100
.byte 0b00111100
.byte 0b00111100
.byte 0b00111100
.byte 0b00111100
.byte 0b00111100
.byte 0b00111100
.byte 0b00111100
.byte 0b00111111
.byte 0b00111111
.byte 0b00111111
.byte 0b00111111
.byte 0b00111111
.byte 0b00111111
.byte 0b00111111
.byte 0b00111111
.byte 0b00111111
.byte 0b00111111
.byte 0b00111111
.byte 0b00111111
.byte 0b00111111
.byte 0b00111111
.byte 0b00111111
.byte 0b00111111
.byte 0b11000000
.byte 0b11000000
.byte 0b11000000
.byte 0b11000000
.byte 0b11000000
.byte 0b11000000
.byte 0b11000000
.byte 0b11000000
.byte 0b11000000
.byte 0b11000000
.byte 0b11000000
.byte 0b11000000
.byte 0b11000000
.byte 0b11000000
.byte 0b11000000
.byte 0b11000000
.byte 0b11000011
.byte 0b11000011
.byte 0b11000011
.byte 0b11000011
.byte 0b11000011
.byte 0b11000011
.byte 0b11000011
.byte 0b11000011
.byte 0b11000011
.byte 0b11000011
.byte 0b11000011
.byte 0b11000011
.byte 0b11000011
.byte 0b11000011
.byte 0b11000011
.byte 0b11000011
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001111
.byte 0b11001111
.byte 0b11001111
.byte 0b11001111
.byte 0b11001111
.byte 0b11001111
.byte 0b11001111
.byte 0b11001111
.byte 0b11001111
.byte 0b11001111
.byte 0b11001111
.byte 0b11001111
.byte 0b11001111
.byte 0b11001111
.byte 0b11001111
.byte 0b11001111
.byte 0b11110000
.byte 0b11110000
.byte 0b11110000
.byte 0b11110000
.byte 0b11110000
.byte 0b11110000
.byte 0b11110000
.byte 0b11110000
.byte 0b11110000
.byte 0b11110000
.byte 0b11110000
.byte 0b11110000
.byte 0b11110000
.byte 0b11110000
.byte 0b11110000
.byte 0b11110000
.byte 0b11110011
.byte 0b11110011
.byte 0b11110011
.byte 0b11110011
.byte 0b11110011
.byte 0b11110011
.byte 0b11110011
.byte 0b11110011
.byte 0b11110011
.byte 0b11110011
.byte 0b11110011
.byte 0b11110011
.byte 0b11110011
.byte 0b11110011
.byte 0b11110011
.byte 0b11110011
.byte 0b11111100
.byte 0b11111100
.byte 0b11111100
.byte 0b11111100
.byte 0b11111100
.byte 0b11111100
.byte 0b11111100
.byte 0b11111100
.byte 0b11111100
.byte 0b11111100
.byte 0b11111100
.byte 0b11111100
.byte 0b11111100
.byte 0b11111100
.byte 0b11111100
.byte 0b11111100
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010011
.byte 0b00010011
.byte 0b00010011
.byte 0b00010011
.byte 0b00010011
.byte 0b00010011
.byte 0b00010011
.byte 0b00010011
.byte 0b00010011
.byte 0b00010011
.byte 0b00010011
.byte 0b00010011
.byte 0b00010011
.byte 0b00010011
.byte 0b00010011
.byte 0b00010011
.byte 0b00010101
.byte 0b00010101
.byte 0b00010101
.byte 0b00010101
.byte 0b00010101
.byte 0b00010101
.byte 0b00010101
.byte 0b00010101
.byte 0b00010101
.byte 0b00010101
.byte 0b00010101
.byte 0b00010101
.byte 0b00010101
.byte 0b00010101
.byte 0b00010101
.byte 0b00010101
.byte 0b00010111
.byte 0b00010111
.byte 0b00010111
.byte 0b00010111
.byte 0b00010111
.byte 0b00010111
.byte 0b00010111
.byte 0b00010111
.byte 0b00010111
.byte 0b00010111
.byte 0b00010111
.byte 0b00010111
.byte 0b00010111
.byte 0b00010111
.byte 0b00010111
.byte 0b00010111
.byte 0b00110001
.byte 0b00110001
.byte 0b00110001
.byte 0b00110001
.byte 0b00110001
.byte 0b00110001
.byte 0b00110001
.byte 0b00110001
.byte 0b00110001
.byte 0b00110001
.byte 0b00110001
.byte 0b00110001
.byte 0b00110001
.byte 0b00110001
.byte 0b00110001
.byte 0b00110001
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110101
.byte 0b00110101
.byte 0b00110101
.byte 0b00110101
.byte 0b00110101
.byte 0b00110101
.byte 0b00110101
.byte 0b00110101
.byte 0b00110101
.byte 0b00110101
.byte 0b00110101
.byte 0b00110101
.byte 0b00110101
.byte 0b00110101
.byte 0b00110101
.byte 0b00110101
.byte 0b00110111
.byte 0b00110111
.byte 0b00110111
.byte 0b00110111
.byte 0b00110111
.byte 0b00110111
.byte 0b00110111
.byte 0b00110111
.byte 0b00110111
.byte 0b00110111
.byte 0b00110111
.byte 0b00110111
.byte 0b00110111
.byte 0b00110111
.byte 0b00110111
.byte 0b00110111
.byte 0b01010001
.byte 0b01010001
.byte 0b01010001
.byte 0b01010001
.byte 0b01010001
.byte 0b01010001
.byte 0b01010001
.byte 0b01010001
.byte 0b01010001
.byte 0b01010001
.byte 0b01010001
.byte 0b01010001
.byte 0b01010001
.byte 0b01010001
.byte 0b01010001
.byte 0b01010001
.byte 0b01010011
.byte 0b01010011
.byte 0b01010011
.byte 0b01010011
.byte 0b01010011
.byte 0b01010011
.byte 0b01010011
.byte 0b01010011
.byte 0b01010011
.byte 0b01010011
.byte 0b01010011
.byte 0b01010011
.byte 0b01010011
.byte 0b01010011
.byte 0b01010011
.byte 0b01010011
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010111
.byte 0b01010111
.byte 0b01010111
.byte 0b01010111
.byte 0b01010111
.byte 0b01010111
.byte 0b01010111
.byte 0b01010111
.byte 0b01010111
.byte 0b01010111
.byte 0b01010111
.byte 0b01010111
.byte 0b01010111
.byte 0b01010111
.byte 0b01010111
.byte 0b01010111
.byte 0b01110001
.byte 0b01110001
.byte 0b01110001
.byte 0b01110001
.byte 0b01110001
.byte 0b01110001
.byte 0b01110001
.byte 0b01110001
.byte 0b01110001
.byte 0b01110001
.byte 0b01110001
.byte 0b01110001
.byte 0b01110001
.byte 0b01110001
.byte 0b01110001
.byte 0b01110001
.byte 0b01110011
.byte 0b01110011
.byte 0b01110011
.byte 0b01110011
.byte 0b01110011
.byte 0b01110011
.byte 0b01110011
.byte 0b01110011
.byte 0b01110011
.byte 0b01110011
.byte 0b01110011
.byte 0b01110011
.byte 0b01110011
.byte 0b01110011
.byte 0b01110011
.byte 0b01110011
.byte 0b01110101
.byte 0b01110101
.byte 0b01110101
.byte 0b01110101
.byte 0b01110101
.byte 0b01110101
.byte 0b01110101
.byte 0b01110101
.byte 0b01110101
.byte 0b01110101
.byte 0b01110101
.byte 0b01110101
.byte 0b01110101
.byte 0b01110101
.byte 0b01110101
.byte 0b01110101
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010011
.byte 0b00010011
.byte 0b00010011
.byte 0b00010011
.byte 0b00010011
.byte 0b00010011
.byte 0b00010011
.byte 0b00010011
.byte 0b00010011
.byte 0b00010011
.byte 0b00010011
.byte 0b00010011
.byte 0b00010011
.byte 0b00010011
.byte 0b00010011
.byte 0b00010011
.byte 0b00011001
.byte 0b00011001
.byte 0b00011001
.byte 0b00011001
.byte 0b00011001
.byte 0b00011001
.byte 0b00011001
.byte 0b00011001
.byte 0b00011001
.byte 0b00011001
.byte 0b00011001
.byte 0b00011001
.byte 0b00011001
.byte 0b00011001
.byte 0b00011001
.byte 0b00011001
.byte 0b00011011
.byte 0b00011011
.byte 0b00011011
.byte 0b00011011
.byte 0b00011011
.byte 0b00011011
.byte 0b00011011
.byte 0b00011011
.byte 0b00011011
.byte 0b00011011
.byte 0b00011011
.byte 0b00011011
.byte 0b00011011
.byte 0b00011011
.byte 0b00011011
.byte 0b00011011
.byte 0b00110001
.byte 0b00110001
.byte 0b00110001
.byte 0b00110001
.byte 0b00110001
.byte 0b00110001
.byte 0b00110001
.byte 0b00110001
.byte 0b00110001
.byte 0b00110001
.byte 0b00110001
.byte 0b00110001
.byte 0b00110001
.byte 0b00110001
.byte 0b00110001
.byte 0b00110001
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00111001
.byte 0b00111001
.byte 0b00111001
.byte 0b00111001
.byte 0b00111001
.byte 0b00111001
.byte 0b00111001
.byte 0b00111001
.byte 0b00111001
.byte 0b00111001
.byte 0b00111001
.byte 0b00111001
.byte 0b00111001
.byte 0b00111001
.byte 0b00111001
.byte 0b00111001
.byte 0b00111011
.byte 0b00111011
.byte 0b00111011
.byte 0b00111011
.byte 0b00111011
.byte 0b00111011
.byte 0b00111011
.byte 0b00111011
.byte 0b00111011
.byte 0b00111011
.byte 0b00111011
.byte 0b00111011
.byte 0b00111011
.byte 0b00111011
.byte 0b00111011
.byte 0b00111011
.byte 0b10010001
.byte 0b10010001
.byte 0b10010001
.byte 0b10010001
.byte 0b10010001
.byte 0b10010001
.byte 0b10010001
.byte 0b10010001
.byte 0b10010001
.byte 0b10010001
.byte 0b10010001
.byte 0b10010001
.byte 0b10010001
.byte 0b10010001
.byte 0b10010001
.byte 0b10010001
.byte 0b10010011
.byte 0b10010011
.byte 0b10010011
.byte 0b10010011
.byte 0b10010011
.byte 0b10010011
.byte 0b10010011
.byte 0b10010011
.byte 0b10010011
.byte 0b10010011
.byte 0b10010011
.byte 0b10010011
.byte 0b10010011
.byte 0b10010011
.byte 0b10010011
.byte 0b10010011
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011011
.byte 0b10011011
.byte 0b10011011
.byte 0b10011011
.byte 0b10011011
.byte 0b10011011
.byte 0b10011011
.byte 0b10011011
.byte 0b10011011
.byte 0b10011011
.byte 0b10011011
.byte 0b10011011
.byte 0b10011011
.byte 0b10011011
.byte 0b10011011
.byte 0b10011011
.byte 0b10110001
.byte 0b10110001
.byte 0b10110001
.byte 0b10110001
.byte 0b10110001
.byte 0b10110001
.byte 0b10110001
.byte 0b10110001
.byte 0b10110001
.byte 0b10110001
.byte 0b10110001
.byte 0b10110001
.byte 0b10110001
.byte 0b10110001
.byte 0b10110001
.byte 0b10110001
.byte 0b10110011
.byte 0b10110011
.byte 0b10110011
.byte 0b10110011
.byte 0b10110011
.byte 0b10110011
.byte 0b10110011
.byte 0b10110011
.byte 0b10110011
.byte 0b10110011
.byte 0b10110011
.byte 0b10110011
.byte 0b10110011
.byte 0b10110011
.byte 0b10110011
.byte 0b10110011
.byte 0b10111001
.byte 0b10111001
.byte 0b10111001
.byte 0b10111001
.byte 0b10111001
.byte 0b10111001
.byte 0b10111001
.byte 0b10111001
.byte 0b10111001
.byte 0b10111001
.byte 0b10111001
.byte 0b10111001
.byte 0b10111001
.byte 0b10111001
.byte 0b10111001
.byte 0b10111001
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010101
.byte 0b00010101
.byte 0b00010101
.byte 0b00010101
.byte 0b00010101
.byte 0b00010101
.byte 0b00010101
.byte 0b00010101
.byte 0b00010101
.byte 0b00010101
.byte 0b00010101
.byte 0b00010101
.byte 0b00010101
.byte 0b00010101
.byte 0b00010101
.byte 0b00010101
.byte 0b00011001
.byte 0b00011001
.byte 0b00011001
.byte 0b00011001
.byte 0b00011001
.byte 0b00011001
.byte 0b00011001
.byte 0b00011001
.byte 0b00011001
.byte 0b00011001
.byte 0b00011001
.byte 0b00011001
.byte 0b00011001
.byte 0b00011001
.byte 0b00011001
.byte 0b00011001
.byte 0b00011101
.byte 0b00011101
.byte 0b00011101
.byte 0b00011101
.byte 0b00011101
.byte 0b00011101
.byte 0b00011101
.byte 0b00011101
.byte 0b00011101
.byte 0b00011101
.byte 0b00011101
.byte 0b00011101
.byte 0b00011101
.byte 0b00011101
.byte 0b00011101
.byte 0b00011101
.byte 0b01010001
.byte 0b01010001
.byte 0b01010001
.byte 0b01010001
.byte 0b01010001
.byte 0b01010001
.byte 0b01010001
.byte 0b01010001
.byte 0b01010001
.byte 0b01010001
.byte 0b01010001
.byte 0b01010001
.byte 0b01010001
.byte 0b01010001
.byte 0b01010001
.byte 0b01010001
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01011001
.byte 0b01011001
.byte 0b01011001
.byte 0b01011001
.byte 0b01011001
.byte 0b01011001
.byte 0b01011001
.byte 0b01011001
.byte 0b01011001
.byte 0b01011001
.byte 0b01011001
.byte 0b01011001
.byte 0b01011001
.byte 0b01011001
.byte 0b01011001
.byte 0b01011001
.byte 0b01011101
.byte 0b01011101
.byte 0b01011101
.byte 0b01011101
.byte 0b01011101
.byte 0b01011101
.byte 0b01011101
.byte 0b01011101
.byte 0b01011101
.byte 0b01011101
.byte 0b01011101
.byte 0b01011101
.byte 0b01011101
.byte 0b01011101
.byte 0b01011101
.byte 0b01011101
.byte 0b10010001
.byte 0b10010001
.byte 0b10010001
.byte 0b10010001
.byte 0b10010001
.byte 0b10010001
.byte 0b10010001
.byte 0b10010001
.byte 0b10010001
.byte 0b10010001
.byte 0b10010001
.byte 0b10010001
.byte 0b10010001
.byte 0b10010001
.byte 0b10010001
.byte 0b10010001
.byte 0b10010101
.byte 0b10010101
.byte 0b10010101
.byte 0b10010101
.byte 0b10010101
.byte 0b10010101
.byte 0b10010101
.byte 0b10010101
.byte 0b10010101
.byte 0b10010101
.byte 0b10010101
.byte 0b10010101
.byte 0b10010101
.byte 0b10010101
.byte 0b10010101
.byte 0b10010101
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011101
.byte 0b10011101
.byte 0b10011101
.byte 0b10011101
.byte 0b10011101
.byte 0b10011101
.byte 0b10011101
.byte 0b10011101
.byte 0b10011101
.byte 0b10011101
.byte 0b10011101
.byte 0b10011101
.byte 0b10011101
.byte 0b10011101
.byte 0b10011101
.byte 0b10011101
.byte 0b11010001
.byte 0b11010001
.byte 0b11010001
.byte 0b11010001
.byte 0b11010001
.byte 0b11010001
.byte 0b11010001
.byte 0b11010001
.byte 0b11010001
.byte 0b11010001
.byte 0b11010001
.byte 0b11010001
.byte 0b11010001
.byte 0b11010001
.byte 0b11010001
.byte 0b11010001
.byte 0b11010101
.byte 0b11010101
.byte 0b11010101
.byte 0b11010101
.byte 0b11010101
.byte 0b11010101
.byte 0b11010101
.byte 0b11010101
.byte 0b11010101
.byte 0b11010101
.byte 0b11010101
.byte 0b11010101
.byte 0b11010101
.byte 0b11010101
.byte 0b11010101
.byte 0b11010101
.byte 0b11011001
.byte 0b11011001
.byte 0b11011001
.byte 0b11011001
.byte 0b11011001
.byte 0b11011001
.byte 0b11011001
.byte 0b11011001
.byte 0b11011001
.byte 0b11011001
.byte 0b11011001
.byte 0b11011001
.byte 0b11011001
.byte 0b11011001
.byte 0b11011001
.byte 0b11011001
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010001
.byte 0b00010111
.byte 0b00010111
.byte 0b00010111
.byte 0b00010111
.byte 0b00010111
.byte 0b00010111
.byte 0b00010111
.byte 0b00010111
.byte 0b00010111
.byte 0b00010111
.byte 0b00010111
.byte 0b00010111
.byte 0b00010111
.byte 0b00010111
.byte 0b00010111
.byte 0b00010111
.byte 0b00011001
.byte 0b00011001
.byte 0b00011001
.byte 0b00011001
.byte 0b00011001
.byte 0b00011001
.byte 0b00011001
.byte 0b00011001
.byte 0b00011001
.byte 0b00011001
.byte 0b00011001
.byte 0b00011001
.byte 0b00011001
.byte 0b00011001
.byte 0b00011001
.byte 0b00011001
.byte 0b00011111
.byte 0b00011111
.byte 0b00011111
.byte 0b00011111
.byte 0b00011111
.byte 0b00011111
.byte 0b00011111
.byte 0b00011111
.byte 0b00011111
.byte 0b00011111
.byte 0b00011111
.byte 0b00011111
.byte 0b00011111
.byte 0b00011111
.byte 0b00011111
.byte 0b00011111
.byte 0b01110001
.byte 0b01110001
.byte 0b01110001
.byte 0b01110001
.byte 0b01110001
.byte 0b01110001
.byte 0b01110001
.byte 0b01110001
.byte 0b01110001
.byte 0b01110001
.byte 0b01110001
.byte 0b01110001
.byte 0b01110001
.byte 0b01110001
.byte 0b01110001
.byte 0b01110001
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01111001
.byte 0b01111001
.byte 0b01111001
.byte 0b01111001
.byte 0b01111001
.byte 0b01111001
.byte 0b01111001
.byte 0b01111001
.byte 0b01111001
.byte 0b01111001
.byte 0b01111001
.byte 0b01111001
.byte 0b01111001
.byte 0b01111001
.byte 0b01111001
.byte 0b01111001
.byte 0b01111111
.byte 0b01111111
.byte 0b01111111
.byte 0b01111111
.byte 0b01111111
.byte 0b01111111
.byte 0b01111111
.byte 0b01111111
.byte 0b01111111
.byte 0b01111111
.byte 0b01111111
.byte 0b01111111
.byte 0b01111111
.byte 0b01111111
.byte 0b01111111
.byte 0b01111111
.byte 0b10010001
.byte 0b10010001
.byte 0b10010001
.byte 0b10010001
.byte 0b10010001
.byte 0b10010001
.byte 0b10010001
.byte 0b10010001
.byte 0b10010001
.byte 0b10010001
.byte 0b10010001
.byte 0b10010001
.byte 0b10010001
.byte 0b10010001
.byte 0b10010001
.byte 0b10010001
.byte 0b10010111
.byte 0b10010111
.byte 0b10010111
.byte 0b10010111
.byte 0b10010111
.byte 0b10010111
.byte 0b10010111
.byte 0b10010111
.byte 0b10010111
.byte 0b10010111
.byte 0b10010111
.byte 0b10010111
.byte 0b10010111
.byte 0b10010111
.byte 0b10010111
.byte 0b10010111
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011111
.byte 0b10011111
.byte 0b10011111
.byte 0b10011111
.byte 0b10011111
.byte 0b10011111
.byte 0b10011111
.byte 0b10011111
.byte 0b10011111
.byte 0b10011111
.byte 0b10011111
.byte 0b10011111
.byte 0b10011111
.byte 0b10011111
.byte 0b10011111
.byte 0b10011111
.byte 0b11110001
.byte 0b11110001
.byte 0b11110001
.byte 0b11110001
.byte 0b11110001
.byte 0b11110001
.byte 0b11110001
.byte 0b11110001
.byte 0b11110001
.byte 0b11110001
.byte 0b11110001
.byte 0b11110001
.byte 0b11110001
.byte 0b11110001
.byte 0b11110001
.byte 0b11110001
.byte 0b11110111
.byte 0b11110111
.byte 0b11110111
.byte 0b11110111
.byte 0b11110111
.byte 0b11110111
.byte 0b11110111
.byte 0b11110111
.byte 0b11110111
.byte 0b11110111
.byte 0b11110111
.byte 0b11110111
.byte 0b11110111
.byte 0b11110111
.byte 0b11110111
.byte 0b11110111
.byte 0b11111001
.byte 0b11111001
.byte 0b11111001
.byte 0b11111001
.byte 0b11111001
.byte 0b11111001
.byte 0b11111001
.byte 0b11111001
.byte 0b11111001
.byte 0b11111001
.byte 0b11111001
.byte 0b11111001
.byte 0b11111001
.byte 0b11111001
.byte 0b11111001
.byte 0b11111001
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100011
.byte 0b00100011
.byte 0b00100011
.byte 0b00100011
.byte 0b00100011
.byte 0b00100011
.byte 0b00100011
.byte 0b00100011
.byte 0b00100011
.byte 0b00100011
.byte 0b00100011
.byte 0b00100011
.byte 0b00100011
.byte 0b00100011
.byte 0b00100011
.byte 0b00100011
.byte 0b00100110
.byte 0b00100110
.byte 0b00100110
.byte 0b00100110
.byte 0b00100110
.byte 0b00100110
.byte 0b00100110
.byte 0b00100110
.byte 0b00100110
.byte 0b00100110
.byte 0b00100110
.byte 0b00100110
.byte 0b00100110
.byte 0b00100110
.byte 0b00100110
.byte 0b00100110
.byte 0b00100111
.byte 0b00100111
.byte 0b00100111
.byte 0b00100111
.byte 0b00100111
.byte 0b00100111
.byte 0b00100111
.byte 0b00100111
.byte 0b00100111
.byte 0b00100111
.byte 0b00100111
.byte 0b00100111
.byte 0b00100111
.byte 0b00100111
.byte 0b00100111
.byte 0b00100111
.byte 0b00110010
.byte 0b00110010
.byte 0b00110010
.byte 0b00110010
.byte 0b00110010
.byte 0b00110010
.byte 0b00110010
.byte 0b00110010
.byte 0b00110010
.byte 0b00110010
.byte 0b00110010
.byte 0b00110010
.byte 0b00110010
.byte 0b00110010
.byte 0b00110010
.byte 0b00110010
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110110
.byte 0b00110110
.byte 0b00110110
.byte 0b00110110
.byte 0b00110110
.byte 0b00110110
.byte 0b00110110
.byte 0b00110110
.byte 0b00110110
.byte 0b00110110
.byte 0b00110110
.byte 0b00110110
.byte 0b00110110
.byte 0b00110110
.byte 0b00110110
.byte 0b00110110
.byte 0b00110111
.byte 0b00110111
.byte 0b00110111
.byte 0b00110111
.byte 0b00110111
.byte 0b00110111
.byte 0b00110111
.byte 0b00110111
.byte 0b00110111
.byte 0b00110111
.byte 0b00110111
.byte 0b00110111
.byte 0b00110111
.byte 0b00110111
.byte 0b00110111
.byte 0b00110111
.byte 0b01100010
.byte 0b01100010
.byte 0b01100010
.byte 0b01100010
.byte 0b01100010
.byte 0b01100010
.byte 0b01100010
.byte 0b01100010
.byte 0b01100010
.byte 0b01100010
.byte 0b01100010
.byte 0b01100010
.byte 0b01100010
.byte 0b01100010
.byte 0b01100010
.byte 0b01100010
.byte 0b01100011
.byte 0b01100011
.byte 0b01100011
.byte 0b01100011
.byte 0b01100011
.byte 0b01100011
.byte 0b01100011
.byte 0b01100011
.byte 0b01100011
.byte 0b01100011
.byte 0b01100011
.byte 0b01100011
.byte 0b01100011
.byte 0b01100011
.byte 0b01100011
.byte 0b01100011
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01100111
.byte 0b01100111
.byte 0b01100111
.byte 0b01100111
.byte 0b01100111
.byte 0b01100111
.byte 0b01100111
.byte 0b01100111
.byte 0b01100111
.byte 0b01100111
.byte 0b01100111
.byte 0b01100111
.byte 0b01100111
.byte 0b01100111
.byte 0b01100111
.byte 0b01100111
.byte 0b01110010
.byte 0b01110010
.byte 0b01110010
.byte 0b01110010
.byte 0b01110010
.byte 0b01110010
.byte 0b01110010
.byte 0b01110010
.byte 0b01110010
.byte 0b01110010
.byte 0b01110010
.byte 0b01110010
.byte 0b01110010
.byte 0b01110010
.byte 0b01110010
.byte 0b01110010
.byte 0b01110011
.byte 0b01110011
.byte 0b01110011
.byte 0b01110011
.byte 0b01110011
.byte 0b01110011
.byte 0b01110011
.byte 0b01110011
.byte 0b01110011
.byte 0b01110011
.byte 0b01110011
.byte 0b01110011
.byte 0b01110011
.byte 0b01110011
.byte 0b01110011
.byte 0b01110011
.byte 0b01110110
.byte 0b01110110
.byte 0b01110110
.byte 0b01110110
.byte 0b01110110
.byte 0b01110110
.byte 0b01110110
.byte 0b01110110
.byte 0b01110110
.byte 0b01110110
.byte 0b01110110
.byte 0b01110110
.byte 0b01110110
.byte 0b01110110
.byte 0b01110110
.byte 0b01110110
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100011
.byte 0b00100011
.byte 0b00100011
.byte 0b00100011
.byte 0b00100011
.byte 0b00100011
.byte 0b00100011
.byte 0b00100011
.byte 0b00100011
.byte 0b00100011
.byte 0b00100011
.byte 0b00100011
.byte 0b00100011
.byte 0b00100011
.byte 0b00100011
.byte 0b00100011
.byte 0b00101010
.byte 0b00101010
.byte 0b00101010
.byte 0b00101010
.byte 0b00101010
.byte 0b00101010
.byte 0b00101010
.byte 0b00101010
.byte 0b00101010
.byte 0b00101010
.byte 0b00101010
.byte 0b00101010
.byte 0b00101010
.byte 0b00101010
.byte 0b00101010
.byte 0b00101010
.byte 0b00101011
.byte 0b00101011
.byte 0b00101011
.byte 0b00101011
.byte 0b00101011
.byte 0b00101011
.byte 0b00101011
.byte 0b00101011
.byte 0b00101011
.byte 0b00101011
.byte 0b00101011
.byte 0b00101011
.byte 0b00101011
.byte 0b00101011
.byte 0b00101011
.byte 0b00101011
.byte 0b00110010
.byte 0b00110010
.byte 0b00110010
.byte 0b00110010
.byte 0b00110010
.byte 0b00110010
.byte 0b00110010
.byte 0b00110010
.byte 0b00110010
.byte 0b00110010
.byte 0b00110010
.byte 0b00110010
.byte 0b00110010
.byte 0b00110010
.byte 0b00110010
.byte 0b00110010
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00111010
.byte 0b00111010
.byte 0b00111010
.byte 0b00111010
.byte 0b00111010
.byte 0b00111010
.byte 0b00111010
.byte 0b00111010
.byte 0b00111010
.byte 0b00111010
.byte 0b00111010
.byte 0b00111010
.byte 0b00111010
.byte 0b00111010
.byte 0b00111010
.byte 0b00111010
.byte 0b00111011
.byte 0b00111011
.byte 0b00111011
.byte 0b00111011
.byte 0b00111011
.byte 0b00111011
.byte 0b00111011
.byte 0b00111011
.byte 0b00111011
.byte 0b00111011
.byte 0b00111011
.byte 0b00111011
.byte 0b00111011
.byte 0b00111011
.byte 0b00111011
.byte 0b00111011
.byte 0b10100010
.byte 0b10100010
.byte 0b10100010
.byte 0b10100010
.byte 0b10100010
.byte 0b10100010
.byte 0b10100010
.byte 0b10100010
.byte 0b10100010
.byte 0b10100010
.byte 0b10100010
.byte 0b10100010
.byte 0b10100010
.byte 0b10100010
.byte 0b10100010
.byte 0b10100010
.byte 0b10100011
.byte 0b10100011
.byte 0b10100011
.byte 0b10100011
.byte 0b10100011
.byte 0b10100011
.byte 0b10100011
.byte 0b10100011
.byte 0b10100011
.byte 0b10100011
.byte 0b10100011
.byte 0b10100011
.byte 0b10100011
.byte 0b10100011
.byte 0b10100011
.byte 0b10100011
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101011
.byte 0b10101011
.byte 0b10101011
.byte 0b10101011
.byte 0b10101011
.byte 0b10101011
.byte 0b10101011
.byte 0b10101011
.byte 0b10101011
.byte 0b10101011
.byte 0b10101011
.byte 0b10101011
.byte 0b10101011
.byte 0b10101011
.byte 0b10101011
.byte 0b10101011
.byte 0b10110010
.byte 0b10110010
.byte 0b10110010
.byte 0b10110010
.byte 0b10110010
.byte 0b10110010
.byte 0b10110010
.byte 0b10110010
.byte 0b10110010
.byte 0b10110010
.byte 0b10110010
.byte 0b10110010
.byte 0b10110010
.byte 0b10110010
.byte 0b10110010
.byte 0b10110010
.byte 0b10110011
.byte 0b10110011
.byte 0b10110011
.byte 0b10110011
.byte 0b10110011
.byte 0b10110011
.byte 0b10110011
.byte 0b10110011
.byte 0b10110011
.byte 0b10110011
.byte 0b10110011
.byte 0b10110011
.byte 0b10110011
.byte 0b10110011
.byte 0b10110011
.byte 0b10110011
.byte 0b10111010
.byte 0b10111010
.byte 0b10111010
.byte 0b10111010
.byte 0b10111010
.byte 0b10111010
.byte 0b10111010
.byte 0b10111010
.byte 0b10111010
.byte 0b10111010
.byte 0b10111010
.byte 0b10111010
.byte 0b10111010
.byte 0b10111010
.byte 0b10111010
.byte 0b10111010
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100110
.byte 0b00100110
.byte 0b00100110
.byte 0b00100110
.byte 0b00100110
.byte 0b00100110
.byte 0b00100110
.byte 0b00100110
.byte 0b00100110
.byte 0b00100110
.byte 0b00100110
.byte 0b00100110
.byte 0b00100110
.byte 0b00100110
.byte 0b00100110
.byte 0b00100110
.byte 0b00101010
.byte 0b00101010
.byte 0b00101010
.byte 0b00101010
.byte 0b00101010
.byte 0b00101010
.byte 0b00101010
.byte 0b00101010
.byte 0b00101010
.byte 0b00101010
.byte 0b00101010
.byte 0b00101010
.byte 0b00101010
.byte 0b00101010
.byte 0b00101010
.byte 0b00101010
.byte 0b00101110
.byte 0b00101110
.byte 0b00101110
.byte 0b00101110
.byte 0b00101110
.byte 0b00101110
.byte 0b00101110
.byte 0b00101110
.byte 0b00101110
.byte 0b00101110
.byte 0b00101110
.byte 0b00101110
.byte 0b00101110
.byte 0b00101110
.byte 0b00101110
.byte 0b00101110
.byte 0b01100010
.byte 0b01100010
.byte 0b01100010
.byte 0b01100010
.byte 0b01100010
.byte 0b01100010
.byte 0b01100010
.byte 0b01100010
.byte 0b01100010
.byte 0b01100010
.byte 0b01100010
.byte 0b01100010
.byte 0b01100010
.byte 0b01100010
.byte 0b01100010
.byte 0b01100010
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01101010
.byte 0b01101010
.byte 0b01101010
.byte 0b01101010
.byte 0b01101010
.byte 0b01101010
.byte 0b01101010
.byte 0b01101010
.byte 0b01101010
.byte 0b01101010
.byte 0b01101010
.byte 0b01101010
.byte 0b01101010
.byte 0b01101010
.byte 0b01101010
.byte 0b01101010
.byte 0b01101110
.byte 0b01101110
.byte 0b01101110
.byte 0b01101110
.byte 0b01101110
.byte 0b01101110
.byte 0b01101110
.byte 0b01101110
.byte 0b01101110
.byte 0b01101110
.byte 0b01101110
.byte 0b01101110
.byte 0b01101110
.byte 0b01101110
.byte 0b01101110
.byte 0b01101110
.byte 0b10100010
.byte 0b10100010
.byte 0b10100010
.byte 0b10100010
.byte 0b10100010
.byte 0b10100010
.byte 0b10100010
.byte 0b10100010
.byte 0b10100010
.byte 0b10100010
.byte 0b10100010
.byte 0b10100010
.byte 0b10100010
.byte 0b10100010
.byte 0b10100010
.byte 0b10100010
.byte 0b10100110
.byte 0b10100110
.byte 0b10100110
.byte 0b10100110
.byte 0b10100110
.byte 0b10100110
.byte 0b10100110
.byte 0b10100110
.byte 0b10100110
.byte 0b10100110
.byte 0b10100110
.byte 0b10100110
.byte 0b10100110
.byte 0b10100110
.byte 0b10100110
.byte 0b10100110
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101110
.byte 0b10101110
.byte 0b10101110
.byte 0b10101110
.byte 0b10101110
.byte 0b10101110
.byte 0b10101110
.byte 0b10101110
.byte 0b10101110
.byte 0b10101110
.byte 0b10101110
.byte 0b10101110
.byte 0b10101110
.byte 0b10101110
.byte 0b10101110
.byte 0b10101110
.byte 0b11100010
.byte 0b11100010
.byte 0b11100010
.byte 0b11100010
.byte 0b11100010
.byte 0b11100010
.byte 0b11100010
.byte 0b11100010
.byte 0b11100010
.byte 0b11100010
.byte 0b11100010
.byte 0b11100010
.byte 0b11100010
.byte 0b11100010
.byte 0b11100010
.byte 0b11100010
.byte 0b11100110
.byte 0b11100110
.byte 0b11100110
.byte 0b11100110
.byte 0b11100110
.byte 0b11100110
.byte 0b11100110
.byte 0b11100110
.byte 0b11100110
.byte 0b11100110
.byte 0b11100110
.byte 0b11100110
.byte 0b11100110
.byte 0b11100110
.byte 0b11100110
.byte 0b11100110
.byte 0b11101010
.byte 0b11101010
.byte 0b11101010
.byte 0b11101010
.byte 0b11101010
.byte 0b11101010
.byte 0b11101010
.byte 0b11101010
.byte 0b11101010
.byte 0b11101010
.byte 0b11101010
.byte 0b11101010
.byte 0b11101010
.byte 0b11101010
.byte 0b11101010
.byte 0b11101010
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100010
.byte 0b00100111
.byte 0b00100111
.byte 0b00100111
.byte 0b00100111
.byte 0b00100111
.byte 0b00100111
.byte 0b00100111
.byte 0b00100111
.byte 0b00100111
.byte 0b00100111
.byte 0b00100111
.byte 0b00100111
.byte 0b00100111
.byte 0b00100111
.byte 0b00100111
.byte 0b00100111
.byte 0b00101010
.byte 0b00101010
.byte 0b00101010
.byte 0b00101010
.byte 0b00101010
.byte 0b00101010
.byte 0b00101010
.byte 0b00101010
.byte 0b00101010
.byte 0b00101010
.byte 0b00101010
.byte 0b00101010
.byte 0b00101010
.byte 0b00101010
.byte 0b00101010
.byte 0b00101010
.byte 0b00101111
.byte 0b00101111
.byte 0b00101111
.byte 0b00101111
.byte 0b00101111
.byte 0b00101111
.byte 0b00101111
.byte 0b00101111
.byte 0b00101111
.byte 0b00101111
.byte 0b00101111
.byte 0b00101111
.byte 0b00101111
.byte 0b00101111
.byte 0b00101111
.byte 0b00101111
.byte 0b01110010
.byte 0b01110010
.byte 0b01110010
.byte 0b01110010
.byte 0b01110010
.byte 0b01110010
.byte 0b01110010
.byte 0b01110010
.byte 0b01110010
.byte 0b01110010
.byte 0b01110010
.byte 0b01110010
.byte 0b01110010
.byte 0b01110010
.byte 0b01110010
.byte 0b01110010
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01111010
.byte 0b01111010
.byte 0b01111010
.byte 0b01111010
.byte 0b01111010
.byte 0b01111010
.byte 0b01111010
.byte 0b01111010
.byte 0b01111010
.byte 0b01111010
.byte 0b01111010
.byte 0b01111010
.byte 0b01111010
.byte 0b01111010
.byte 0b01111010
.byte 0b01111010
.byte 0b01111111
.byte 0b01111111
.byte 0b01111111
.byte 0b01111111
.byte 0b01111111
.byte 0b01111111
.byte 0b01111111
.byte 0b01111111
.byte 0b01111111
.byte 0b01111111
.byte 0b01111111
.byte 0b01111111
.byte 0b01111111
.byte 0b01111111
.byte 0b01111111
.byte 0b01111111
.byte 0b10100010
.byte 0b10100010
.byte 0b10100010
.byte 0b10100010
.byte 0b10100010
.byte 0b10100010
.byte 0b10100010
.byte 0b10100010
.byte 0b10100010
.byte 0b10100010
.byte 0b10100010
.byte 0b10100010
.byte 0b10100010
.byte 0b10100010
.byte 0b10100010
.byte 0b10100010
.byte 0b10100111
.byte 0b10100111
.byte 0b10100111
.byte 0b10100111
.byte 0b10100111
.byte 0b10100111
.byte 0b10100111
.byte 0b10100111
.byte 0b10100111
.byte 0b10100111
.byte 0b10100111
.byte 0b10100111
.byte 0b10100111
.byte 0b10100111
.byte 0b10100111
.byte 0b10100111
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101111
.byte 0b10101111
.byte 0b10101111
.byte 0b10101111
.byte 0b10101111
.byte 0b10101111
.byte 0b10101111
.byte 0b10101111
.byte 0b10101111
.byte 0b10101111
.byte 0b10101111
.byte 0b10101111
.byte 0b10101111
.byte 0b10101111
.byte 0b10101111
.byte 0b10101111
.byte 0b11110010
.byte 0b11110010
.byte 0b11110010
.byte 0b11110010
.byte 0b11110010
.byte 0b11110010
.byte 0b11110010
.byte 0b11110010
.byte 0b11110010
.byte 0b11110010
.byte 0b11110010
.byte 0b11110010
.byte 0b11110010
.byte 0b11110010
.byte 0b11110010
.byte 0b11110010
.byte 0b11110111
.byte 0b11110111
.byte 0b11110111
.byte 0b11110111
.byte 0b11110111
.byte 0b11110111
.byte 0b11110111
.byte 0b11110111
.byte 0b11110111
.byte 0b11110111
.byte 0b11110111
.byte 0b11110111
.byte 0b11110111
.byte 0b11110111
.byte 0b11110111
.byte 0b11110111
.byte 0b11111010
.byte 0b11111010
.byte 0b11111010
.byte 0b11111010
.byte 0b11111010
.byte 0b11111010
.byte 0b11111010
.byte 0b11111010
.byte 0b11111010
.byte 0b11111010
.byte 0b11111010
.byte 0b11111010
.byte 0b11111010
.byte 0b11111010
.byte 0b11111010
.byte 0b11111010
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000101
.byte 0b01000101
.byte 0b01000101
.byte 0b01000101
.byte 0b01000101
.byte 0b01000101
.byte 0b01000101
.byte 0b01000101
.byte 0b01000101
.byte 0b01000101
.byte 0b01000101
.byte 0b01000101
.byte 0b01000101
.byte 0b01000101
.byte 0b01000101
.byte 0b01000101
.byte 0b01000110
.byte 0b01000110
.byte 0b01000110
.byte 0b01000110
.byte 0b01000110
.byte 0b01000110
.byte 0b01000110
.byte 0b01000110
.byte 0b01000110
.byte 0b01000110
.byte 0b01000110
.byte 0b01000110
.byte 0b01000110
.byte 0b01000110
.byte 0b01000110
.byte 0b01000110
.byte 0b01000111
.byte 0b01000111
.byte 0b01000111
.byte 0b01000111
.byte 0b01000111
.byte 0b01000111
.byte 0b01000111
.byte 0b01000111
.byte 0b01000111
.byte 0b01000111
.byte 0b01000111
.byte 0b01000111
.byte 0b01000111
.byte 0b01000111
.byte 0b01000111
.byte 0b01000111
.byte 0b01010100
.byte 0b01010100
.byte 0b01010100
.byte 0b01010100
.byte 0b01010100
.byte 0b01010100
.byte 0b01010100
.byte 0b01010100
.byte 0b01010100
.byte 0b01010100
.byte 0b01010100
.byte 0b01010100
.byte 0b01010100
.byte 0b01010100
.byte 0b01010100
.byte 0b01010100
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010110
.byte 0b01010110
.byte 0b01010110
.byte 0b01010110
.byte 0b01010110
.byte 0b01010110
.byte 0b01010110
.byte 0b01010110
.byte 0b01010110
.byte 0b01010110
.byte 0b01010110
.byte 0b01010110
.byte 0b01010110
.byte 0b01010110
.byte 0b01010110
.byte 0b01010110
.byte 0b01010111
.byte 0b01010111
.byte 0b01010111
.byte 0b01010111
.byte 0b01010111
.byte 0b01010111
.byte 0b01010111
.byte 0b01010111
.byte 0b01010111
.byte 0b01010111
.byte 0b01010111
.byte 0b01010111
.byte 0b01010111
.byte 0b01010111
.byte 0b01010111
.byte 0b01010111
.byte 0b01100100
.byte 0b01100100
.byte 0b01100100
.byte 0b01100100
.byte 0b01100100
.byte 0b01100100
.byte 0b01100100
.byte 0b01100100
.byte 0b01100100
.byte 0b01100100
.byte 0b01100100
.byte 0b01100100
.byte 0b01100100
.byte 0b01100100
.byte 0b01100100
.byte 0b01100100
.byte 0b01100101
.byte 0b01100101
.byte 0b01100101
.byte 0b01100101
.byte 0b01100101
.byte 0b01100101
.byte 0b01100101
.byte 0b01100101
.byte 0b01100101
.byte 0b01100101
.byte 0b01100101
.byte 0b01100101
.byte 0b01100101
.byte 0b01100101
.byte 0b01100101
.byte 0b01100101
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01100111
.byte 0b01100111
.byte 0b01100111
.byte 0b01100111
.byte 0b01100111
.byte 0b01100111
.byte 0b01100111
.byte 0b01100111
.byte 0b01100111
.byte 0b01100111
.byte 0b01100111
.byte 0b01100111
.byte 0b01100111
.byte 0b01100111
.byte 0b01100111
.byte 0b01100111
.byte 0b01110100
.byte 0b01110100
.byte 0b01110100
.byte 0b01110100
.byte 0b01110100
.byte 0b01110100
.byte 0b01110100
.byte 0b01110100
.byte 0b01110100
.byte 0b01110100
.byte 0b01110100
.byte 0b01110100
.byte 0b01110100
.byte 0b01110100
.byte 0b01110100
.byte 0b01110100
.byte 0b01110101
.byte 0b01110101
.byte 0b01110101
.byte 0b01110101
.byte 0b01110101
.byte 0b01110101
.byte 0b01110101
.byte 0b01110101
.byte 0b01110101
.byte 0b01110101
.byte 0b01110101
.byte 0b01110101
.byte 0b01110101
.byte 0b01110101
.byte 0b01110101
.byte 0b01110101
.byte 0b01110110
.byte 0b01110110
.byte 0b01110110
.byte 0b01110110
.byte 0b01110110
.byte 0b01110110
.byte 0b01110110
.byte 0b01110110
.byte 0b01110110
.byte 0b01110110
.byte 0b01110110
.byte 0b01110110
.byte 0b01110110
.byte 0b01110110
.byte 0b01110110
.byte 0b01110110
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000101
.byte 0b01000101
.byte 0b01000101
.byte 0b01000101
.byte 0b01000101
.byte 0b01000101
.byte 0b01000101
.byte 0b01000101
.byte 0b01000101
.byte 0b01000101
.byte 0b01000101
.byte 0b01000101
.byte 0b01000101
.byte 0b01000101
.byte 0b01000101
.byte 0b01000101
.byte 0b01001100
.byte 0b01001100
.byte 0b01001100
.byte 0b01001100
.byte 0b01001100
.byte 0b01001100
.byte 0b01001100
.byte 0b01001100
.byte 0b01001100
.byte 0b01001100
.byte 0b01001100
.byte 0b01001100
.byte 0b01001100
.byte 0b01001100
.byte 0b01001100
.byte 0b01001100
.byte 0b01001101
.byte 0b01001101
.byte 0b01001101
.byte 0b01001101
.byte 0b01001101
.byte 0b01001101
.byte 0b01001101
.byte 0b01001101
.byte 0b01001101
.byte 0b01001101
.byte 0b01001101
.byte 0b01001101
.byte 0b01001101
.byte 0b01001101
.byte 0b01001101
.byte 0b01001101
.byte 0b01010100
.byte 0b01010100
.byte 0b01010100
.byte 0b01010100
.byte 0b01010100
.byte 0b01010100
.byte 0b01010100
.byte 0b01010100
.byte 0b01010100
.byte 0b01010100
.byte 0b01010100
.byte 0b01010100
.byte 0b01010100
.byte 0b01010100
.byte 0b01010100
.byte 0b01010100
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01011100
.byte 0b01011100
.byte 0b01011100
.byte 0b01011100
.byte 0b01011100
.byte 0b01011100
.byte 0b01011100
.byte 0b01011100
.byte 0b01011100
.byte 0b01011100
.byte 0b01011100
.byte 0b01011100
.byte 0b01011100
.byte 0b01011100
.byte 0b01011100
.byte 0b01011100
.byte 0b01011101
.byte 0b01011101
.byte 0b01011101
.byte 0b01011101
.byte 0b01011101
.byte 0b01011101
.byte 0b01011101
.byte 0b01011101
.byte 0b01011101
.byte 0b01011101
.byte 0b01011101
.byte 0b01011101
.byte 0b01011101
.byte 0b01011101
.byte 0b01011101
.byte 0b01011101
.byte 0b11000100
.byte 0b11000100
.byte 0b11000100
.byte 0b11000100
.byte 0b11000100
.byte 0b11000100
.byte 0b11000100
.byte 0b11000100
.byte 0b11000100
.byte 0b11000100
.byte 0b11000100
.byte 0b11000100
.byte 0b11000100
.byte 0b11000100
.byte 0b11000100
.byte 0b11000100
.byte 0b11000101
.byte 0b11000101
.byte 0b11000101
.byte 0b11000101
.byte 0b11000101
.byte 0b11000101
.byte 0b11000101
.byte 0b11000101
.byte 0b11000101
.byte 0b11000101
.byte 0b11000101
.byte 0b11000101
.byte 0b11000101
.byte 0b11000101
.byte 0b11000101
.byte 0b11000101
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001101
.byte 0b11001101
.byte 0b11001101
.byte 0b11001101
.byte 0b11001101
.byte 0b11001101
.byte 0b11001101
.byte 0b11001101
.byte 0b11001101
.byte 0b11001101
.byte 0b11001101
.byte 0b11001101
.byte 0b11001101
.byte 0b11001101
.byte 0b11001101
.byte 0b11001101
.byte 0b11010100
.byte 0b11010100
.byte 0b11010100
.byte 0b11010100
.byte 0b11010100
.byte 0b11010100
.byte 0b11010100
.byte 0b11010100
.byte 0b11010100
.byte 0b11010100
.byte 0b11010100
.byte 0b11010100
.byte 0b11010100
.byte 0b11010100
.byte 0b11010100
.byte 0b11010100
.byte 0b11010101
.byte 0b11010101
.byte 0b11010101
.byte 0b11010101
.byte 0b11010101
.byte 0b11010101
.byte 0b11010101
.byte 0b11010101
.byte 0b11010101
.byte 0b11010101
.byte 0b11010101
.byte 0b11010101
.byte 0b11010101
.byte 0b11010101
.byte 0b11010101
.byte 0b11010101
.byte 0b11011100
.byte 0b11011100
.byte 0b11011100
.byte 0b11011100
.byte 0b11011100
.byte 0b11011100
.byte 0b11011100
.byte 0b11011100
.byte 0b11011100
.byte 0b11011100
.byte 0b11011100
.byte 0b11011100
.byte 0b11011100
.byte 0b11011100
.byte 0b11011100
.byte 0b11011100
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000110
.byte 0b01000110
.byte 0b01000110
.byte 0b01000110
.byte 0b01000110
.byte 0b01000110
.byte 0b01000110
.byte 0b01000110
.byte 0b01000110
.byte 0b01000110
.byte 0b01000110
.byte 0b01000110
.byte 0b01000110
.byte 0b01000110
.byte 0b01000110
.byte 0b01000110
.byte 0b01001100
.byte 0b01001100
.byte 0b01001100
.byte 0b01001100
.byte 0b01001100
.byte 0b01001100
.byte 0b01001100
.byte 0b01001100
.byte 0b01001100
.byte 0b01001100
.byte 0b01001100
.byte 0b01001100
.byte 0b01001100
.byte 0b01001100
.byte 0b01001100
.byte 0b01001100
.byte 0b01001110
.byte 0b01001110
.byte 0b01001110
.byte 0b01001110
.byte 0b01001110
.byte 0b01001110
.byte 0b01001110
.byte 0b01001110
.byte 0b01001110
.byte 0b01001110
.byte 0b01001110
.byte 0b01001110
.byte 0b01001110
.byte 0b01001110
.byte 0b01001110
.byte 0b01001110
.byte 0b01100100
.byte 0b01100100
.byte 0b01100100
.byte 0b01100100
.byte 0b01100100
.byte 0b01100100
.byte 0b01100100
.byte 0b01100100
.byte 0b01100100
.byte 0b01100100
.byte 0b01100100
.byte 0b01100100
.byte 0b01100100
.byte 0b01100100
.byte 0b01100100
.byte 0b01100100
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01101100
.byte 0b01101100
.byte 0b01101100
.byte 0b01101100
.byte 0b01101100
.byte 0b01101100
.byte 0b01101100
.byte 0b01101100
.byte 0b01101100
.byte 0b01101100
.byte 0b01101100
.byte 0b01101100
.byte 0b01101100
.byte 0b01101100
.byte 0b01101100
.byte 0b01101100
.byte 0b01101110
.byte 0b01101110
.byte 0b01101110
.byte 0b01101110
.byte 0b01101110
.byte 0b01101110
.byte 0b01101110
.byte 0b01101110
.byte 0b01101110
.byte 0b01101110
.byte 0b01101110
.byte 0b01101110
.byte 0b01101110
.byte 0b01101110
.byte 0b01101110
.byte 0b01101110
.byte 0b11000100
.byte 0b11000100
.byte 0b11000100
.byte 0b11000100
.byte 0b11000100
.byte 0b11000100
.byte 0b11000100
.byte 0b11000100
.byte 0b11000100
.byte 0b11000100
.byte 0b11000100
.byte 0b11000100
.byte 0b11000100
.byte 0b11000100
.byte 0b11000100
.byte 0b11000100
.byte 0b11000110
.byte 0b11000110
.byte 0b11000110
.byte 0b11000110
.byte 0b11000110
.byte 0b11000110
.byte 0b11000110
.byte 0b11000110
.byte 0b11000110
.byte 0b11000110
.byte 0b11000110
.byte 0b11000110
.byte 0b11000110
.byte 0b11000110
.byte 0b11000110
.byte 0b11000110
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001110
.byte 0b11001110
.byte 0b11001110
.byte 0b11001110
.byte 0b11001110
.byte 0b11001110
.byte 0b11001110
.byte 0b11001110
.byte 0b11001110
.byte 0b11001110
.byte 0b11001110
.byte 0b11001110
.byte 0b11001110
.byte 0b11001110
.byte 0b11001110
.byte 0b11001110
.byte 0b11100100
.byte 0b11100100
.byte 0b11100100
.byte 0b11100100
.byte 0b11100100
.byte 0b11100100
.byte 0b11100100
.byte 0b11100100
.byte 0b11100100
.byte 0b11100100
.byte 0b11100100
.byte 0b11100100
.byte 0b11100100
.byte 0b11100100
.byte 0b11100100
.byte 0b11100100
.byte 0b11100110
.byte 0b11100110
.byte 0b11100110
.byte 0b11100110
.byte 0b11100110
.byte 0b11100110
.byte 0b11100110
.byte 0b11100110
.byte 0b11100110
.byte 0b11100110
.byte 0b11100110
.byte 0b11100110
.byte 0b11100110
.byte 0b11100110
.byte 0b11100110
.byte 0b11100110
.byte 0b11101100
.byte 0b11101100
.byte 0b11101100
.byte 0b11101100
.byte 0b11101100
.byte 0b11101100
.byte 0b11101100
.byte 0b11101100
.byte 0b11101100
.byte 0b11101100
.byte 0b11101100
.byte 0b11101100
.byte 0b11101100
.byte 0b11101100
.byte 0b11101100
.byte 0b11101100
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000100
.byte 0b01000101
.byte 0b01000101
.byte 0b01000101
.byte 0b01000101
.byte 0b01000101
.byte 0b01000101
.byte 0b01000101
.byte 0b01000101
.byte 0b01000101
.byte 0b01000101
.byte 0b01000101
.byte 0b01000101
.byte 0b01000101
.byte 0b01000101
.byte 0b01000101
.byte 0b01000101
.byte 0b01001110
.byte 0b01001110
.byte 0b01001110
.byte 0b01001110
.byte 0b01001110
.byte 0b01001110
.byte 0b01001110
.byte 0b01001110
.byte 0b01001110
.byte 0b01001110
.byte 0b01001110
.byte 0b01001110
.byte 0b01001110
.byte 0b01001110
.byte 0b01001110
.byte 0b01001110
.byte 0b01001111
.byte 0b01001111
.byte 0b01001111
.byte 0b01001111
.byte 0b01001111
.byte 0b01001111
.byte 0b01001111
.byte 0b01001111
.byte 0b01001111
.byte 0b01001111
.byte 0b01001111
.byte 0b01001111
.byte 0b01001111
.byte 0b01001111
.byte 0b01001111
.byte 0b01001111
.byte 0b01010100
.byte 0b01010100
.byte 0b01010100
.byte 0b01010100
.byte 0b01010100
.byte 0b01010100
.byte 0b01010100
.byte 0b01010100
.byte 0b01010100
.byte 0b01010100
.byte 0b01010100
.byte 0b01010100
.byte 0b01010100
.byte 0b01010100
.byte 0b01010100
.byte 0b01010100
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01011110
.byte 0b01011110
.byte 0b01011110
.byte 0b01011110
.byte 0b01011110
.byte 0b01011110
.byte 0b01011110
.byte 0b01011110
.byte 0b01011110
.byte 0b01011110
.byte 0b01011110
.byte 0b01011110
.byte 0b01011110
.byte 0b01011110
.byte 0b01011110
.byte 0b01011110
.byte 0b01011111
.byte 0b01011111
.byte 0b01011111
.byte 0b01011111
.byte 0b01011111
.byte 0b01011111
.byte 0b01011111
.byte 0b01011111
.byte 0b01011111
.byte 0b01011111
.byte 0b01011111
.byte 0b01011111
.byte 0b01011111
.byte 0b01011111
.byte 0b01011111
.byte 0b01011111
.byte 0b11100100
.byte 0b11100100
.byte 0b11100100
.byte 0b11100100
.byte 0b11100100
.byte 0b11100100
.byte 0b11100100
.byte 0b11100100
.byte 0b11100100
.byte 0b11100100
.byte 0b11100100
.byte 0b11100100
.byte 0b11100100
.byte 0b11100100
.byte 0b11100100
.byte 0b11100100
.byte 0b11100101
.byte 0b11100101
.byte 0b11100101
.byte 0b11100101
.byte 0b11100101
.byte 0b11100101
.byte 0b11100101
.byte 0b11100101
.byte 0b11100101
.byte 0b11100101
.byte 0b11100101
.byte 0b11100101
.byte 0b11100101
.byte 0b11100101
.byte 0b11100101
.byte 0b11100101
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101111
.byte 0b11101111
.byte 0b11101111
.byte 0b11101111
.byte 0b11101111
.byte 0b11101111
.byte 0b11101111
.byte 0b11101111
.byte 0b11101111
.byte 0b11101111
.byte 0b11101111
.byte 0b11101111
.byte 0b11101111
.byte 0b11101111
.byte 0b11101111
.byte 0b11101111
.byte 0b11110100
.byte 0b11110100
.byte 0b11110100
.byte 0b11110100
.byte 0b11110100
.byte 0b11110100
.byte 0b11110100
.byte 0b11110100
.byte 0b11110100
.byte 0b11110100
.byte 0b11110100
.byte 0b11110100
.byte 0b11110100
.byte 0b11110100
.byte 0b11110100
.byte 0b11110100
.byte 0b11110101
.byte 0b11110101
.byte 0b11110101
.byte 0b11110101
.byte 0b11110101
.byte 0b11110101
.byte 0b11110101
.byte 0b11110101
.byte 0b11110101
.byte 0b11110101
.byte 0b11110101
.byte 0b11110101
.byte 0b11110101
.byte 0b11110101
.byte 0b11110101
.byte 0b11110101
.byte 0b11111110
.byte 0b11111110
.byte 0b11111110
.byte 0b11111110
.byte 0b11111110
.byte 0b11111110
.byte 0b11111110
.byte 0b11111110
.byte 0b11111110
.byte 0b11111110
.byte 0b11111110
.byte 0b11111110
.byte 0b11111110
.byte 0b11111110
.byte 0b11111110
.byte 0b11111110
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001001
.byte 0b10001001
.byte 0b10001001
.byte 0b10001001
.byte 0b10001001
.byte 0b10001001
.byte 0b10001001
.byte 0b10001001
.byte 0b10001001
.byte 0b10001001
.byte 0b10001001
.byte 0b10001001
.byte 0b10001001
.byte 0b10001001
.byte 0b10001001
.byte 0b10001001
.byte 0b10001010
.byte 0b10001010
.byte 0b10001010
.byte 0b10001010
.byte 0b10001010
.byte 0b10001010
.byte 0b10001010
.byte 0b10001010
.byte 0b10001010
.byte 0b10001010
.byte 0b10001010
.byte 0b10001010
.byte 0b10001010
.byte 0b10001010
.byte 0b10001010
.byte 0b10001010
.byte 0b10001011
.byte 0b10001011
.byte 0b10001011
.byte 0b10001011
.byte 0b10001011
.byte 0b10001011
.byte 0b10001011
.byte 0b10001011
.byte 0b10001011
.byte 0b10001011
.byte 0b10001011
.byte 0b10001011
.byte 0b10001011
.byte 0b10001011
.byte 0b10001011
.byte 0b10001011
.byte 0b10011000
.byte 0b10011000
.byte 0b10011000
.byte 0b10011000
.byte 0b10011000
.byte 0b10011000
.byte 0b10011000
.byte 0b10011000
.byte 0b10011000
.byte 0b10011000
.byte 0b10011000
.byte 0b10011000
.byte 0b10011000
.byte 0b10011000
.byte 0b10011000
.byte 0b10011000
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011010
.byte 0b10011010
.byte 0b10011010
.byte 0b10011010
.byte 0b10011010
.byte 0b10011010
.byte 0b10011010
.byte 0b10011010
.byte 0b10011010
.byte 0b10011010
.byte 0b10011010
.byte 0b10011010
.byte 0b10011010
.byte 0b10011010
.byte 0b10011010
.byte 0b10011010
.byte 0b10011011
.byte 0b10011011
.byte 0b10011011
.byte 0b10011011
.byte 0b10011011
.byte 0b10011011
.byte 0b10011011
.byte 0b10011011
.byte 0b10011011
.byte 0b10011011
.byte 0b10011011
.byte 0b10011011
.byte 0b10011011
.byte 0b10011011
.byte 0b10011011
.byte 0b10011011
.byte 0b10101000
.byte 0b10101000
.byte 0b10101000
.byte 0b10101000
.byte 0b10101000
.byte 0b10101000
.byte 0b10101000
.byte 0b10101000
.byte 0b10101000
.byte 0b10101000
.byte 0b10101000
.byte 0b10101000
.byte 0b10101000
.byte 0b10101000
.byte 0b10101000
.byte 0b10101000
.byte 0b10101001
.byte 0b10101001
.byte 0b10101001
.byte 0b10101001
.byte 0b10101001
.byte 0b10101001
.byte 0b10101001
.byte 0b10101001
.byte 0b10101001
.byte 0b10101001
.byte 0b10101001
.byte 0b10101001
.byte 0b10101001
.byte 0b10101001
.byte 0b10101001
.byte 0b10101001
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101011
.byte 0b10101011
.byte 0b10101011
.byte 0b10101011
.byte 0b10101011
.byte 0b10101011
.byte 0b10101011
.byte 0b10101011
.byte 0b10101011
.byte 0b10101011
.byte 0b10101011
.byte 0b10101011
.byte 0b10101011
.byte 0b10101011
.byte 0b10101011
.byte 0b10101011
.byte 0b10111000
.byte 0b10111000
.byte 0b10111000
.byte 0b10111000
.byte 0b10111000
.byte 0b10111000
.byte 0b10111000
.byte 0b10111000
.byte 0b10111000
.byte 0b10111000
.byte 0b10111000
.byte 0b10111000
.byte 0b10111000
.byte 0b10111000
.byte 0b10111000
.byte 0b10111000
.byte 0b10111001
.byte 0b10111001
.byte 0b10111001
.byte 0b10111001
.byte 0b10111001
.byte 0b10111001
.byte 0b10111001
.byte 0b10111001
.byte 0b10111001
.byte 0b10111001
.byte 0b10111001
.byte 0b10111001
.byte 0b10111001
.byte 0b10111001
.byte 0b10111001
.byte 0b10111001
.byte 0b10111010
.byte 0b10111010
.byte 0b10111010
.byte 0b10111010
.byte 0b10111010
.byte 0b10111010
.byte 0b10111010
.byte 0b10111010
.byte 0b10111010
.byte 0b10111010
.byte 0b10111010
.byte 0b10111010
.byte 0b10111010
.byte 0b10111010
.byte 0b10111010
.byte 0b10111010
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001001
.byte 0b10001001
.byte 0b10001001
.byte 0b10001001
.byte 0b10001001
.byte 0b10001001
.byte 0b10001001
.byte 0b10001001
.byte 0b10001001
.byte 0b10001001
.byte 0b10001001
.byte 0b10001001
.byte 0b10001001
.byte 0b10001001
.byte 0b10001001
.byte 0b10001001
.byte 0b10001100
.byte 0b10001100
.byte 0b10001100
.byte 0b10001100
.byte 0b10001100
.byte 0b10001100
.byte 0b10001100
.byte 0b10001100
.byte 0b10001100
.byte 0b10001100
.byte 0b10001100
.byte 0b10001100
.byte 0b10001100
.byte 0b10001100
.byte 0b10001100
.byte 0b10001100
.byte 0b10001101
.byte 0b10001101
.byte 0b10001101
.byte 0b10001101
.byte 0b10001101
.byte 0b10001101
.byte 0b10001101
.byte 0b10001101
.byte 0b10001101
.byte 0b10001101
.byte 0b10001101
.byte 0b10001101
.byte 0b10001101
.byte 0b10001101
.byte 0b10001101
.byte 0b10001101
.byte 0b10011000
.byte 0b10011000
.byte 0b10011000
.byte 0b10011000
.byte 0b10011000
.byte 0b10011000
.byte 0b10011000
.byte 0b10011000
.byte 0b10011000
.byte 0b10011000
.byte 0b10011000
.byte 0b10011000
.byte 0b10011000
.byte 0b10011000
.byte 0b10011000
.byte 0b10011000
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011100
.byte 0b10011100
.byte 0b10011100
.byte 0b10011100
.byte 0b10011100
.byte 0b10011100
.byte 0b10011100
.byte 0b10011100
.byte 0b10011100
.byte 0b10011100
.byte 0b10011100
.byte 0b10011100
.byte 0b10011100
.byte 0b10011100
.byte 0b10011100
.byte 0b10011100
.byte 0b10011101
.byte 0b10011101
.byte 0b10011101
.byte 0b10011101
.byte 0b10011101
.byte 0b10011101
.byte 0b10011101
.byte 0b10011101
.byte 0b10011101
.byte 0b10011101
.byte 0b10011101
.byte 0b10011101
.byte 0b10011101
.byte 0b10011101
.byte 0b10011101
.byte 0b10011101
.byte 0b11001000
.byte 0b11001000
.byte 0b11001000
.byte 0b11001000
.byte 0b11001000
.byte 0b11001000
.byte 0b11001000
.byte 0b11001000
.byte 0b11001000
.byte 0b11001000
.byte 0b11001000
.byte 0b11001000
.byte 0b11001000
.byte 0b11001000
.byte 0b11001000
.byte 0b11001000
.byte 0b11001001
.byte 0b11001001
.byte 0b11001001
.byte 0b11001001
.byte 0b11001001
.byte 0b11001001
.byte 0b11001001
.byte 0b11001001
.byte 0b11001001
.byte 0b11001001
.byte 0b11001001
.byte 0b11001001
.byte 0b11001001
.byte 0b11001001
.byte 0b11001001
.byte 0b11001001
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001101
.byte 0b11001101
.byte 0b11001101
.byte 0b11001101
.byte 0b11001101
.byte 0b11001101
.byte 0b11001101
.byte 0b11001101
.byte 0b11001101
.byte 0b11001101
.byte 0b11001101
.byte 0b11001101
.byte 0b11001101
.byte 0b11001101
.byte 0b11001101
.byte 0b11001101
.byte 0b11011000
.byte 0b11011000
.byte 0b11011000
.byte 0b11011000
.byte 0b11011000
.byte 0b11011000
.byte 0b11011000
.byte 0b11011000
.byte 0b11011000
.byte 0b11011000
.byte 0b11011000
.byte 0b11011000
.byte 0b11011000
.byte 0b11011000
.byte 0b11011000
.byte 0b11011000
.byte 0b11011001
.byte 0b11011001
.byte 0b11011001
.byte 0b11011001
.byte 0b11011001
.byte 0b11011001
.byte 0b11011001
.byte 0b11011001
.byte 0b11011001
.byte 0b11011001
.byte 0b11011001
.byte 0b11011001
.byte 0b11011001
.byte 0b11011001
.byte 0b11011001
.byte 0b11011001
.byte 0b11011100
.byte 0b11011100
.byte 0b11011100
.byte 0b11011100
.byte 0b11011100
.byte 0b11011100
.byte 0b11011100
.byte 0b11011100
.byte 0b11011100
.byte 0b11011100
.byte 0b11011100
.byte 0b11011100
.byte 0b11011100
.byte 0b11011100
.byte 0b11011100
.byte 0b11011100
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001010
.byte 0b10001010
.byte 0b10001010
.byte 0b10001010
.byte 0b10001010
.byte 0b10001010
.byte 0b10001010
.byte 0b10001010
.byte 0b10001010
.byte 0b10001010
.byte 0b10001010
.byte 0b10001010
.byte 0b10001010
.byte 0b10001010
.byte 0b10001010
.byte 0b10001010
.byte 0b10001100
.byte 0b10001100
.byte 0b10001100
.byte 0b10001100
.byte 0b10001100
.byte 0b10001100
.byte 0b10001100
.byte 0b10001100
.byte 0b10001100
.byte 0b10001100
.byte 0b10001100
.byte 0b10001100
.byte 0b10001100
.byte 0b10001100
.byte 0b10001100
.byte 0b10001100
.byte 0b10001110
.byte 0b10001110
.byte 0b10001110
.byte 0b10001110
.byte 0b10001110
.byte 0b10001110
.byte 0b10001110
.byte 0b10001110
.byte 0b10001110
.byte 0b10001110
.byte 0b10001110
.byte 0b10001110
.byte 0b10001110
.byte 0b10001110
.byte 0b10001110
.byte 0b10001110
.byte 0b10101000
.byte 0b10101000
.byte 0b10101000
.byte 0b10101000
.byte 0b10101000
.byte 0b10101000
.byte 0b10101000
.byte 0b10101000
.byte 0b10101000
.byte 0b10101000
.byte 0b10101000
.byte 0b10101000
.byte 0b10101000
.byte 0b10101000
.byte 0b10101000
.byte 0b10101000
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101100
.byte 0b10101100
.byte 0b10101100
.byte 0b10101100
.byte 0b10101100
.byte 0b10101100
.byte 0b10101100
.byte 0b10101100
.byte 0b10101100
.byte 0b10101100
.byte 0b10101100
.byte 0b10101100
.byte 0b10101100
.byte 0b10101100
.byte 0b10101100
.byte 0b10101100
.byte 0b10101110
.byte 0b10101110
.byte 0b10101110
.byte 0b10101110
.byte 0b10101110
.byte 0b10101110
.byte 0b10101110
.byte 0b10101110
.byte 0b10101110
.byte 0b10101110
.byte 0b10101110
.byte 0b10101110
.byte 0b10101110
.byte 0b10101110
.byte 0b10101110
.byte 0b10101110
.byte 0b11001000
.byte 0b11001000
.byte 0b11001000
.byte 0b11001000
.byte 0b11001000
.byte 0b11001000
.byte 0b11001000
.byte 0b11001000
.byte 0b11001000
.byte 0b11001000
.byte 0b11001000
.byte 0b11001000
.byte 0b11001000
.byte 0b11001000
.byte 0b11001000
.byte 0b11001000
.byte 0b11001010
.byte 0b11001010
.byte 0b11001010
.byte 0b11001010
.byte 0b11001010
.byte 0b11001010
.byte 0b11001010
.byte 0b11001010
.byte 0b11001010
.byte 0b11001010
.byte 0b11001010
.byte 0b11001010
.byte 0b11001010
.byte 0b11001010
.byte 0b11001010
.byte 0b11001010
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001110
.byte 0b11001110
.byte 0b11001110
.byte 0b11001110
.byte 0b11001110
.byte 0b11001110
.byte 0b11001110
.byte 0b11001110
.byte 0b11001110
.byte 0b11001110
.byte 0b11001110
.byte 0b11001110
.byte 0b11001110
.byte 0b11001110
.byte 0b11001110
.byte 0b11001110
.byte 0b11101000
.byte 0b11101000
.byte 0b11101000
.byte 0b11101000
.byte 0b11101000
.byte 0b11101000
.byte 0b11101000
.byte 0b11101000
.byte 0b11101000
.byte 0b11101000
.byte 0b11101000
.byte 0b11101000
.byte 0b11101000
.byte 0b11101000
.byte 0b11101000
.byte 0b11101000
.byte 0b11101010
.byte 0b11101010
.byte 0b11101010
.byte 0b11101010
.byte 0b11101010
.byte 0b11101010
.byte 0b11101010
.byte 0b11101010
.byte 0b11101010
.byte 0b11101010
.byte 0b11101010
.byte 0b11101010
.byte 0b11101010
.byte 0b11101010
.byte 0b11101010
.byte 0b11101010
.byte 0b11101100
.byte 0b11101100
.byte 0b11101100
.byte 0b11101100
.byte 0b11101100
.byte 0b11101100
.byte 0b11101100
.byte 0b11101100
.byte 0b11101100
.byte 0b11101100
.byte 0b11101100
.byte 0b11101100
.byte 0b11101100
.byte 0b11101100
.byte 0b11101100
.byte 0b11101100
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001000
.byte 0b10001011
.byte 0b10001011
.byte 0b10001011
.byte 0b10001011
.byte 0b10001011
.byte 0b10001011
.byte 0b10001011
.byte 0b10001011
.byte 0b10001011
.byte 0b10001011
.byte 0b10001011
.byte 0b10001011
.byte 0b10001011
.byte 0b10001011
.byte 0b10001011
.byte 0b10001011
.byte 0b10001100
.byte 0b10001100
.byte 0b10001100
.byte 0b10001100
.byte 0b10001100
.byte 0b10001100
.byte 0b10001100
.byte 0b10001100
.byte 0b10001100
.byte 0b10001100
.byte 0b10001100
.byte 0b10001100
.byte 0b10001100
.byte 0b10001100
.byte 0b10001100
.byte 0b10001100
.byte 0b10001111
.byte 0b10001111
.byte 0b10001111
.byte 0b10001111
.byte 0b10001111
.byte 0b10001111
.byte 0b10001111
.byte 0b10001111
.byte 0b10001111
.byte 0b10001111
.byte 0b10001111
.byte 0b10001111
.byte 0b10001111
.byte 0b10001111
.byte 0b10001111
.byte 0b10001111
.byte 0b10111000
.byte 0b10111000
.byte 0b10111000
.byte 0b10111000
.byte 0b10111000
.byte 0b10111000
.byte 0b10111000
.byte 0b10111000
.byte 0b10111000
.byte 0b10111000
.byte 0b10111000
.byte 0b10111000
.byte 0b10111000
.byte 0b10111000
.byte 0b10111000
.byte 0b10111000
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111100
.byte 0b10111100
.byte 0b10111100
.byte 0b10111100
.byte 0b10111100
.byte 0b10111100
.byte 0b10111100
.byte 0b10111100
.byte 0b10111100
.byte 0b10111100
.byte 0b10111100
.byte 0b10111100
.byte 0b10111100
.byte 0b10111100
.byte 0b10111100
.byte 0b10111100
.byte 0b10111111
.byte 0b10111111
.byte 0b10111111
.byte 0b10111111
.byte 0b10111111
.byte 0b10111111
.byte 0b10111111
.byte 0b10111111
.byte 0b10111111
.byte 0b10111111
.byte 0b10111111
.byte 0b10111111
.byte 0b10111111
.byte 0b10111111
.byte 0b10111111
.byte 0b10111111
.byte 0b11001000
.byte 0b11001000
.byte 0b11001000
.byte 0b11001000
.byte 0b11001000
.byte 0b11001000
.byte 0b11001000
.byte 0b11001000
.byte 0b11001000
.byte 0b11001000
.byte 0b11001000
.byte 0b11001000
.byte 0b11001000
.byte 0b11001000
.byte 0b11001000
.byte 0b11001000
.byte 0b11001011
.byte 0b11001011
.byte 0b11001011
.byte 0b11001011
.byte 0b11001011
.byte 0b11001011
.byte 0b11001011
.byte 0b11001011
.byte 0b11001011
.byte 0b11001011
.byte 0b11001011
.byte 0b11001011
.byte 0b11001011
.byte 0b11001011
.byte 0b11001011
.byte 0b11001011
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001111
.byte 0b11001111
.byte 0b11001111
.byte 0b11001111
.byte 0b11001111
.byte 0b11001111
.byte 0b11001111
.byte 0b11001111
.byte 0b11001111
.byte 0b11001111
.byte 0b11001111
.byte 0b11001111
.byte 0b11001111
.byte 0b11001111
.byte 0b11001111
.byte 0b11001111
.byte 0b11111000
.byte 0b11111000
.byte 0b11111000
.byte 0b11111000
.byte 0b11111000
.byte 0b11111000
.byte 0b11111000
.byte 0b11111000
.byte 0b11111000
.byte 0b11111000
.byte 0b11111000
.byte 0b11111000
.byte 0b11111000
.byte 0b11111000
.byte 0b11111000
.byte 0b11111000
.byte 0b11111011
.byte 0b11111011
.byte 0b11111011
.byte 0b11111011
.byte 0b11111011
.byte 0b11111011
.byte 0b11111011
.byte 0b11111011
.byte 0b11111011
.byte 0b11111011
.byte 0b11111011
.byte 0b11111011
.byte 0b11111011
.byte 0b11111011
.byte 0b11111011
.byte 0b11111011
.byte 0b11111100
.byte 0b11111100
.byte 0b11111100
.byte 0b11111100
.byte 0b11111100
.byte 0b11111100
.byte 0b11111100
.byte 0b11111100
.byte 0b11111100
.byte 0b11111100
.byte 0b11111100
.byte 0b11111100
.byte 0b11111100
.byte 0b11111100
.byte 0b11111100
.byte 0b11111100
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110011
.byte 0b00110111
.byte 0b00110111
.byte 0b00110111
.byte 0b00110111
.byte 0b00110111
.byte 0b00110111
.byte 0b00110111
.byte 0b00110111
.byte 0b00110111
.byte 0b00110111
.byte 0b00110111
.byte 0b00110111
.byte 0b00110111
.byte 0b00110111
.byte 0b00110111
.byte 0b00110111
.byte 0b00111011
.byte 0b00111011
.byte 0b00111011
.byte 0b00111011
.byte 0b00111011
.byte 0b00111011
.byte 0b00111011
.byte 0b00111011
.byte 0b00111011
.byte 0b00111011
.byte 0b00111011
.byte 0b00111011
.byte 0b00111011
.byte 0b00111011
.byte 0b00111011
.byte 0b00111011
.byte 0b00111111
.byte 0b00111111
.byte 0b00111111
.byte 0b00111111
.byte 0b00111111
.byte 0b00111111
.byte 0b00111111
.byte 0b00111111
.byte 0b00111111
.byte 0b00111111
.byte 0b00111111
.byte 0b00111111
.byte 0b00111111
.byte 0b00111111
.byte 0b00111111
.byte 0b00111111
.byte 0b01110011
.byte 0b01110011
.byte 0b01110011
.byte 0b01110011
.byte 0b01110011
.byte 0b01110011
.byte 0b01110011
.byte 0b01110011
.byte 0b01110011
.byte 0b01110011
.byte 0b01110011
.byte 0b01110011
.byte 0b01110011
.byte 0b01110011
.byte 0b01110011
.byte 0b01110011
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01111011
.byte 0b01111011
.byte 0b01111011
.byte 0b01111011
.byte 0b01111011
.byte 0b01111011
.byte 0b01111011
.byte 0b01111011
.byte 0b01111011
.byte 0b01111011
.byte 0b01111011
.byte 0b01111011
.byte 0b01111011
.byte 0b01111011
.byte 0b01111011
.byte 0b01111011
.byte 0b01111111
.byte 0b01111111
.byte 0b01111111
.byte 0b01111111
.byte 0b01111111
.byte 0b01111111
.byte 0b01111111
.byte 0b01111111
.byte 0b01111111
.byte 0b01111111
.byte 0b01111111
.byte 0b01111111
.byte 0b01111111
.byte 0b01111111
.byte 0b01111111
.byte 0b01111111
.byte 0b10110011
.byte 0b10110011
.byte 0b10110011
.byte 0b10110011
.byte 0b10110011
.byte 0b10110011
.byte 0b10110011
.byte 0b10110011
.byte 0b10110011
.byte 0b10110011
.byte 0b10110011
.byte 0b10110011
.byte 0b10110011
.byte 0b10110011
.byte 0b10110011
.byte 0b10110011
.byte 0b10110111
.byte 0b10110111
.byte 0b10110111
.byte 0b10110111
.byte 0b10110111
.byte 0b10110111
.byte 0b10110111
.byte 0b10110111
.byte 0b10110111
.byte 0b10110111
.byte 0b10110111
.byte 0b10110111
.byte 0b10110111
.byte 0b10110111
.byte 0b10110111
.byte 0b10110111
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111111
.byte 0b10111111
.byte 0b10111111
.byte 0b10111111
.byte 0b10111111
.byte 0b10111111
.byte 0b10111111
.byte 0b10111111
.byte 0b10111111
.byte 0b10111111
.byte 0b10111111
.byte 0b10111111
.byte 0b10111111
.byte 0b10111111
.byte 0b10111111
.byte 0b10111111
.byte 0b11110011
.byte 0b11110011
.byte 0b11110011
.byte 0b11110011
.byte 0b11110011
.byte 0b11110011
.byte 0b11110011
.byte 0b11110011
.byte 0b11110011
.byte 0b11110011
.byte 0b11110011
.byte 0b11110011
.byte 0b11110011
.byte 0b11110011
.byte 0b11110011
.byte 0b11110011
.byte 0b11110111
.byte 0b11110111
.byte 0b11110111
.byte 0b11110111
.byte 0b11110111
.byte 0b11110111
.byte 0b11110111
.byte 0b11110111
.byte 0b11110111
.byte 0b11110111
.byte 0b11110111
.byte 0b11110111
.byte 0b11110111
.byte 0b11110111
.byte 0b11110111
.byte 0b11110111
.byte 0b11111011
.byte 0b11111011
.byte 0b11111011
.byte 0b11111011
.byte 0b11111011
.byte 0b11111011
.byte 0b11111011
.byte 0b11111011
.byte 0b11111011
.byte 0b11111011
.byte 0b11111011
.byte 0b11111011
.byte 0b11111011
.byte 0b11111011
.byte 0b11111011
.byte 0b11111011
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101010
.byte 0b10101011
.byte 0b10101011
.byte 0b10101011
.byte 0b10101011
.byte 0b10101011
.byte 0b10101011
.byte 0b10101011
.byte 0b10101011
.byte 0b10101011
.byte 0b10101011
.byte 0b10101011
.byte 0b10101011
.byte 0b10101011
.byte 0b10101011
.byte 0b10101011
.byte 0b10101011
.byte 0b10101110
.byte 0b10101110
.byte 0b10101110
.byte 0b10101110
.byte 0b10101110
.byte 0b10101110
.byte 0b10101110
.byte 0b10101110
.byte 0b10101110
.byte 0b10101110
.byte 0b10101110
.byte 0b10101110
.byte 0b10101110
.byte 0b10101110
.byte 0b10101110
.byte 0b10101110
.byte 0b10101111
.byte 0b10101111
.byte 0b10101111
.byte 0b10101111
.byte 0b10101111
.byte 0b10101111
.byte 0b10101111
.byte 0b10101111
.byte 0b10101111
.byte 0b10101111
.byte 0b10101111
.byte 0b10101111
.byte 0b10101111
.byte 0b10101111
.byte 0b10101111
.byte 0b10101111
.byte 0b10111010
.byte 0b10111010
.byte 0b10111010
.byte 0b10111010
.byte 0b10111010
.byte 0b10111010
.byte 0b10111010
.byte 0b10111010
.byte 0b10111010
.byte 0b10111010
.byte 0b10111010
.byte 0b10111010
.byte 0b10111010
.byte 0b10111010
.byte 0b10111010
.byte 0b10111010
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111110
.byte 0b10111110
.byte 0b10111110
.byte 0b10111110
.byte 0b10111110
.byte 0b10111110
.byte 0b10111110
.byte 0b10111110
.byte 0b10111110
.byte 0b10111110
.byte 0b10111110
.byte 0b10111110
.byte 0b10111110
.byte 0b10111110
.byte 0b10111110
.byte 0b10111110
.byte 0b10111111
.byte 0b10111111
.byte 0b10111111
.byte 0b10111111
.byte 0b10111111
.byte 0b10111111
.byte 0b10111111
.byte 0b10111111
.byte 0b10111111
.byte 0b10111111
.byte 0b10111111
.byte 0b10111111
.byte 0b10111111
.byte 0b10111111
.byte 0b10111111
.byte 0b10111111
.byte 0b11101010
.byte 0b11101010
.byte 0b11101010
.byte 0b11101010
.byte 0b11101010
.byte 0b11101010
.byte 0b11101010
.byte 0b11101010
.byte 0b11101010
.byte 0b11101010
.byte 0b11101010
.byte 0b11101010
.byte 0b11101010
.byte 0b11101010
.byte 0b11101010
.byte 0b11101010
.byte 0b11101011
.byte 0b11101011
.byte 0b11101011
.byte 0b11101011
.byte 0b11101011
.byte 0b11101011
.byte 0b11101011
.byte 0b11101011
.byte 0b11101011
.byte 0b11101011
.byte 0b11101011
.byte 0b11101011
.byte 0b11101011
.byte 0b11101011
.byte 0b11101011
.byte 0b11101011
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101111
.byte 0b11101111
.byte 0b11101111
.byte 0b11101111
.byte 0b11101111
.byte 0b11101111
.byte 0b11101111
.byte 0b11101111
.byte 0b11101111
.byte 0b11101111
.byte 0b11101111
.byte 0b11101111
.byte 0b11101111
.byte 0b11101111
.byte 0b11101111
.byte 0b11101111
.byte 0b11111010
.byte 0b11111010
.byte 0b11111010
.byte 0b11111010
.byte 0b11111010
.byte 0b11111010
.byte 0b11111010
.byte 0b11111010
.byte 0b11111010
.byte 0b11111010
.byte 0b11111010
.byte 0b11111010
.byte 0b11111010
.byte 0b11111010
.byte 0b11111010
.byte 0b11111010
.byte 0b11111011
.byte 0b11111011
.byte 0b11111011
.byte 0b11111011
.byte 0b11111011
.byte 0b11111011
.byte 0b11111011
.byte 0b11111011
.byte 0b11111011
.byte 0b11111011
.byte 0b11111011
.byte 0b11111011
.byte 0b11111011
.byte 0b11111011
.byte 0b11111011
.byte 0b11111011
.byte 0b11111110
.byte 0b11111110
.byte 0b11111110
.byte 0b11111110
.byte 0b11111110
.byte 0b11111110
.byte 0b11111110
.byte 0b11111110
.byte 0b11111110
.byte 0b11111110
.byte 0b11111110
.byte 0b11111110
.byte 0b11111110
.byte 0b11111110
.byte 0b11111110
.byte 0b11111110
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01100110
.byte 0b01100111
.byte 0b01100111
.byte 0b01100111
.byte 0b01100111
.byte 0b01100111
.byte 0b01100111
.byte 0b01100111
.byte 0b01100111
.byte 0b01100111
.byte 0b01100111
.byte 0b01100111
.byte 0b01100111
.byte 0b01100111
.byte 0b01100111
.byte 0b01100111
.byte 0b01100111
.byte 0b01101110
.byte 0b01101110
.byte 0b01101110
.byte 0b01101110
.byte 0b01101110
.byte 0b01101110
.byte 0b01101110
.byte 0b01101110
.byte 0b01101110
.byte 0b01101110
.byte 0b01101110
.byte 0b01101110
.byte 0b01101110
.byte 0b01101110
.byte 0b01101110
.byte 0b01101110
.byte 0b01101111
.byte 0b01101111
.byte 0b01101111
.byte 0b01101111
.byte 0b01101111
.byte 0b01101111
.byte 0b01101111
.byte 0b01101111
.byte 0b01101111
.byte 0b01101111
.byte 0b01101111
.byte 0b01101111
.byte 0b01101111
.byte 0b01101111
.byte 0b01101111
.byte 0b01101111
.byte 0b01110110
.byte 0b01110110
.byte 0b01110110
.byte 0b01110110
.byte 0b01110110
.byte 0b01110110
.byte 0b01110110
.byte 0b01110110
.byte 0b01110110
.byte 0b01110110
.byte 0b01110110
.byte 0b01110110
.byte 0b01110110
.byte 0b01110110
.byte 0b01110110
.byte 0b01110110
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01111110
.byte 0b01111110
.byte 0b01111110
.byte 0b01111110
.byte 0b01111110
.byte 0b01111110
.byte 0b01111110
.byte 0b01111110
.byte 0b01111110
.byte 0b01111110
.byte 0b01111110
.byte 0b01111110
.byte 0b01111110
.byte 0b01111110
.byte 0b01111110
.byte 0b01111110
.byte 0b01111111
.byte 0b01111111
.byte 0b01111111
.byte 0b01111111
.byte 0b01111111
.byte 0b01111111
.byte 0b01111111
.byte 0b01111111
.byte 0b01111111
.byte 0b01111111
.byte 0b01111111
.byte 0b01111111
.byte 0b01111111
.byte 0b01111111
.byte 0b01111111
.byte 0b01111111
.byte 0b11100110
.byte 0b11100110
.byte 0b11100110
.byte 0b11100110
.byte 0b11100110
.byte 0b11100110
.byte 0b11100110
.byte 0b11100110
.byte 0b11100110
.byte 0b11100110
.byte 0b11100110
.byte 0b11100110
.byte 0b11100110
.byte 0b11100110
.byte 0b11100110
.byte 0b11100110
.byte 0b11100111
.byte 0b11100111
.byte 0b11100111
.byte 0b11100111
.byte 0b11100111
.byte 0b11100111
.byte 0b11100111
.byte 0b11100111
.byte 0b11100111
.byte 0b11100111
.byte 0b11100111
.byte 0b11100111
.byte 0b11100111
.byte 0b11100111
.byte 0b11100111
.byte 0b11100111
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101111
.byte 0b11101111
.byte 0b11101111
.byte 0b11101111
.byte 0b11101111
.byte 0b11101111
.byte 0b11101111
.byte 0b11101111
.byte 0b11101111
.byte 0b11101111
.byte 0b11101111
.byte 0b11101111
.byte 0b11101111
.byte 0b11101111
.byte 0b11101111
.byte 0b11101111
.byte 0b11110110
.byte 0b11110110
.byte 0b11110110
.byte 0b11110110
.byte 0b11110110
.byte 0b11110110
.byte 0b11110110
.byte 0b11110110
.byte 0b11110110
.byte 0b11110110
.byte 0b11110110
.byte 0b11110110
.byte 0b11110110
.byte 0b11110110
.byte 0b11110110
.byte 0b11110110
.byte 0b11110111
.byte 0b11110111
.byte 0b11110111
.byte 0b11110111
.byte 0b11110111
.byte 0b11110111
.byte 0b11110111
.byte 0b11110111
.byte 0b11110111
.byte 0b11110111
.byte 0b11110111
.byte 0b11110111
.byte 0b11110111
.byte 0b11110111
.byte 0b11110111
.byte 0b11110111
.byte 0b11111110
.byte 0b11111110
.byte 0b11111110
.byte 0b11111110
.byte 0b11111110
.byte 0b11111110
.byte 0b11111110
.byte 0b11111110
.byte 0b11111110
.byte 0b11111110
.byte 0b11111110
.byte 0b11111110
.byte 0b11111110
.byte 0b11111110
.byte 0b11111110
.byte 0b11111110
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011001
.byte 0b10011011
.byte 0b10011011
.byte 0b10011011
.byte 0b10011011
.byte 0b10011011
.byte 0b10011011
.byte 0b10011011
.byte 0b10011011
.byte 0b10011011
.byte 0b10011011
.byte 0b10011011
.byte 0b10011011
.byte 0b10011011
.byte 0b10011011
.byte 0b10011011
.byte 0b10011011
.byte 0b10011101
.byte 0b10011101
.byte 0b10011101
.byte 0b10011101
.byte 0b10011101
.byte 0b10011101
.byte 0b10011101
.byte 0b10011101
.byte 0b10011101
.byte 0b10011101
.byte 0b10011101
.byte 0b10011101
.byte 0b10011101
.byte 0b10011101
.byte 0b10011101
.byte 0b10011101
.byte 0b10011111
.byte 0b10011111
.byte 0b10011111
.byte 0b10011111
.byte 0b10011111
.byte 0b10011111
.byte 0b10011111
.byte 0b10011111
.byte 0b10011111
.byte 0b10011111
.byte 0b10011111
.byte 0b10011111
.byte 0b10011111
.byte 0b10011111
.byte 0b10011111
.byte 0b10011111
.byte 0b10111001
.byte 0b10111001
.byte 0b10111001
.byte 0b10111001
.byte 0b10111001
.byte 0b10111001
.byte 0b10111001
.byte 0b10111001
.byte 0b10111001
.byte 0b10111001
.byte 0b10111001
.byte 0b10111001
.byte 0b10111001
.byte 0b10111001
.byte 0b10111001
.byte 0b10111001
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111011
.byte 0b10111101
.byte 0b10111101
.byte 0b10111101
.byte 0b10111101
.byte 0b10111101
.byte 0b10111101
.byte 0b10111101
.byte 0b10111101
.byte 0b10111101
.byte 0b10111101
.byte 0b10111101
.byte 0b10111101
.byte 0b10111101
.byte 0b10111101
.byte 0b10111101
.byte 0b10111101
.byte 0b10111111
.byte 0b10111111
.byte 0b10111111
.byte 0b10111111
.byte 0b10111111
.byte 0b10111111
.byte 0b10111111
.byte 0b10111111
.byte 0b10111111
.byte 0b10111111
.byte 0b10111111
.byte 0b10111111
.byte 0b10111111
.byte 0b10111111
.byte 0b10111111
.byte 0b10111111
.byte 0b11011001
.byte 0b11011001
.byte 0b11011001
.byte 0b11011001
.byte 0b11011001
.byte 0b11011001
.byte 0b11011001
.byte 0b11011001
.byte 0b11011001
.byte 0b11011001
.byte 0b11011001
.byte 0b11011001
.byte 0b11011001
.byte 0b11011001
.byte 0b11011001
.byte 0b11011001
.byte 0b11011011
.byte 0b11011011
.byte 0b11011011
.byte 0b11011011
.byte 0b11011011
.byte 0b11011011
.byte 0b11011011
.byte 0b11011011
.byte 0b11011011
.byte 0b11011011
.byte 0b11011011
.byte 0b11011011
.byte 0b11011011
.byte 0b11011011
.byte 0b11011011
.byte 0b11011011
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b11011111
.byte 0b11011111
.byte 0b11011111
.byte 0b11011111
.byte 0b11011111
.byte 0b11011111
.byte 0b11011111
.byte 0b11011111
.byte 0b11011111
.byte 0b11011111
.byte 0b11011111
.byte 0b11011111
.byte 0b11011111
.byte 0b11011111
.byte 0b11011111
.byte 0b11011111
.byte 0b11111001
.byte 0b11111001
.byte 0b11111001
.byte 0b11111001
.byte 0b11111001
.byte 0b11111001
.byte 0b11111001
.byte 0b11111001
.byte 0b11111001
.byte 0b11111001
.byte 0b11111001
.byte 0b11111001
.byte 0b11111001
.byte 0b11111001
.byte 0b11111001
.byte 0b11111001
.byte 0b11111011
.byte 0b11111011
.byte 0b11111011
.byte 0b11111011
.byte 0b11111011
.byte 0b11111011
.byte 0b11111011
.byte 0b11111011
.byte 0b11111011
.byte 0b11111011
.byte 0b11111011
.byte 0b11111011
.byte 0b11111011
.byte 0b11111011
.byte 0b11111011
.byte 0b11111011
.byte 0b11111101
.byte 0b11111101
.byte 0b11111101
.byte 0b11111101
.byte 0b11111101
.byte 0b11111101
.byte 0b11111101
.byte 0b11111101
.byte 0b11111101
.byte 0b11111101
.byte 0b11111101
.byte 0b11111101
.byte 0b11111101
.byte 0b11111101
.byte 0b11111101
.byte 0b11111101
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010101
.byte 0b01010111
.byte 0b01010111
.byte 0b01010111
.byte 0b01010111
.byte 0b01010111
.byte 0b01010111
.byte 0b01010111
.byte 0b01010111
.byte 0b01010111
.byte 0b01010111
.byte 0b01010111
.byte 0b01010111
.byte 0b01010111
.byte 0b01010111
.byte 0b01010111
.byte 0b01010111
.byte 0b01011101
.byte 0b01011101
.byte 0b01011101
.byte 0b01011101
.byte 0b01011101
.byte 0b01011101
.byte 0b01011101
.byte 0b01011101
.byte 0b01011101
.byte 0b01011101
.byte 0b01011101
.byte 0b01011101
.byte 0b01011101
.byte 0b01011101
.byte 0b01011101
.byte 0b01011101
.byte 0b01011111
.byte 0b01011111
.byte 0b01011111
.byte 0b01011111
.byte 0b01011111
.byte 0b01011111
.byte 0b01011111
.byte 0b01011111
.byte 0b01011111
.byte 0b01011111
.byte 0b01011111
.byte 0b01011111
.byte 0b01011111
.byte 0b01011111
.byte 0b01011111
.byte 0b01011111
.byte 0b01110101
.byte 0b01110101
.byte 0b01110101
.byte 0b01110101
.byte 0b01110101
.byte 0b01110101
.byte 0b01110101
.byte 0b01110101
.byte 0b01110101
.byte 0b01110101
.byte 0b01110101
.byte 0b01110101
.byte 0b01110101
.byte 0b01110101
.byte 0b01110101
.byte 0b01110101
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01110111
.byte 0b01111101
.byte 0b01111101
.byte 0b01111101
.byte 0b01111101
.byte 0b01111101
.byte 0b01111101
.byte 0b01111101
.byte 0b01111101
.byte 0b01111101
.byte 0b01111101
.byte 0b01111101
.byte 0b01111101
.byte 0b01111101
.byte 0b01111101
.byte 0b01111101
.byte 0b01111101
.byte 0b01111111
.byte 0b01111111
.byte 0b01111111
.byte 0b01111111
.byte 0b01111111
.byte 0b01111111
.byte 0b01111111
.byte 0b01111111
.byte 0b01111111
.byte 0b01111111
.byte 0b01111111
.byte 0b01111111
.byte 0b01111111
.byte 0b01111111
.byte 0b01111111
.byte 0b01111111
.byte 0b11010101
.byte 0b11010101
.byte 0b11010101
.byte 0b11010101
.byte 0b11010101
.byte 0b11010101
.byte 0b11010101
.byte 0b11010101
.byte 0b11010101
.byte 0b11010101
.byte 0b11010101
.byte 0b11010101
.byte 0b11010101
.byte 0b11010101
.byte 0b11010101
.byte 0b11010101
.byte 0b11010111
.byte 0b11010111
.byte 0b11010111
.byte 0b11010111
.byte 0b11010111
.byte 0b11010111
.byte 0b11010111
.byte 0b11010111
.byte 0b11010111
.byte 0b11010111
.byte 0b11010111
.byte 0b11010111
.byte 0b11010111
.byte 0b11010111
.byte 0b11010111
.byte 0b11010111
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b11011111
.byte 0b11011111
.byte 0b11011111
.byte 0b11011111
.byte 0b11011111
.byte 0b11011111
.byte 0b11011111
.byte 0b11011111
.byte 0b11011111
.byte 0b11011111
.byte 0b11011111
.byte 0b11011111
.byte 0b11011111
.byte 0b11011111
.byte 0b11011111
.byte 0b11011111
.byte 0b11110101
.byte 0b11110101
.byte 0b11110101
.byte 0b11110101
.byte 0b11110101
.byte 0b11110101
.byte 0b11110101
.byte 0b11110101
.byte 0b11110101
.byte 0b11110101
.byte 0b11110101
.byte 0b11110101
.byte 0b11110101
.byte 0b11110101
.byte 0b11110101
.byte 0b11110101
.byte 0b11110111
.byte 0b11110111
.byte 0b11110111
.byte 0b11110111
.byte 0b11110111
.byte 0b11110111
.byte 0b11110111
.byte 0b11110111
.byte 0b11110111
.byte 0b11110111
.byte 0b11110111
.byte 0b11110111
.byte 0b11110111
.byte 0b11110111
.byte 0b11110111
.byte 0b11110111
.byte 0b11111101
.byte 0b11111101
.byte 0b11111101
.byte 0b11111101
.byte 0b11111101
.byte 0b11111101
.byte 0b11111101
.byte 0b11111101
.byte 0b11111101
.byte 0b11111101
.byte 0b11111101
.byte 0b11111101
.byte 0b11111101
.byte 0b11111101
.byte 0b11111101
.byte 0b11111101
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001100
.byte 0b11001101
.byte 0b11001101
.byte 0b11001101
.byte 0b11001101
.byte 0b11001101
.byte 0b11001101
.byte 0b11001101
.byte 0b11001101
.byte 0b11001101
.byte 0b11001101
.byte 0b11001101
.byte 0b11001101
.byte 0b11001101
.byte 0b11001101
.byte 0b11001101
.byte 0b11001101
.byte 0b11001110
.byte 0b11001110
.byte 0b11001110
.byte 0b11001110
.byte 0b11001110
.byte 0b11001110
.byte 0b11001110
.byte 0b11001110
.byte 0b11001110
.byte 0b11001110
.byte 0b11001110
.byte 0b11001110
.byte 0b11001110
.byte 0b11001110
.byte 0b11001110
.byte 0b11001110
.byte 0b11001111
.byte 0b11001111
.byte 0b11001111
.byte 0b11001111
.byte 0b11001111
.byte 0b11001111
.byte 0b11001111
.byte 0b11001111
.byte 0b11001111
.byte 0b11001111
.byte 0b11001111
.byte 0b11001111
.byte 0b11001111
.byte 0b11001111
.byte 0b11001111
.byte 0b11001111
.byte 0b11011100
.byte 0b11011100
.byte 0b11011100
.byte 0b11011100
.byte 0b11011100
.byte 0b11011100
.byte 0b11011100
.byte 0b11011100
.byte 0b11011100
.byte 0b11011100
.byte 0b11011100
.byte 0b11011100
.byte 0b11011100
.byte 0b11011100
.byte 0b11011100
.byte 0b11011100
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b11011101
.byte 0b11011110
.byte 0b11011110
.byte 0b11011110
.byte 0b11011110
.byte 0b11011110
.byte 0b11011110
.byte 0b11011110
.byte 0b11011110
.byte 0b11011110
.byte 0b11011110
.byte 0b11011110
.byte 0b11011110
.byte 0b11011110
.byte 0b11011110
.byte 0b11011110
.byte 0b11011110
.byte 0b11011111
.byte 0b11011111
.byte 0b11011111
.byte 0b11011111
.byte 0b11011111
.byte 0b11011111
.byte 0b11011111
.byte 0b11011111
.byte 0b11011111
.byte 0b11011111
.byte 0b11011111
.byte 0b11011111
.byte 0b11011111
.byte 0b11011111
.byte 0b11011111
.byte 0b11011111
.byte 0b11101100
.byte 0b11101100
.byte 0b11101100
.byte 0b11101100
.byte 0b11101100
.byte 0b11101100
.byte 0b11101100
.byte 0b11101100
.byte 0b11101100
.byte 0b11101100
.byte 0b11101100
.byte 0b11101100
.byte 0b11101100
.byte 0b11101100
.byte 0b11101100
.byte 0b11101100
.byte 0b11101101
.byte 0b11101101
.byte 0b11101101
.byte 0b11101101
.byte 0b11101101
.byte 0b11101101
.byte 0b11101101
.byte 0b11101101
.byte 0b11101101
.byte 0b11101101
.byte 0b11101101
.byte 0b11101101
.byte 0b11101101
.byte 0b11101101
.byte 0b11101101
.byte 0b11101101
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101110
.byte 0b11101111
.byte 0b11101111
.byte 0b11101111
.byte 0b11101111
.byte 0b11101111
.byte 0b11101111
.byte 0b11101111
.byte 0b11101111
.byte 0b11101111
.byte 0b11101111
.byte 0b11101111
.byte 0b11101111
.byte 0b11101111
.byte 0b11101111
.byte 0b11101111
.byte 0b11101111
.byte 0b11111100
.byte 0b11111100
.byte 0b11111100
.byte 0b11111100
.byte 0b11111100
.byte 0b11111100
.byte 0b11111100
.byte 0b11111100
.byte 0b11111100
.byte 0b11111100
.byte 0b11111100
.byte 0b11111100
.byte 0b11111100
.byte 0b11111100
.byte 0b11111100
.byte 0b11111100
.byte 0b11111101
.byte 0b11111101
.byte 0b11111101
.byte 0b11111101
.byte 0b11111101
.byte 0b11111101
.byte 0b11111101
.byte 0b11111101
.byte 0b11111101
.byte 0b11111101
.byte 0b11111101
.byte 0b11111101
.byte 0b11111101
.byte 0b11111101
.byte 0b11111101
.byte 0b11111101
.byte 0b11111110
.byte 0b11111110
.byte 0b11111110
.byte 0b11111110
.byte 0b11111110
.byte 0b11111110
.byte 0b11111110
.byte 0b11111110
.byte 0b11111110
.byte 0b11111110
.byte 0b11111110
.byte 0b11111110
.byte 0b11111110
.byte 0b11111110
.byte 0b11111110
.byte 0b11111110
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.byte 0b11111111
.global bitspreadtable_numpatterns
.equ bitspreadtable_numpatterns, 38
|
74hc595/Amethyst
| 3,566
|
assets/crumbquadtable.S
|
; "crumb" is an obscure term for a 2-bit quantity
.section .progmem.assets
.balign 256
.global crumbquadtable
.type crumbquadtable, @object
crumbquadtable:
.rept 64
.byte 0b00000000, 0b01010101, 0b10101010, 0b11111111
.endr
.global crumbmasktable
.type crumbmasktable, @object
crumbmasktable:
.rept 64
.byte 0b11000000, 0b00110000, 0b00001100, 0b00000011
.endr
.global bitmasktable
.type bitmasktable, @object
bitmasktable:
.rept 32
.byte 0b10000000, 0b01000000, 0b00100000, 0b00010000
.byte 0b00001000, 0b00000100, 0b00000010, 0b00000001
.endr
; fragments of horizontal lines, used in 2-bit-per-pixel bitmap modes
; The table is padded out because it's easier to combine 2 nibbles into a byte
; (2 cycles: SWAP+OR) than to combine two crumbs into a nibble (3 cycles: LSL+LSL+OR)
.global lhlin_fragments
.type lhlin_fragments, @object
lhlin_fragments:
; Start bit: 0
; End bit: 0 1 2 3
.byte 0b11000000, 0b11110000, 0b11111100, 0b11111111, 0,0,0,0,0,0,0,0,0,0,0,0
; Start bit: 1
; End bit: 0 1 2 3
.byte 0b11110000, 0b00110000, 0b00111100, 0b00111111, 0,0,0,0,0,0,0,0,0,0,0,0
; Start bit: 2
; End bit: 0 1 2 3
.byte 0b11111100, 0b00111100, 0b00001100, 0b00001111, 0,0,0,0,0,0,0,0,0,0,0,0
; Start bit: 3
; End bit: 0 1 2 3
.byte 0b11111111, 0b00111111, 0b00001111, 0b00000011, 0,0,0,0,0,0,0,0,0,0,0,0
.space 192
; fragments of vertical lines, used i1 2-bit-per-pixel bitmap modes
; The table is padded out because it's easier to combine 2 nibbles into a byte
; (2 cycles: SWAP+OR) than to combine two three-bit quantities into a byte
; (4 cycles: LSL+LSL+LSL+OR)
.global bhlin_fragments
.type bhlin_fragments, @object
bhlin_fragments:
; Start bit: 0
; End bit: 0 1 2 3 4 5 6 7
.byte 0b10000000, 0b11000000, 0b11100000, 0b11110000, 0b11111000, 0b11111100, 0b11111110, 0b11111111, 0,0,0,0,0,0,0,0
; Start bit: 1
; End bit: 0 1 2 3 4 5 6 7
.byte 0b11000000, 0b01000000, 0b01100000, 0b01110000, 0b01111000, 0b01111100, 0b01111110, 0b01111111, 0,0,0,0,0,0,0,0
; Start bit: 2
; End bit: 0 1 2 3 4 5 6 7
.byte 0b11100000, 0b01100000, 0b00100000, 0b00110000, 0b00111000, 0b00111100, 0b00111110, 0b00111111, 0,0,0,0,0,0,0,0
; Start bit: 3
; End bit: 0 1 2 3 4 5 6 7
.byte 0b11110000, 0b01110000, 0b00110000, 0b00010000, 0b00011000, 0b00011100, 0b00011110, 0b00011111, 0,0,0,0,0,0,0,0
; Start bit: 4
; End bit: 0 1 2 3 4 5 6 7
.byte 0b11111000, 0b01111000, 0b00111000, 0b00011000, 0b00001000, 0b00001100, 0b00001110, 0b00001111, 0,0,0,0,0,0,0,0
; Start bit: 5
; End bit: 0 1 2 3 4 5 6 7
.byte 0b11111100, 0b01111100, 0b00111100, 0b00011100, 0b00001100, 0b00000100, 0b00000110, 0b00000111, 0,0,0,0,0,0,0,0
; Start bit: 6
; End bit: 0 1 2 3 4 5 6 7
.byte 0b11111110, 0b01111110, 0b00111110, 0b00011110, 0b00001110, 0b00000110, 0b00000010, 0b00000011, 0,0,0,0,0,0,0,0
; Start bit: 7
; End bit: 0 1 2 3 4 5 6 7
.byte 0b11111111, 0b01111111, 0b00111111, 0b00011111, 0b00001111, 0b00000111, 0b00000011, 0b00000001, 0,0,0,0,0,0,0,0
|
74hc595/Amethyst
| 3,050
|
assets/hsvtable.S
|
.section .progmem.assets
.balign 256
.global hsvtable
.type hsvtable, @object
hsvtable:
.byte 240
.byte 133
.byte 133
.byte 133
.byte 133
.byte 21
.byte 21
.byte 21
.byte 21
.byte 112
.byte 112
.byte 112
.byte 69
.byte 69
.byte 69
.byte 69
.byte 148
.byte 148
.byte 133
.byte 133
.byte 176
.byte 176
.byte 176
.byte 176
.byte 97
.byte 112
.byte 112
.byte 112
.byte 224
.byte 224
.byte 224
.byte 224
.byte 192
.byte 192
.byte 208
.byte 208
.byte 193
.byte 65
.byte 65
.byte 97
.byte 97
.byte 32
.byte 32
.byte 96
.byte 96
.byte 20
.byte 20
.byte 20
.byte 192
.byte 192
.byte 40
.byte 40
.byte 24
.byte 1
.byte 1
.byte 33
.byte 48
.byte 48
.byte 32
.byte 96
.byte 96
.byte 64
.byte 64
.byte 64
.byte 197
.byte 197
.byte 213
.byte 213
.byte 213
.byte 181
.byte 181
.byte 181
.byte 53
.byte 53
.byte 37
.byte 37
.byte 101
.byte 69
.byte 69
.byte 69
.byte 148
.byte 148
.byte 45
.byte 45
.byte 149
.byte 225
.byte 225
.byte 43
.byte 195
.byte 146
.byte 130
.byte 130
.byte 52
.byte 180
.byte 180
.byte 212
.byte 44
.byte 60
.byte 13
.byte 105
.byte 105
.byte 209
.byte 241
.byte 113
.byte 131
.byte 146
.byte 2
.byte 194
.byte 116
.byte 84
.byte 84
.byte 132
.byte 12
.byte 28
.byte 232
.byte 13
.byte 73
.byte 145
.byte 177
.byte 49
.byte 147
.byte 18
.byte 18
.byte 36
.byte 36
.byte 68
.byte 68
.byte 132
.byte 158
.byte 158
.byte 143
.byte 143
.byte 159
.byte 235
.byte 235
.byte 107
.byte 107
.byte 117
.byte 117
.byte 117
.byte 101
.byte 30
.byte 30
.byte 30
.byte 124
.byte 109
.byte 109
.byte 61
.byte 61
.byte 139
.byte 11
.byte 43
.byte 195
.byte 195
.byte 210
.byte 150
.byte 46
.byte 244
.byte 244
.byte 212
.byte 44
.byte 188
.byte 77
.byte 93
.byte 121
.byte 121
.byte 27
.byte 59
.byte 211
.byte 67
.byte 2
.byte 66
.byte 134
.byte 228
.byte 228
.byte 196
.byte 12
.byte 140
.byte 156
.byte 157
.byte 217
.byte 57
.byte 25
.byte 147
.byte 19
.byte 3
.byte 18
.byte 66
.byte 100
.byte 100
.byte 196
.byte 196
.byte 158
.byte 207
.byte 223
.byte 223
.byte 159
.byte 159
.byte 191
.byte 191
.byte 63
.byte 63
.byte 215
.byte 231
.byte 111
.byte 254
.byte 190
.byte 222
.byte 108
.byte 124
.byte 237
.byte 253
.byte 219
.byte 155
.byte 187
.byte 123
.byte 243
.byte 23
.byte 242
.byte 182
.byte 246
.byte 78
.byte 78
.byte 142
.byte 236
.byte 252
.byte 237
.byte 189
.byte 189
.byte 155
.byte 27
.byte 59
.byte 115
.byte 99
.byte 34
.byte 22
.byte 198
.byte 230
.byte 78
.byte 78
.byte 204
.byte 204
.byte 220
.byte 157
.byte 249
.byte 185
.byte 185
.byte 51
.byte 51
.byte 35
.byte 50
.byte 6
.byte 70
.byte 70
.byte 228
.byte 196
|
74hc595/Amethyst
| 69,740
|
assets/test_tileset_8x8.S
|
.text
.balign 256
.global test_tileset_8x8
.type test_tileset_8x8, @object
test_tileset_8x8:
.byte 0b11111111
.byte 0b00000000
.byte 0b11111111
.byte 0b00000000
.byte 0b11111111
.byte 0b00000000
.byte 0b11001100
.byte 0b00000000
.byte 0b00110011
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b01000000
.byte 0b01111111
.byte 0b00000011
.byte 0b00111111
.byte 0b01111111
.byte 0b01000000
.byte 0b11111111
.byte 0b01000000
.byte 0b00000000
.byte 0b00000111
.byte 0b00100000
.byte 0b00000111
.byte 0b01000000
.byte 0b01000000
.byte 0b00001111
.byte 0b01000000
.byte 0b00011111
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b11110000
.byte 0b00000000
.byte 0b11000000
.byte 0b00000000
.byte 0b10000000
.byte 0b00000000
.byte 0b11001100
.byte 0b00000000
.byte 0b00110011
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b01000000
.byte 0b01000000
.byte 0b00011100
.byte 0b00100000
.byte 0b01000000
.byte 0b01000000
.byte 0b10000000
.byte 0b01100000
.byte 0b00111111
.byte 0b00011100
.byte 0b00100000
.byte 0b00001100
.byte 0b01000000
.byte 0b01000000
.byte 0b00011000
.byte 0b01000000
.byte 0b00110000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b11110000
.byte 0b00000000
.byte 0b11000000
.byte 0b00000000
.byte 0b10000000
.byte 0b00000000
.byte 0b11000110
.byte 0b00000000
.byte 0b00110110
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b01111111
.byte 0b01000000
.byte 0b00110000
.byte 0b00100000
.byte 0b01000000
.byte 0b01000000
.byte 0b10000000
.byte 0b00110000
.byte 0b00000010
.byte 0b00110000
.byte 0b01100001
.byte 0b00001000
.byte 0b01000001
.byte 0b01000000
.byte 0b00110000
.byte 0b01111111
.byte 0b00100000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b11110000
.byte 0b00000000
.byte 0b11000000
.byte 0b00000000
.byte 0b10000000
.byte 0b00000000
.byte 0b11000110
.byte 0b00000000
.byte 0b00110110
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00100000
.byte 0b01111111
.byte 0b00100000
.byte 0b00100000
.byte 0b01111111
.byte 0b01111111
.byte 0b10000010
.byte 0b00010000
.byte 0b00000011
.byte 0b00000000
.byte 0b00111110
.byte 0b00001000
.byte 0b01100001
.byte 0b01000001
.byte 0b00100000
.byte 0b01000000
.byte 0b00100000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b11110000
.byte 0b00000000
.byte 0b11000000
.byte 0b00000000
.byte 0b10000000
.byte 0b00000000
.byte 0b11000110
.byte 0b00000000
.byte 0b00110110
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00100000
.byte 0b01000000
.byte 0b00100000
.byte 0b00100000
.byte 0b01000000
.byte 0b01000000
.byte 0b11000011
.byte 0b00011111
.byte 0b00000001
.byte 0b00000000
.byte 0b01000111
.byte 0b00001000
.byte 0b00100001
.byte 0b01100011
.byte 0b00100000
.byte 0b01000000
.byte 0b00100000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b11110000
.byte 0b00000000
.byte 0b11000000
.byte 0b00000000
.byte 0b10000000
.byte 0b00000000
.byte 0b11000110
.byte 0b00000000
.byte 0b00110110
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00010000
.byte 0b01000000
.byte 0b00111000
.byte 0b00100000
.byte 0b01000000
.byte 0b01100000
.byte 0b01100000
.byte 0b00001000
.byte 0b00000001
.byte 0b00000000
.byte 0b01000001
.byte 0b00001000
.byte 0b00110001
.byte 0b00110110
.byte 0b00110000
.byte 0b01110000
.byte 0b00011000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b11110000
.byte 0b00000000
.byte 0b11000000
.byte 0b00000000
.byte 0b10000000
.byte 0b00000000
.byte 0b11001100
.byte 0b00000000
.byte 0b00110011
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00011111
.byte 0b01111111
.byte 0b00001111
.byte 0b00111111
.byte 0b01000000
.byte 0b00111100
.byte 0b00110000
.byte 0b00001000
.byte 0b00111111
.byte 0b00000000
.byte 0b01000000
.byte 0b00001000
.byte 0b00011110
.byte 0b00011100
.byte 0b00011111
.byte 0b00011100
.byte 0b00001111
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b11111111
.byte 0b00000000
.byte 0b11111111
.byte 0b00000000
.byte 0b11111111
.byte 0b00000000
.byte 0b11001100
.byte 0b00000000
.byte 0b00110011
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000001
.byte 0b01111111
.byte 0b00000111
.byte 0b00011111
.byte 0b00001100
.byte 0b00000000
.byte 0b00000000
.byte 0b01000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000111
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b11111111
.byte 0b00000000
.byte 0b11111111
.byte 0b00000000
.byte 0b11111111
.byte 0b00000000
.byte 0b11001100
.byte 0b00000000
.byte 0b00110011
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000100
.byte 0b11111100
.byte 0b11111000
.byte 0b11000000
.byte 0b11111000
.byte 0b00000000
.byte 0b11110000
.byte 0b00010000
.byte 0b00011110
.byte 0b11000000
.byte 0b00010000
.byte 0b11111000
.byte 0b00000010
.byte 0b00000000
.byte 0b11110000
.byte 0b00000000
.byte 0b11111110
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00001111
.byte 0b00000000
.byte 0b00000011
.byte 0b00000000
.byte 0b00000001
.byte 0b00000000
.byte 0b11001100
.byte 0b00000000
.byte 0b00110011
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00001100
.byte 0b00000100
.byte 0b00001100
.byte 0b01111110
.byte 0b00000000
.byte 0b00000000
.byte 0b00010000
.byte 0b00010000
.byte 0b11110000
.byte 0b01110000
.byte 0b01100000
.byte 0b00001100
.byte 0b00000110
.byte 0b01111000
.byte 0b00011100
.byte 0b00000000
.byte 0b00011011
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00001111
.byte 0b00000000
.byte 0b00000011
.byte 0b00000000
.byte 0b00000001
.byte 0b00000000
.byte 0b01101100
.byte 0b00000000
.byte 0b01100111
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b11111000
.byte 0b00000100
.byte 0b00000000
.byte 0b00000010
.byte 0b00000000
.byte 0b00000000
.byte 0b00110000
.byte 0b00010000
.byte 0b00000000
.byte 0b00010000
.byte 0b11000000
.byte 0b00000000
.byte 0b10000100
.byte 0b11001000
.byte 0b00000100
.byte 0b11100000
.byte 0b01110011
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00001111
.byte 0b00000000
.byte 0b00000011
.byte 0b00000000
.byte 0b00000001
.byte 0b00000000
.byte 0b01101100
.byte 0b00000000
.byte 0b01100111
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00011000
.byte 0b11111100
.byte 0b00000000
.byte 0b00000010
.byte 0b00000000
.byte 0b00000000
.byte 0b01100000
.byte 0b00010000
.byte 0b00000000
.byte 0b00001000
.byte 0b00000000
.byte 0b00000000
.byte 0b10000100
.byte 0b10001100
.byte 0b00000100
.byte 0b00011100
.byte 0b00000011
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00001111
.byte 0b00000000
.byte 0b00000011
.byte 0b00000000
.byte 0b00000001
.byte 0b00000000
.byte 0b01101100
.byte 0b00000000
.byte 0b01100111
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00010000
.byte 0b01110000
.byte 0b00000000
.byte 0b00000010
.byte 0b00000000
.byte 0b00000000
.byte 0b11000011
.byte 0b11110000
.byte 0b00000000
.byte 0b00001000
.byte 0b00000000
.byte 0b00000000
.byte 0b01000100
.byte 0b00000100
.byte 0b00011100
.byte 0b00000100
.byte 0b00001110
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00001111
.byte 0b00000000
.byte 0b00000011
.byte 0b00000000
.byte 0b00000001
.byte 0b00000000
.byte 0b01101100
.byte 0b00000000
.byte 0b01100111
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00110000
.byte 0b00010000
.byte 0b00011110
.byte 0b00000110
.byte 0b00000000
.byte 0b00000000
.byte 0b00000110
.byte 0b00011000
.byte 0b00000000
.byte 0b00001000
.byte 0b11000000
.byte 0b00000000
.byte 0b01101100
.byte 0b00000100
.byte 0b00110000
.byte 0b00001100
.byte 0b00111000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00001111
.byte 0b00000000
.byte 0b00000011
.byte 0b00000000
.byte 0b00000001
.byte 0b00000000
.byte 0b11001100
.byte 0b00000000
.byte 0b00110011
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b11100000
.byte 0b11110000
.byte 0b11110000
.byte 0b00011100
.byte 0b01111000
.byte 0b00000110
.byte 0b00011100
.byte 0b00001100
.byte 0b11111100
.byte 0b00001000
.byte 0b01110000
.byte 0b00000000
.byte 0b00111000
.byte 0b00000000
.byte 0b11100000
.byte 0b00011000
.byte 0b11100000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b11111111
.byte 0b00000000
.byte 0b11111111
.byte 0b00000000
.byte 0b11111111
.byte 0b00000000
.byte 0b11001100
.byte 0b00000000
.byte 0b00110011
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b11110000
.byte 0b11000000
.byte 0b11111100
.byte 0b11110000
.byte 0b00000000
.byte 0b00000000
.byte 0b00011000
.byte 0b00011000
.byte 0b00000000
.byte 0b00010000
.byte 0b00000000
.byte 0b00000000
.byte 0b11110000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
.byte 0b00000000
|
74hc595/Amethyst
| 37,241
|
assets/cosine.S
|
.section .progmem.assets
.balign 256
.global cosinetable
.global cosinetable_lsb
.global cosinetable_msb
.type cosinetable, @object
.type cosinetable_lsb, @object
.type cosinetable_msb, @object
cosinetable:
cosinetable_lsb:
.byte lo8( 32767) ; i= 0 theta=0.00000 cos(theta)*32767=32767.000
.byte lo8( 32757) ; i= 1 theta=0.02454 cos(theta)*32767=32757.131
.byte lo8( 32728) ; i= 2 theta=0.04909 cos(theta)*32767=32727.531
.byte lo8( 32678) ; i= 3 theta=0.07363 cos(theta)*32767=32678.216
.byte lo8( 32609) ; i= 4 theta=0.09817 cos(theta)*32767=32609.218
.byte lo8( 32521) ; i= 5 theta=0.12272 cos(theta)*32767=32520.577
.byte lo8( 32412) ; i= 6 theta=0.14726 cos(theta)*32767=32412.347
.byte lo8( 32285) ; i= 7 theta=0.17181 cos(theta)*32767=32284.593
.byte lo8( 32137) ; i= 8 theta=0.19635 cos(theta)*32767=32137.391
.byte lo8( 31971) ; i= 9 theta=0.22089 cos(theta)*32767=31970.832
.byte lo8( 31785) ; i= 10 theta=0.24544 cos(theta)*32767=31785.014
.byte lo8( 31580) ; i= 11 theta=0.26998 cos(theta)*32767=31580.050
.byte lo8( 31356) ; i= 12 theta=0.29452 cos(theta)*32767=31356.064
.byte lo8( 31113) ; i= 13 theta=0.31907 cos(theta)*32767=31113.190
.byte lo8( 30852) ; i= 14 theta=0.34361 cos(theta)*32767=30851.574
.byte lo8( 30571) ; i= 15 theta=0.36816 cos(theta)*32767=30571.375
.byte lo8( 30273) ; i= 16 theta=0.39270 cos(theta)*32767=30272.761
.byte lo8( 29956) ; i= 17 theta=0.41724 cos(theta)*32767=29955.911
.byte lo8( 29621) ; i= 18 theta=0.44179 cos(theta)*32767=29621.017
.byte lo8( 29268) ; i= 19 theta=0.46633 cos(theta)*32767=29268.281
.byte lo8( 28898) ; i= 20 theta=0.49087 cos(theta)*32767=28897.914
.byte lo8( 28510) ; i= 21 theta=0.51542 cos(theta)*32767=28510.140
.byte lo8( 28105) ; i= 22 theta=0.53996 cos(theta)*32767=28105.193
.byte lo8( 27683) ; i= 23 theta=0.56450 cos(theta)*32767=27683.317
.byte lo8( 27245) ; i= 24 theta=0.58905 cos(theta)*32767=27244.765
.byte lo8( 26790) ; i= 25 theta=0.61359 cos(theta)*32767=26789.802
.byte lo8( 26319) ; i= 26 theta=0.63814 cos(theta)*32767=26318.701
.byte lo8( 25832) ; i= 27 theta=0.66268 cos(theta)*32767=25831.747
.byte lo8( 25329) ; i= 28 theta=0.68722 cos(theta)*32767=25329.234
.byte lo8( 24811) ; i= 29 theta=0.71177 cos(theta)*32767=24811.462
.byte lo8( 24279) ; i= 30 theta=0.73631 cos(theta)*32767=24278.746
.byte lo8( 23731) ; i= 31 theta=0.76085 cos(theta)*32767=23731.404
.byte lo8( 23170) ; i= 32 theta=0.78540 cos(theta)*32767=23169.768
.byte lo8( 22594) ; i= 33 theta=0.80994 cos(theta)*32767=22594.175
.byte lo8( 22005) ; i= 34 theta=0.83449 cos(theta)*32767=22004.972
.byte lo8( 21403) ; i= 35 theta=0.85903 cos(theta)*32767=21402.515
.byte lo8( 20787) ; i= 36 theta=0.88357 cos(theta)*32767=20787.165
.byte lo8( 20159) ; i= 37 theta=0.90812 cos(theta)*32767=20159.294
.byte lo8( 19519) ; i= 38 theta=0.93266 cos(theta)*32767=19519.279
.byte lo8( 18868) ; i= 39 theta=0.95720 cos(theta)*32767=18867.507
.byte lo8( 18204) ; i= 40 theta=0.98175 cos(theta)*32767=18204.370
.byte lo8( 17530) ; i= 41 theta=1.00629 cos(theta)*32767=17530.267
.byte lo8( 16846) ; i= 42 theta=1.03084 cos(theta)*32767=16845.605
.byte lo8( 16151) ; i= 43 theta=1.05538 cos(theta)*32767=16150.795
.byte lo8( 15446) ; i= 44 theta=1.07992 cos(theta)*32767=15446.257
.byte lo8( 14732) ; i= 45 theta=1.10447 cos(theta)*32767=14732.414
.byte lo8( 14010) ; i= 46 theta=1.12901 cos(theta)*32767=14009.698
.byte lo8( 13279) ; i= 47 theta=1.15355 cos(theta)*32767=13278.542
.byte lo8( 12539) ; i= 48 theta=1.17810 cos(theta)*32767=12539.388
.byte lo8( 11793) ; i= 49 theta=1.20264 cos(theta)*32767=11792.681
.byte lo8( 11039) ; i= 50 theta=1.22718 cos(theta)*32767=11038.870
.byte lo8( 10278) ; i= 51 theta=1.25173 cos(theta)*32767=10278.410
.byte lo8( 9512) ; i= 52 theta=1.27627 cos(theta)*32767=9511.758
.byte lo8( 8739) ; i= 53 theta=1.30082 cos(theta)*32767=8739.377
.byte lo8( 7962) ; i= 54 theta=1.32536 cos(theta)*32767=7961.732
.byte lo8( 7179) ; i= 55 theta=1.34990 cos(theta)*32767=7179.290
.byte lo8( 6393) ; i= 56 theta=1.37445 cos(theta)*32767=6392.525
.byte lo8( 5602) ; i= 57 theta=1.39899 cos(theta)*32767=5601.908
.byte lo8( 4808) ; i= 58 theta=1.42353 cos(theta)*32767=4807.917
.byte lo8( 4011) ; i= 59 theta=1.44808 cos(theta)*32767=4011.031
.byte lo8( 3212) ; i= 60 theta=1.47262 cos(theta)*32767=3211.728
.byte lo8( 2410) ; i= 61 theta=1.49717 cos(theta)*32767=2410.490
.byte lo8( 1608) ; i= 62 theta=1.52171 cos(theta)*32767=1607.800
.byte lo8( 804) ; i= 63 theta=1.54625 cos(theta)*32767=804.142
.byte lo8( 0) ; i= 64 theta=1.57080 cos(theta)*32767=0.000
.byte lo8( -804) ; i= 65 theta=1.59534 cos(theta)*32767=-804.142
.byte lo8( -1608) ; i= 66 theta=1.61988 cos(theta)*32767=-1607.800
.byte lo8( -2410) ; i= 67 theta=1.64443 cos(theta)*32767=-2410.490
.byte lo8( -3212) ; i= 68 theta=1.66897 cos(theta)*32767=-3211.728
.byte lo8( -4011) ; i= 69 theta=1.69351 cos(theta)*32767=-4011.031
.byte lo8( -4808) ; i= 70 theta=1.71806 cos(theta)*32767=-4807.917
.byte lo8( -5602) ; i= 71 theta=1.74260 cos(theta)*32767=-5601.908
.byte lo8( -6393) ; i= 72 theta=1.76715 cos(theta)*32767=-6392.525
.byte lo8( -7179) ; i= 73 theta=1.79169 cos(theta)*32767=-7179.290
.byte lo8( -7962) ; i= 74 theta=1.81623 cos(theta)*32767=-7961.732
.byte lo8( -8739) ; i= 75 theta=1.84078 cos(theta)*32767=-8739.377
.byte lo8( -9512) ; i= 76 theta=1.86532 cos(theta)*32767=-9511.758
.byte lo8(-10278) ; i= 77 theta=1.88986 cos(theta)*32767=-10278.410
.byte lo8(-11039) ; i= 78 theta=1.91441 cos(theta)*32767=-11038.870
.byte lo8(-11793) ; i= 79 theta=1.93895 cos(theta)*32767=-11792.681
.byte lo8(-12539) ; i= 80 theta=1.96350 cos(theta)*32767=-12539.388
.byte lo8(-13279) ; i= 81 theta=1.98804 cos(theta)*32767=-13278.542
.byte lo8(-14010) ; i= 82 theta=2.01258 cos(theta)*32767=-14009.698
.byte lo8(-14732) ; i= 83 theta=2.03713 cos(theta)*32767=-14732.414
.byte lo8(-15446) ; i= 84 theta=2.06167 cos(theta)*32767=-15446.257
.byte lo8(-16151) ; i= 85 theta=2.08621 cos(theta)*32767=-16150.795
.byte lo8(-16846) ; i= 86 theta=2.11076 cos(theta)*32767=-16845.605
.byte lo8(-17530) ; i= 87 theta=2.13530 cos(theta)*32767=-17530.267
.byte lo8(-18204) ; i= 88 theta=2.15984 cos(theta)*32767=-18204.370
.byte lo8(-18868) ; i= 89 theta=2.18439 cos(theta)*32767=-18867.507
.byte lo8(-19519) ; i= 90 theta=2.20893 cos(theta)*32767=-19519.279
.byte lo8(-20159) ; i= 91 theta=2.23348 cos(theta)*32767=-20159.294
.byte lo8(-20787) ; i= 92 theta=2.25802 cos(theta)*32767=-20787.165
.byte lo8(-21403) ; i= 93 theta=2.28256 cos(theta)*32767=-21402.515
.byte lo8(-22005) ; i= 94 theta=2.30711 cos(theta)*32767=-22004.972
.byte lo8(-22594) ; i= 95 theta=2.33165 cos(theta)*32767=-22594.175
.byte lo8(-23170) ; i= 96 theta=2.35619 cos(theta)*32767=-23169.768
.byte lo8(-23731) ; i= 97 theta=2.38074 cos(theta)*32767=-23731.404
.byte lo8(-24279) ; i= 98 theta=2.40528 cos(theta)*32767=-24278.746
.byte lo8(-24811) ; i= 99 theta=2.42983 cos(theta)*32767=-24811.462
.byte lo8(-25329) ; i=100 theta=2.45437 cos(theta)*32767=-25329.234
.byte lo8(-25832) ; i=101 theta=2.47891 cos(theta)*32767=-25831.747
.byte lo8(-26319) ; i=102 theta=2.50346 cos(theta)*32767=-26318.701
.byte lo8(-26790) ; i=103 theta=2.52800 cos(theta)*32767=-26789.802
.byte lo8(-27245) ; i=104 theta=2.55254 cos(theta)*32767=-27244.765
.byte lo8(-27683) ; i=105 theta=2.57709 cos(theta)*32767=-27683.317
.byte lo8(-28105) ; i=106 theta=2.60163 cos(theta)*32767=-28105.193
.byte lo8(-28510) ; i=107 theta=2.62618 cos(theta)*32767=-28510.140
.byte lo8(-28898) ; i=108 theta=2.65072 cos(theta)*32767=-28897.914
.byte lo8(-29268) ; i=109 theta=2.67526 cos(theta)*32767=-29268.281
.byte lo8(-29621) ; i=110 theta=2.69981 cos(theta)*32767=-29621.017
.byte lo8(-29956) ; i=111 theta=2.72435 cos(theta)*32767=-29955.911
.byte lo8(-30273) ; i=112 theta=2.74889 cos(theta)*32767=-30272.761
.byte lo8(-30571) ; i=113 theta=2.77344 cos(theta)*32767=-30571.375
.byte lo8(-30852) ; i=114 theta=2.79798 cos(theta)*32767=-30851.574
.byte lo8(-31113) ; i=115 theta=2.82252 cos(theta)*32767=-31113.190
.byte lo8(-31356) ; i=116 theta=2.84707 cos(theta)*32767=-31356.064
.byte lo8(-31580) ; i=117 theta=2.87161 cos(theta)*32767=-31580.050
.byte lo8(-31785) ; i=118 theta=2.89616 cos(theta)*32767=-31785.014
.byte lo8(-31971) ; i=119 theta=2.92070 cos(theta)*32767=-31970.832
.byte lo8(-32137) ; i=120 theta=2.94524 cos(theta)*32767=-32137.391
.byte lo8(-32285) ; i=121 theta=2.96979 cos(theta)*32767=-32284.593
.byte lo8(-32412) ; i=122 theta=2.99433 cos(theta)*32767=-32412.347
.byte lo8(-32521) ; i=123 theta=3.01887 cos(theta)*32767=-32520.577
.byte lo8(-32609) ; i=124 theta=3.04342 cos(theta)*32767=-32609.218
.byte lo8(-32678) ; i=125 theta=3.06796 cos(theta)*32767=-32678.216
.byte lo8(-32728) ; i=126 theta=3.09251 cos(theta)*32767=-32727.531
.byte lo8(-32757) ; i=127 theta=3.11705 cos(theta)*32767=-32757.131
.byte lo8(-32767) ; i=128 theta=3.14159 cos(theta)*32767=-32767.000
.byte lo8(-32757) ; i=129 theta=3.16614 cos(theta)*32767=-32757.131
.byte lo8(-32728) ; i=130 theta=3.19068 cos(theta)*32767=-32727.531
.byte lo8(-32678) ; i=131 theta=3.21522 cos(theta)*32767=-32678.216
.byte lo8(-32609) ; i=132 theta=3.23977 cos(theta)*32767=-32609.218
.byte lo8(-32521) ; i=133 theta=3.26431 cos(theta)*32767=-32520.577
.byte lo8(-32412) ; i=134 theta=3.28885 cos(theta)*32767=-32412.347
.byte lo8(-32285) ; i=135 theta=3.31340 cos(theta)*32767=-32284.593
.byte lo8(-32137) ; i=136 theta=3.33794 cos(theta)*32767=-32137.391
.byte lo8(-31971) ; i=137 theta=3.36249 cos(theta)*32767=-31970.832
.byte lo8(-31785) ; i=138 theta=3.38703 cos(theta)*32767=-31785.014
.byte lo8(-31580) ; i=139 theta=3.41157 cos(theta)*32767=-31580.050
.byte lo8(-31356) ; i=140 theta=3.43612 cos(theta)*32767=-31356.064
.byte lo8(-31113) ; i=141 theta=3.46066 cos(theta)*32767=-31113.190
.byte lo8(-30852) ; i=142 theta=3.48520 cos(theta)*32767=-30851.574
.byte lo8(-30571) ; i=143 theta=3.50975 cos(theta)*32767=-30571.375
.byte lo8(-30273) ; i=144 theta=3.53429 cos(theta)*32767=-30272.761
.byte lo8(-29956) ; i=145 theta=3.55884 cos(theta)*32767=-29955.911
.byte lo8(-29621) ; i=146 theta=3.58338 cos(theta)*32767=-29621.017
.byte lo8(-29268) ; i=147 theta=3.60792 cos(theta)*32767=-29268.281
.byte lo8(-28898) ; i=148 theta=3.63247 cos(theta)*32767=-28897.914
.byte lo8(-28510) ; i=149 theta=3.65701 cos(theta)*32767=-28510.140
.byte lo8(-28105) ; i=150 theta=3.68155 cos(theta)*32767=-28105.193
.byte lo8(-27683) ; i=151 theta=3.70610 cos(theta)*32767=-27683.317
.byte lo8(-27245) ; i=152 theta=3.73064 cos(theta)*32767=-27244.765
.byte lo8(-26790) ; i=153 theta=3.75518 cos(theta)*32767=-26789.802
.byte lo8(-26319) ; i=154 theta=3.77973 cos(theta)*32767=-26318.701
.byte lo8(-25832) ; i=155 theta=3.80427 cos(theta)*32767=-25831.747
.byte lo8(-25329) ; i=156 theta=3.82882 cos(theta)*32767=-25329.234
.byte lo8(-24811) ; i=157 theta=3.85336 cos(theta)*32767=-24811.462
.byte lo8(-24279) ; i=158 theta=3.87790 cos(theta)*32767=-24278.746
.byte lo8(-23731) ; i=159 theta=3.90245 cos(theta)*32767=-23731.404
.byte lo8(-23170) ; i=160 theta=3.92699 cos(theta)*32767=-23169.768
.byte lo8(-22594) ; i=161 theta=3.95153 cos(theta)*32767=-22594.175
.byte lo8(-22005) ; i=162 theta=3.97608 cos(theta)*32767=-22004.972
.byte lo8(-21403) ; i=163 theta=4.00062 cos(theta)*32767=-21402.515
.byte lo8(-20787) ; i=164 theta=4.02517 cos(theta)*32767=-20787.165
.byte lo8(-20159) ; i=165 theta=4.04971 cos(theta)*32767=-20159.294
.byte lo8(-19519) ; i=166 theta=4.07425 cos(theta)*32767=-19519.279
.byte lo8(-18868) ; i=167 theta=4.09880 cos(theta)*32767=-18867.507
.byte lo8(-18204) ; i=168 theta=4.12334 cos(theta)*32767=-18204.370
.byte lo8(-17530) ; i=169 theta=4.14788 cos(theta)*32767=-17530.267
.byte lo8(-16846) ; i=170 theta=4.17243 cos(theta)*32767=-16845.605
.byte lo8(-16151) ; i=171 theta=4.19697 cos(theta)*32767=-16150.795
.byte lo8(-15446) ; i=172 theta=4.22152 cos(theta)*32767=-15446.257
.byte lo8(-14732) ; i=173 theta=4.24606 cos(theta)*32767=-14732.414
.byte lo8(-14010) ; i=174 theta=4.27060 cos(theta)*32767=-14009.698
.byte lo8(-13279) ; i=175 theta=4.29515 cos(theta)*32767=-13278.542
.byte lo8(-12539) ; i=176 theta=4.31969 cos(theta)*32767=-12539.388
.byte lo8(-11793) ; i=177 theta=4.34423 cos(theta)*32767=-11792.681
.byte lo8(-11039) ; i=178 theta=4.36878 cos(theta)*32767=-11038.870
.byte lo8(-10278) ; i=179 theta=4.39332 cos(theta)*32767=-10278.410
.byte lo8( -9512) ; i=180 theta=4.41786 cos(theta)*32767=-9511.758
.byte lo8( -8739) ; i=181 theta=4.44241 cos(theta)*32767=-8739.377
.byte lo8( -7962) ; i=182 theta=4.46695 cos(theta)*32767=-7961.732
.byte lo8( -7179) ; i=183 theta=4.49150 cos(theta)*32767=-7179.290
.byte lo8( -6393) ; i=184 theta=4.51604 cos(theta)*32767=-6392.525
.byte lo8( -5602) ; i=185 theta=4.54058 cos(theta)*32767=-5601.908
.byte lo8( -4808) ; i=186 theta=4.56513 cos(theta)*32767=-4807.917
.byte lo8( -4011) ; i=187 theta=4.58967 cos(theta)*32767=-4011.031
.byte lo8( -3212) ; i=188 theta=4.61421 cos(theta)*32767=-3211.728
.byte lo8( -2410) ; i=189 theta=4.63876 cos(theta)*32767=-2410.490
.byte lo8( -1608) ; i=190 theta=4.66330 cos(theta)*32767=-1607.800
.byte lo8( -804) ; i=191 theta=4.68785 cos(theta)*32767=-804.142
.byte lo8( 0) ; i=192 theta=4.71239 cos(theta)*32767=-0.000
.byte lo8( 804) ; i=193 theta=4.73693 cos(theta)*32767=804.142
.byte lo8( 1608) ; i=194 theta=4.76148 cos(theta)*32767=1607.800
.byte lo8( 2410) ; i=195 theta=4.78602 cos(theta)*32767=2410.490
.byte lo8( 3212) ; i=196 theta=4.81056 cos(theta)*32767=3211.728
.byte lo8( 4011) ; i=197 theta=4.83511 cos(theta)*32767=4011.031
.byte lo8( 4808) ; i=198 theta=4.85965 cos(theta)*32767=4807.917
.byte lo8( 5602) ; i=199 theta=4.88419 cos(theta)*32767=5601.908
.byte lo8( 6393) ; i=200 theta=4.90874 cos(theta)*32767=6392.525
.byte lo8( 7179) ; i=201 theta=4.93328 cos(theta)*32767=7179.290
.byte lo8( 7962) ; i=202 theta=4.95783 cos(theta)*32767=7961.732
.byte lo8( 8739) ; i=203 theta=4.98237 cos(theta)*32767=8739.377
.byte lo8( 9512) ; i=204 theta=5.00691 cos(theta)*32767=9511.758
.byte lo8( 10278) ; i=205 theta=5.03146 cos(theta)*32767=10278.410
.byte lo8( 11039) ; i=206 theta=5.05600 cos(theta)*32767=11038.870
.byte lo8( 11793) ; i=207 theta=5.08054 cos(theta)*32767=11792.681
.byte lo8( 12539) ; i=208 theta=5.10509 cos(theta)*32767=12539.388
.byte lo8( 13279) ; i=209 theta=5.12963 cos(theta)*32767=13278.542
.byte lo8( 14010) ; i=210 theta=5.15418 cos(theta)*32767=14009.698
.byte lo8( 14732) ; i=211 theta=5.17872 cos(theta)*32767=14732.414
.byte lo8( 15446) ; i=212 theta=5.20326 cos(theta)*32767=15446.257
.byte lo8( 16151) ; i=213 theta=5.22781 cos(theta)*32767=16150.795
.byte lo8( 16846) ; i=214 theta=5.25235 cos(theta)*32767=16845.605
.byte lo8( 17530) ; i=215 theta=5.27689 cos(theta)*32767=17530.267
.byte lo8( 18204) ; i=216 theta=5.30144 cos(theta)*32767=18204.370
.byte lo8( 18868) ; i=217 theta=5.32598 cos(theta)*32767=18867.507
.byte lo8( 19519) ; i=218 theta=5.35052 cos(theta)*32767=19519.279
.byte lo8( 20159) ; i=219 theta=5.37507 cos(theta)*32767=20159.294
.byte lo8( 20787) ; i=220 theta=5.39961 cos(theta)*32767=20787.165
.byte lo8( 21403) ; i=221 theta=5.42416 cos(theta)*32767=21402.515
.byte lo8( 22005) ; i=222 theta=5.44870 cos(theta)*32767=22004.972
.byte lo8( 22594) ; i=223 theta=5.47324 cos(theta)*32767=22594.175
.byte lo8( 23170) ; i=224 theta=5.49779 cos(theta)*32767=23169.768
.byte lo8( 23731) ; i=225 theta=5.52233 cos(theta)*32767=23731.404
.byte lo8( 24279) ; i=226 theta=5.54687 cos(theta)*32767=24278.746
.byte lo8( 24811) ; i=227 theta=5.57142 cos(theta)*32767=24811.462
.byte lo8( 25329) ; i=228 theta=5.59596 cos(theta)*32767=25329.234
.byte lo8( 25832) ; i=229 theta=5.62051 cos(theta)*32767=25831.747
.byte lo8( 26319) ; i=230 theta=5.64505 cos(theta)*32767=26318.701
.byte lo8( 26790) ; i=231 theta=5.66959 cos(theta)*32767=26789.802
.byte lo8( 27245) ; i=232 theta=5.69414 cos(theta)*32767=27244.765
.byte lo8( 27683) ; i=233 theta=5.71868 cos(theta)*32767=27683.317
.byte lo8( 28105) ; i=234 theta=5.74322 cos(theta)*32767=28105.193
.byte lo8( 28510) ; i=235 theta=5.76777 cos(theta)*32767=28510.140
.byte lo8( 28898) ; i=236 theta=5.79231 cos(theta)*32767=28897.914
.byte lo8( 29268) ; i=237 theta=5.81686 cos(theta)*32767=29268.281
.byte lo8( 29621) ; i=238 theta=5.84140 cos(theta)*32767=29621.017
.byte lo8( 29956) ; i=239 theta=5.86594 cos(theta)*32767=29955.911
.byte lo8( 30273) ; i=240 theta=5.89049 cos(theta)*32767=30272.761
.byte lo8( 30571) ; i=241 theta=5.91503 cos(theta)*32767=30571.375
.byte lo8( 30852) ; i=242 theta=5.93957 cos(theta)*32767=30851.574
.byte lo8( 31113) ; i=243 theta=5.96412 cos(theta)*32767=31113.190
.byte lo8( 31356) ; i=244 theta=5.98866 cos(theta)*32767=31356.064
.byte lo8( 31580) ; i=245 theta=6.01320 cos(theta)*32767=31580.050
.byte lo8( 31785) ; i=246 theta=6.03775 cos(theta)*32767=31785.014
.byte lo8( 31971) ; i=247 theta=6.06229 cos(theta)*32767=31970.832
.byte lo8( 32137) ; i=248 theta=6.08684 cos(theta)*32767=32137.391
.byte lo8( 32285) ; i=249 theta=6.11138 cos(theta)*32767=32284.593
.byte lo8( 32412) ; i=250 theta=6.13592 cos(theta)*32767=32412.347
.byte lo8( 32521) ; i=251 theta=6.16047 cos(theta)*32767=32520.577
.byte lo8( 32609) ; i=252 theta=6.18501 cos(theta)*32767=32609.218
.byte lo8( 32678) ; i=253 theta=6.20955 cos(theta)*32767=32678.216
.byte lo8( 32728) ; i=254 theta=6.23410 cos(theta)*32767=32727.531
.byte lo8( 32757) ; i=255 theta=6.25864 cos(theta)*32767=32757.131
cosinetable_msb:
.byte hi8( 32767) ; i= 0 theta=0.00000 cos(theta)*32767=32767.000
.byte hi8( 32757) ; i= 1 theta=0.02454 cos(theta)*32767=32757.131
.byte hi8( 32728) ; i= 2 theta=0.04909 cos(theta)*32767=32727.531
.byte hi8( 32678) ; i= 3 theta=0.07363 cos(theta)*32767=32678.216
.byte hi8( 32609) ; i= 4 theta=0.09817 cos(theta)*32767=32609.218
.byte hi8( 32521) ; i= 5 theta=0.12272 cos(theta)*32767=32520.577
.byte hi8( 32412) ; i= 6 theta=0.14726 cos(theta)*32767=32412.347
.byte hi8( 32285) ; i= 7 theta=0.17181 cos(theta)*32767=32284.593
.byte hi8( 32137) ; i= 8 theta=0.19635 cos(theta)*32767=32137.391
.byte hi8( 31971) ; i= 9 theta=0.22089 cos(theta)*32767=31970.832
.byte hi8( 31785) ; i= 10 theta=0.24544 cos(theta)*32767=31785.014
.byte hi8( 31580) ; i= 11 theta=0.26998 cos(theta)*32767=31580.050
.byte hi8( 31356) ; i= 12 theta=0.29452 cos(theta)*32767=31356.064
.byte hi8( 31113) ; i= 13 theta=0.31907 cos(theta)*32767=31113.190
.byte hi8( 30852) ; i= 14 theta=0.34361 cos(theta)*32767=30851.574
.byte hi8( 30571) ; i= 15 theta=0.36816 cos(theta)*32767=30571.375
.byte hi8( 30273) ; i= 16 theta=0.39270 cos(theta)*32767=30272.761
.byte hi8( 29956) ; i= 17 theta=0.41724 cos(theta)*32767=29955.911
.byte hi8( 29621) ; i= 18 theta=0.44179 cos(theta)*32767=29621.017
.byte hi8( 29268) ; i= 19 theta=0.46633 cos(theta)*32767=29268.281
.byte hi8( 28898) ; i= 20 theta=0.49087 cos(theta)*32767=28897.914
.byte hi8( 28510) ; i= 21 theta=0.51542 cos(theta)*32767=28510.140
.byte hi8( 28105) ; i= 22 theta=0.53996 cos(theta)*32767=28105.193
.byte hi8( 27683) ; i= 23 theta=0.56450 cos(theta)*32767=27683.317
.byte hi8( 27245) ; i= 24 theta=0.58905 cos(theta)*32767=27244.765
.byte hi8( 26790) ; i= 25 theta=0.61359 cos(theta)*32767=26789.802
.byte hi8( 26319) ; i= 26 theta=0.63814 cos(theta)*32767=26318.701
.byte hi8( 25832) ; i= 27 theta=0.66268 cos(theta)*32767=25831.747
.byte hi8( 25329) ; i= 28 theta=0.68722 cos(theta)*32767=25329.234
.byte hi8( 24811) ; i= 29 theta=0.71177 cos(theta)*32767=24811.462
.byte hi8( 24279) ; i= 30 theta=0.73631 cos(theta)*32767=24278.746
.byte hi8( 23731) ; i= 31 theta=0.76085 cos(theta)*32767=23731.404
.byte hi8( 23170) ; i= 32 theta=0.78540 cos(theta)*32767=23169.768
.byte hi8( 22594) ; i= 33 theta=0.80994 cos(theta)*32767=22594.175
.byte hi8( 22005) ; i= 34 theta=0.83449 cos(theta)*32767=22004.972
.byte hi8( 21403) ; i= 35 theta=0.85903 cos(theta)*32767=21402.515
.byte hi8( 20787) ; i= 36 theta=0.88357 cos(theta)*32767=20787.165
.byte hi8( 20159) ; i= 37 theta=0.90812 cos(theta)*32767=20159.294
.byte hi8( 19519) ; i= 38 theta=0.93266 cos(theta)*32767=19519.279
.byte hi8( 18868) ; i= 39 theta=0.95720 cos(theta)*32767=18867.507
.byte hi8( 18204) ; i= 40 theta=0.98175 cos(theta)*32767=18204.370
.byte hi8( 17530) ; i= 41 theta=1.00629 cos(theta)*32767=17530.267
.byte hi8( 16846) ; i= 42 theta=1.03084 cos(theta)*32767=16845.605
.byte hi8( 16151) ; i= 43 theta=1.05538 cos(theta)*32767=16150.795
.byte hi8( 15446) ; i= 44 theta=1.07992 cos(theta)*32767=15446.257
.byte hi8( 14732) ; i= 45 theta=1.10447 cos(theta)*32767=14732.414
.byte hi8( 14010) ; i= 46 theta=1.12901 cos(theta)*32767=14009.698
.byte hi8( 13279) ; i= 47 theta=1.15355 cos(theta)*32767=13278.542
.byte hi8( 12539) ; i= 48 theta=1.17810 cos(theta)*32767=12539.388
.byte hi8( 11793) ; i= 49 theta=1.20264 cos(theta)*32767=11792.681
.byte hi8( 11039) ; i= 50 theta=1.22718 cos(theta)*32767=11038.870
.byte hi8( 10278) ; i= 51 theta=1.25173 cos(theta)*32767=10278.410
.byte hi8( 9512) ; i= 52 theta=1.27627 cos(theta)*32767=9511.758
.byte hi8( 8739) ; i= 53 theta=1.30082 cos(theta)*32767=8739.377
.byte hi8( 7962) ; i= 54 theta=1.32536 cos(theta)*32767=7961.732
.byte hi8( 7179) ; i= 55 theta=1.34990 cos(theta)*32767=7179.290
.byte hi8( 6393) ; i= 56 theta=1.37445 cos(theta)*32767=6392.525
.byte hi8( 5602) ; i= 57 theta=1.39899 cos(theta)*32767=5601.908
.byte hi8( 4808) ; i= 58 theta=1.42353 cos(theta)*32767=4807.917
.byte hi8( 4011) ; i= 59 theta=1.44808 cos(theta)*32767=4011.031
.byte hi8( 3212) ; i= 60 theta=1.47262 cos(theta)*32767=3211.728
.byte hi8( 2410) ; i= 61 theta=1.49717 cos(theta)*32767=2410.490
.byte hi8( 1608) ; i= 62 theta=1.52171 cos(theta)*32767=1607.800
.byte hi8( 804) ; i= 63 theta=1.54625 cos(theta)*32767=804.142
.byte hi8( 0) ; i= 64 theta=1.57080 cos(theta)*32767=0.000
.byte hi8( -804) ; i= 65 theta=1.59534 cos(theta)*32767=-804.142
.byte hi8( -1608) ; i= 66 theta=1.61988 cos(theta)*32767=-1607.800
.byte hi8( -2410) ; i= 67 theta=1.64443 cos(theta)*32767=-2410.490
.byte hi8( -3212) ; i= 68 theta=1.66897 cos(theta)*32767=-3211.728
.byte hi8( -4011) ; i= 69 theta=1.69351 cos(theta)*32767=-4011.031
.byte hi8( -4808) ; i= 70 theta=1.71806 cos(theta)*32767=-4807.917
.byte hi8( -5602) ; i= 71 theta=1.74260 cos(theta)*32767=-5601.908
.byte hi8( -6393) ; i= 72 theta=1.76715 cos(theta)*32767=-6392.525
.byte hi8( -7179) ; i= 73 theta=1.79169 cos(theta)*32767=-7179.290
.byte hi8( -7962) ; i= 74 theta=1.81623 cos(theta)*32767=-7961.732
.byte hi8( -8739) ; i= 75 theta=1.84078 cos(theta)*32767=-8739.377
.byte hi8( -9512) ; i= 76 theta=1.86532 cos(theta)*32767=-9511.758
.byte hi8(-10278) ; i= 77 theta=1.88986 cos(theta)*32767=-10278.410
.byte hi8(-11039) ; i= 78 theta=1.91441 cos(theta)*32767=-11038.870
.byte hi8(-11793) ; i= 79 theta=1.93895 cos(theta)*32767=-11792.681
.byte hi8(-12539) ; i= 80 theta=1.96350 cos(theta)*32767=-12539.388
.byte hi8(-13279) ; i= 81 theta=1.98804 cos(theta)*32767=-13278.542
.byte hi8(-14010) ; i= 82 theta=2.01258 cos(theta)*32767=-14009.698
.byte hi8(-14732) ; i= 83 theta=2.03713 cos(theta)*32767=-14732.414
.byte hi8(-15446) ; i= 84 theta=2.06167 cos(theta)*32767=-15446.257
.byte hi8(-16151) ; i= 85 theta=2.08621 cos(theta)*32767=-16150.795
.byte hi8(-16846) ; i= 86 theta=2.11076 cos(theta)*32767=-16845.605
.byte hi8(-17530) ; i= 87 theta=2.13530 cos(theta)*32767=-17530.267
.byte hi8(-18204) ; i= 88 theta=2.15984 cos(theta)*32767=-18204.370
.byte hi8(-18868) ; i= 89 theta=2.18439 cos(theta)*32767=-18867.507
.byte hi8(-19519) ; i= 90 theta=2.20893 cos(theta)*32767=-19519.279
.byte hi8(-20159) ; i= 91 theta=2.23348 cos(theta)*32767=-20159.294
.byte hi8(-20787) ; i= 92 theta=2.25802 cos(theta)*32767=-20787.165
.byte hi8(-21403) ; i= 93 theta=2.28256 cos(theta)*32767=-21402.515
.byte hi8(-22005) ; i= 94 theta=2.30711 cos(theta)*32767=-22004.972
.byte hi8(-22594) ; i= 95 theta=2.33165 cos(theta)*32767=-22594.175
.byte hi8(-23170) ; i= 96 theta=2.35619 cos(theta)*32767=-23169.768
.byte hi8(-23731) ; i= 97 theta=2.38074 cos(theta)*32767=-23731.404
.byte hi8(-24279) ; i= 98 theta=2.40528 cos(theta)*32767=-24278.746
.byte hi8(-24811) ; i= 99 theta=2.42983 cos(theta)*32767=-24811.462
.byte hi8(-25329) ; i=100 theta=2.45437 cos(theta)*32767=-25329.234
.byte hi8(-25832) ; i=101 theta=2.47891 cos(theta)*32767=-25831.747
.byte hi8(-26319) ; i=102 theta=2.50346 cos(theta)*32767=-26318.701
.byte hi8(-26790) ; i=103 theta=2.52800 cos(theta)*32767=-26789.802
.byte hi8(-27245) ; i=104 theta=2.55254 cos(theta)*32767=-27244.765
.byte hi8(-27683) ; i=105 theta=2.57709 cos(theta)*32767=-27683.317
.byte hi8(-28105) ; i=106 theta=2.60163 cos(theta)*32767=-28105.193
.byte hi8(-28510) ; i=107 theta=2.62618 cos(theta)*32767=-28510.140
.byte hi8(-28898) ; i=108 theta=2.65072 cos(theta)*32767=-28897.914
.byte hi8(-29268) ; i=109 theta=2.67526 cos(theta)*32767=-29268.281
.byte hi8(-29621) ; i=110 theta=2.69981 cos(theta)*32767=-29621.017
.byte hi8(-29956) ; i=111 theta=2.72435 cos(theta)*32767=-29955.911
.byte hi8(-30273) ; i=112 theta=2.74889 cos(theta)*32767=-30272.761
.byte hi8(-30571) ; i=113 theta=2.77344 cos(theta)*32767=-30571.375
.byte hi8(-30852) ; i=114 theta=2.79798 cos(theta)*32767=-30851.574
.byte hi8(-31113) ; i=115 theta=2.82252 cos(theta)*32767=-31113.190
.byte hi8(-31356) ; i=116 theta=2.84707 cos(theta)*32767=-31356.064
.byte hi8(-31580) ; i=117 theta=2.87161 cos(theta)*32767=-31580.050
.byte hi8(-31785) ; i=118 theta=2.89616 cos(theta)*32767=-31785.014
.byte hi8(-31971) ; i=119 theta=2.92070 cos(theta)*32767=-31970.832
.byte hi8(-32137) ; i=120 theta=2.94524 cos(theta)*32767=-32137.391
.byte hi8(-32285) ; i=121 theta=2.96979 cos(theta)*32767=-32284.593
.byte hi8(-32412) ; i=122 theta=2.99433 cos(theta)*32767=-32412.347
.byte hi8(-32521) ; i=123 theta=3.01887 cos(theta)*32767=-32520.577
.byte hi8(-32609) ; i=124 theta=3.04342 cos(theta)*32767=-32609.218
.byte hi8(-32678) ; i=125 theta=3.06796 cos(theta)*32767=-32678.216
.byte hi8(-32728) ; i=126 theta=3.09251 cos(theta)*32767=-32727.531
.byte hi8(-32757) ; i=127 theta=3.11705 cos(theta)*32767=-32757.131
.byte hi8(-32767) ; i=128 theta=3.14159 cos(theta)*32767=-32767.000
.byte hi8(-32757) ; i=129 theta=3.16614 cos(theta)*32767=-32757.131
.byte hi8(-32728) ; i=130 theta=3.19068 cos(theta)*32767=-32727.531
.byte hi8(-32678) ; i=131 theta=3.21522 cos(theta)*32767=-32678.216
.byte hi8(-32609) ; i=132 theta=3.23977 cos(theta)*32767=-32609.218
.byte hi8(-32521) ; i=133 theta=3.26431 cos(theta)*32767=-32520.577
.byte hi8(-32412) ; i=134 theta=3.28885 cos(theta)*32767=-32412.347
.byte hi8(-32285) ; i=135 theta=3.31340 cos(theta)*32767=-32284.593
.byte hi8(-32137) ; i=136 theta=3.33794 cos(theta)*32767=-32137.391
.byte hi8(-31971) ; i=137 theta=3.36249 cos(theta)*32767=-31970.832
.byte hi8(-31785) ; i=138 theta=3.38703 cos(theta)*32767=-31785.014
.byte hi8(-31580) ; i=139 theta=3.41157 cos(theta)*32767=-31580.050
.byte hi8(-31356) ; i=140 theta=3.43612 cos(theta)*32767=-31356.064
.byte hi8(-31113) ; i=141 theta=3.46066 cos(theta)*32767=-31113.190
.byte hi8(-30852) ; i=142 theta=3.48520 cos(theta)*32767=-30851.574
.byte hi8(-30571) ; i=143 theta=3.50975 cos(theta)*32767=-30571.375
.byte hi8(-30273) ; i=144 theta=3.53429 cos(theta)*32767=-30272.761
.byte hi8(-29956) ; i=145 theta=3.55884 cos(theta)*32767=-29955.911
.byte hi8(-29621) ; i=146 theta=3.58338 cos(theta)*32767=-29621.017
.byte hi8(-29268) ; i=147 theta=3.60792 cos(theta)*32767=-29268.281
.byte hi8(-28898) ; i=148 theta=3.63247 cos(theta)*32767=-28897.914
.byte hi8(-28510) ; i=149 theta=3.65701 cos(theta)*32767=-28510.140
.byte hi8(-28105) ; i=150 theta=3.68155 cos(theta)*32767=-28105.193
.byte hi8(-27683) ; i=151 theta=3.70610 cos(theta)*32767=-27683.317
.byte hi8(-27245) ; i=152 theta=3.73064 cos(theta)*32767=-27244.765
.byte hi8(-26790) ; i=153 theta=3.75518 cos(theta)*32767=-26789.802
.byte hi8(-26319) ; i=154 theta=3.77973 cos(theta)*32767=-26318.701
.byte hi8(-25832) ; i=155 theta=3.80427 cos(theta)*32767=-25831.747
.byte hi8(-25329) ; i=156 theta=3.82882 cos(theta)*32767=-25329.234
.byte hi8(-24811) ; i=157 theta=3.85336 cos(theta)*32767=-24811.462
.byte hi8(-24279) ; i=158 theta=3.87790 cos(theta)*32767=-24278.746
.byte hi8(-23731) ; i=159 theta=3.90245 cos(theta)*32767=-23731.404
.byte hi8(-23170) ; i=160 theta=3.92699 cos(theta)*32767=-23169.768
.byte hi8(-22594) ; i=161 theta=3.95153 cos(theta)*32767=-22594.175
.byte hi8(-22005) ; i=162 theta=3.97608 cos(theta)*32767=-22004.972
.byte hi8(-21403) ; i=163 theta=4.00062 cos(theta)*32767=-21402.515
.byte hi8(-20787) ; i=164 theta=4.02517 cos(theta)*32767=-20787.165
.byte hi8(-20159) ; i=165 theta=4.04971 cos(theta)*32767=-20159.294
.byte hi8(-19519) ; i=166 theta=4.07425 cos(theta)*32767=-19519.279
.byte hi8(-18868) ; i=167 theta=4.09880 cos(theta)*32767=-18867.507
.byte hi8(-18204) ; i=168 theta=4.12334 cos(theta)*32767=-18204.370
.byte hi8(-17530) ; i=169 theta=4.14788 cos(theta)*32767=-17530.267
.byte hi8(-16846) ; i=170 theta=4.17243 cos(theta)*32767=-16845.605
.byte hi8(-16151) ; i=171 theta=4.19697 cos(theta)*32767=-16150.795
.byte hi8(-15446) ; i=172 theta=4.22152 cos(theta)*32767=-15446.257
.byte hi8(-14732) ; i=173 theta=4.24606 cos(theta)*32767=-14732.414
.byte hi8(-14010) ; i=174 theta=4.27060 cos(theta)*32767=-14009.698
.byte hi8(-13279) ; i=175 theta=4.29515 cos(theta)*32767=-13278.542
.byte hi8(-12539) ; i=176 theta=4.31969 cos(theta)*32767=-12539.388
.byte hi8(-11793) ; i=177 theta=4.34423 cos(theta)*32767=-11792.681
.byte hi8(-11039) ; i=178 theta=4.36878 cos(theta)*32767=-11038.870
.byte hi8(-10278) ; i=179 theta=4.39332 cos(theta)*32767=-10278.410
.byte hi8( -9512) ; i=180 theta=4.41786 cos(theta)*32767=-9511.758
.byte hi8( -8739) ; i=181 theta=4.44241 cos(theta)*32767=-8739.377
.byte hi8( -7962) ; i=182 theta=4.46695 cos(theta)*32767=-7961.732
.byte hi8( -7179) ; i=183 theta=4.49150 cos(theta)*32767=-7179.290
.byte hi8( -6393) ; i=184 theta=4.51604 cos(theta)*32767=-6392.525
.byte hi8( -5602) ; i=185 theta=4.54058 cos(theta)*32767=-5601.908
.byte hi8( -4808) ; i=186 theta=4.56513 cos(theta)*32767=-4807.917
.byte hi8( -4011) ; i=187 theta=4.58967 cos(theta)*32767=-4011.031
.byte hi8( -3212) ; i=188 theta=4.61421 cos(theta)*32767=-3211.728
.byte hi8( -2410) ; i=189 theta=4.63876 cos(theta)*32767=-2410.490
.byte hi8( -1608) ; i=190 theta=4.66330 cos(theta)*32767=-1607.800
.byte hi8( -804) ; i=191 theta=4.68785 cos(theta)*32767=-804.142
.byte hi8( 0) ; i=192 theta=4.71239 cos(theta)*32767=-0.000
.byte hi8( 804) ; i=193 theta=4.73693 cos(theta)*32767=804.142
.byte hi8( 1608) ; i=194 theta=4.76148 cos(theta)*32767=1607.800
.byte hi8( 2410) ; i=195 theta=4.78602 cos(theta)*32767=2410.490
.byte hi8( 3212) ; i=196 theta=4.81056 cos(theta)*32767=3211.728
.byte hi8( 4011) ; i=197 theta=4.83511 cos(theta)*32767=4011.031
.byte hi8( 4808) ; i=198 theta=4.85965 cos(theta)*32767=4807.917
.byte hi8( 5602) ; i=199 theta=4.88419 cos(theta)*32767=5601.908
.byte hi8( 6393) ; i=200 theta=4.90874 cos(theta)*32767=6392.525
.byte hi8( 7179) ; i=201 theta=4.93328 cos(theta)*32767=7179.290
.byte hi8( 7962) ; i=202 theta=4.95783 cos(theta)*32767=7961.732
.byte hi8( 8739) ; i=203 theta=4.98237 cos(theta)*32767=8739.377
.byte hi8( 9512) ; i=204 theta=5.00691 cos(theta)*32767=9511.758
.byte hi8( 10278) ; i=205 theta=5.03146 cos(theta)*32767=10278.410
.byte hi8( 11039) ; i=206 theta=5.05600 cos(theta)*32767=11038.870
.byte hi8( 11793) ; i=207 theta=5.08054 cos(theta)*32767=11792.681
.byte hi8( 12539) ; i=208 theta=5.10509 cos(theta)*32767=12539.388
.byte hi8( 13279) ; i=209 theta=5.12963 cos(theta)*32767=13278.542
.byte hi8( 14010) ; i=210 theta=5.15418 cos(theta)*32767=14009.698
.byte hi8( 14732) ; i=211 theta=5.17872 cos(theta)*32767=14732.414
.byte hi8( 15446) ; i=212 theta=5.20326 cos(theta)*32767=15446.257
.byte hi8( 16151) ; i=213 theta=5.22781 cos(theta)*32767=16150.795
.byte hi8( 16846) ; i=214 theta=5.25235 cos(theta)*32767=16845.605
.byte hi8( 17530) ; i=215 theta=5.27689 cos(theta)*32767=17530.267
.byte hi8( 18204) ; i=216 theta=5.30144 cos(theta)*32767=18204.370
.byte hi8( 18868) ; i=217 theta=5.32598 cos(theta)*32767=18867.507
.byte hi8( 19519) ; i=218 theta=5.35052 cos(theta)*32767=19519.279
.byte hi8( 20159) ; i=219 theta=5.37507 cos(theta)*32767=20159.294
.byte hi8( 20787) ; i=220 theta=5.39961 cos(theta)*32767=20787.165
.byte hi8( 21403) ; i=221 theta=5.42416 cos(theta)*32767=21402.515
.byte hi8( 22005) ; i=222 theta=5.44870 cos(theta)*32767=22004.972
.byte hi8( 22594) ; i=223 theta=5.47324 cos(theta)*32767=22594.175
.byte hi8( 23170) ; i=224 theta=5.49779 cos(theta)*32767=23169.768
.byte hi8( 23731) ; i=225 theta=5.52233 cos(theta)*32767=23731.404
.byte hi8( 24279) ; i=226 theta=5.54687 cos(theta)*32767=24278.746
.byte hi8( 24811) ; i=227 theta=5.57142 cos(theta)*32767=24811.462
.byte hi8( 25329) ; i=228 theta=5.59596 cos(theta)*32767=25329.234
.byte hi8( 25832) ; i=229 theta=5.62051 cos(theta)*32767=25831.747
.byte hi8( 26319) ; i=230 theta=5.64505 cos(theta)*32767=26318.701
.byte hi8( 26790) ; i=231 theta=5.66959 cos(theta)*32767=26789.802
.byte hi8( 27245) ; i=232 theta=5.69414 cos(theta)*32767=27244.765
.byte hi8( 27683) ; i=233 theta=5.71868 cos(theta)*32767=27683.317
.byte hi8( 28105) ; i=234 theta=5.74322 cos(theta)*32767=28105.193
.byte hi8( 28510) ; i=235 theta=5.76777 cos(theta)*32767=28510.140
.byte hi8( 28898) ; i=236 theta=5.79231 cos(theta)*32767=28897.914
.byte hi8( 29268) ; i=237 theta=5.81686 cos(theta)*32767=29268.281
.byte hi8( 29621) ; i=238 theta=5.84140 cos(theta)*32767=29621.017
.byte hi8( 29956) ; i=239 theta=5.86594 cos(theta)*32767=29955.911
.byte hi8( 30273) ; i=240 theta=5.89049 cos(theta)*32767=30272.761
.byte hi8( 30571) ; i=241 theta=5.91503 cos(theta)*32767=30571.375
.byte hi8( 30852) ; i=242 theta=5.93957 cos(theta)*32767=30851.574
.byte hi8( 31113) ; i=243 theta=5.96412 cos(theta)*32767=31113.190
.byte hi8( 31356) ; i=244 theta=5.98866 cos(theta)*32767=31356.064
.byte hi8( 31580) ; i=245 theta=6.01320 cos(theta)*32767=31580.050
.byte hi8( 31785) ; i=246 theta=6.03775 cos(theta)*32767=31785.014
.byte hi8( 31971) ; i=247 theta=6.06229 cos(theta)*32767=31970.832
.byte hi8( 32137) ; i=248 theta=6.08684 cos(theta)*32767=32137.391
.byte hi8( 32285) ; i=249 theta=6.11138 cos(theta)*32767=32284.593
.byte hi8( 32412) ; i=250 theta=6.13592 cos(theta)*32767=32412.347
.byte hi8( 32521) ; i=251 theta=6.16047 cos(theta)*32767=32520.577
.byte hi8( 32609) ; i=252 theta=6.18501 cos(theta)*32767=32609.218
.byte hi8( 32678) ; i=253 theta=6.20955 cos(theta)*32767=32678.216
.byte hi8( 32728) ; i=254 theta=6.23410 cos(theta)*32767=32727.531
.byte hi8( 32757) ; i=255 theta=6.25864 cos(theta)*32767=32757.131
|
74hc595/Amethyst
| 47,511
|
system/videomodes.S
|
#include <avr/io.h>
#include "videodefs.h"
#include "asm_macros.inc"
; -------------------- Video linehandler calling convention --------------------
; r2 (isr_tmp) can be used freely but must be cleared before returning.
;
; r31:r30 (Z) and GPIOR0 can be used freely and does not have to be restored.
;
; GPIOR1 and GPIOR2 can be used freely (e.g. for saving registers without using
; the stack) *BUT* they must be restored to the low and high byte of the word
; address of the linehandler with `ldi`+`out` instructions.
;
; SREG must be explicitly saved and restored.
;
; All other registers must be explicitly saved and restored.
;
; Line handlers should end with a jump to `linehandler_end` and not a `ret`.
; Use the `lhret` macro.
;
; The instruction just before the start of a linehandler should be a relative
; jump to the frame handler, which is executed at the start of each frame.
; The builtin linehandlers all use the default framehandlers, but a custom
; linehandler is free to use its own.
;
; Frame handlers should end with a jump to `framehandler_end` and not a `ret`.
; Use the `fhret` macro.
;
; The stack is evil, avoid using it whenever possible!
; In an application with a full 16KB framebuffer, there are only a few hundred
; bytes of work RAM available, so every byte is sacred!
; Instead, consider saving registers/flags in isr_tmp (good for saving SREG),
; vptr (good for saving X), and GPIOR0/GPIOR1/GPIOR2.
;
; When the first instruction of a linehandler executed, TCNT2 will be 0.
; To keep horizontal alignment consistent with other modes, and to minimize
; jitter, all writes to PORTC should be done when TCNT2=1.
.global screen_ptr
.comm screen_ptr, 2
.comm tilemap_hi, 1
.comm tilemap_hh, 1
.comm globalcolor, 1
.comm vscroll, 1
.comm bytesperline, 1
.comm linesperscreen, 1
.section .linehandlers
; Cycles until first PORTC write: 33
.global linehandler_hires_tiled
rjmp framehandler
linehandler_hires_tiled:
9: ; initialize pointers, save registers
movw Z, vptr ; [0]
movw vptr, X ; [1] use vptr to save previous X value
movw X, Z ; [2] so we can use X to point into the name table
in isr_tmp, IO_(SREG) ; [3]
out IO_(GPIOR0), isr_tmp ; [4] save flags in GPIOR0
dec linenum ; [5]
; compute tilemap pointer high byte for this row
lds ZL, vscroll ; [6][7]
add ZL, linenum ; [0]
andi ZL, 7 ; [1]
lds ZH, tilemap_hi ; [2][3]
add ZH, ZL ; [4]
; we can use GPIOR1 and GPIOR2 as temporaries here,
; because they have known values and be restored with load-immediates
out IO_(GPIOR1), ZH ; [5] save high byte of left-half table
subi ZH, -8 ; [6] right-half table is 2048 bytes ahead
out IO_(GPIOR2), ZH ; [7] save high byte of right-half table
subi ZH, 8 ; [0] bring back address of left-half table
push r16 ; [1][2]
ldi r16, 40 ; [3] loop count
; is the tilemap in ROM or RAM?
lds ZL, tilemap_hh ; [4][5] tilemap pointer page byte
sbrc ZL, TILEMAP_IS_RAM_BIT ; [6][7] (if skipped)
rjmp .linehandler_hires_tiled_rampatterns ; [5][6] (if skipped)
.linehandler_hires_tiled_rompatterns:
; save previous RAMPZ0 bit in the carry flag, and set new RAMPZ0
; (only lowest bit of RAMPZ is significant on 128K flash parts)
in isr_tmp, IO_(RAMPZ) ; [0]
lsr isr_tmp ; [1]
out IO_(RAMPZ), ZL ; [2] set new RAMPZ0
nop ; [3]
; loop (each iteration takes 16 cycles and outputs 16 bits)
1: ld ZL, X+ ; [4][5] get tile index (2 cycles)
elpm isr_tmp, Z ; [6][7][0] get left pixels (3 cycles)
out IO_(PORTC), isr_tmp ; [1]* output left half of tile (1 cycle)
in ZH, IO_(GPIOR2) ; [2] switch to right-half table (1 cycle)
nop ; [3] spare (1 cycle)
elpm isr_tmp, Z ; [4][5][6] get right pixels (3 cycles)
in ZH, IO_(GPIOR1) ; [7] Z back to left-half tiles (1 cycle)
dec r16 ; [0] decrement loop count (1 cycle)
out IO_(PORTC), isr_tmp ; [1]* output right half of tile (1 cycle)
brne 1b ; [2][3] loop if columns left (2 cycles, 1 on last iteration)
; restore RAMPZ0
rol r16 ; [4] bring carry flag (old RAMPZ0) back into the low bit of a register
out IO_(RAMPZ), r16 ; [5] restore old RAMPZ0
nop ; [6]
.linehandler_hires_tiled_common_end:
; restore registers, blank video
clrnf isr_tmp ; [7]
ldi ZL, pm_lo8(9b) ; [0]
out IO_(PORTC), isr_tmp ; [1]* blank video
pop r16
out IO_(GPIOR1), ZL
ldi ZL, pm_hi8(9b)
out IO_(GPIOR2), ZL
; unless this was the 8th row, rewind X back to the start of the line
lds ZL, tilemap_hi
cpse ZH, ZL
sbiw X, 40
; restore remaining registers
2: movw Z, X
movw X, vptr ; restore X register
movw vptr, Z ; save new vptr
in isr_tmp, IO_(GPIOR0) ; restore flags
out IO_(SREG), isr_tmp ;
lhret
.linehandler_hires_tiled_rampatterns:
short_nop5 ; for consistent alignment w/romfont
1: ld ZL, X+ ; [5][6] get tile index (2 cycles)
ld isr_tmp, Z ; [6][7] get left pixels (2 cycles)
in ZH, IO_(GPIOR2) ; [0] switch to right-half table (1 cycle)
out IO_(PORTC), isr_tmp ; [1]* output left half of tile (1 cycle)
short_nop2 ; [2][3] spare (2 cycles)
ld isr_tmp, Z ; [4][5] get right pixels (2 cycles)
in ZH, IO_(GPIOR1) ; [6] Z back to left-half tiles (1 cycle)
dec r16 ; [7] decrement loop count (1 cycle)
nop ; [0] spare (1 cycle)
out IO_(PORTC), isr_tmp ; [1]* output right half of tile (1 cycle)
brne 1b ; [3][4] loop if columns left (2 cycles, 1 on last iteration)
rjmp .linehandler_hires_tiled_common_end ; [5][6]
; Decrement line number, saving/restoring SREG. Takes 3 cycles and clobbers isr_tmp.
.macro dec_line_num
in isr_tmp, IO_(SREG)
dec linenum
out IO_(SREG), isr_tmp
.endm
; Cycles until first PORTC write: 9
.global linehandler_160x100x256
rjmp framehandler
linehandler_160x100x256:
; use bit 0 of GPIOR0 to determine if vertical resolution should be halved
sbi IO_(GPIOR0), 0 ; [0][1]
short_nop2 ; [2][3] for alignment with 160x200 mode
.linehandler_160_bytes_per_line:
nop ; [0]
movw Z, vptr ; [1]
.rept 32
nop ; [2] 1 cycle
ld isr_tmp, Z+ ; [3][0] 2 cycles
out IO_(PORTC), isr_tmp ; [1]* 1 cycle
.endr
.linehandler_128_bytes_per_line:
.rept 128
nop ; [2] 1 cycle
ld isr_tmp, Z+ ; [3][0] 2 cycles
out IO_(PORTC), isr_tmp ; [1]* 1 cycle
.endr
; done; blank video, save new pixel pointer, restore Z
short_nop2 ; [2][3]
clrnf isr_tmp ; [0] clear isr_tmp without affecting flags
out IO_(PORTC), isr_tmp ; [1]*
dec_line_num
sbic IO_(GPIOR0), 0
sbrs linenum, 0
movw vptr, Z
nop ; mystery nop--without it, horizontal alignment is off!
lhret
.global linehandler_128x100x256
rjmp framehandler
linehandler_128x100x256:
; use bit 0 of GPIOR0 to determine if vertical resolution should be halved
sbi IO_(GPIOR0), 0 ; [0][1]
movw Z, vptr ; [2]
short_nop2 ; [3][4]
rjmp .linehandler_128_bytes_per_line ; [0][1]
; There's not enough RAM for a full 160x200x256 framebuffer,
; so you'll need to get creative with raster interrupts and beam-racing
; if you use this mode
; Cycles until first PORTC write: 9
.global linehandler_160x200x256
rjmp framehandler
linehandler_160x200x256:
cbi IO_(GPIOR0), 0 ; [0][1]
rjmp .linehandler_160_bytes_per_line ; [2][3]
; Cycles until first PORTC write: 9
.global linehandler_80x50x256
rjmp framehandler
linehandler_80x50x256:
9: in isr_tmp, IO_(SREG) ; [0] save SREG in GPIOR0
out IO_(GPIOR0), isr_tmp ; [1]
movw Z, vptr ; [2]
out IO_(GPIOR1), r16 ; [3]
ldi r16, 80 ; [0]
dec linenum ; [1]
; 8 cycles per pixel (2 shift register periods)
1: ld isr_tmp, Z+ ; [2][3]
dec r16 ; [0]
out IO_(PORTC), isr_tmp ; [1]*
short_nop2 ; [2][3]
brne 1b ; [0][1]
; set Z flag if we need to advance to the next row
ldi r16, 3 ; [1]
and r16, linenum ; [2]
; blank video
clrnf isr_tmp ; [3]
nop ; [0]
out IO_(PORTC), isr_tmp ; [1]*
; if Z=0, advance vptr
brne 2f
movw vptr, Z
; restore registers
2: in isr_tmp, IO_(GPIOR0)
out IO_(SREG), isr_tmp
in r16, IO_(GPIOR1)
ldi ZL, pm_lo8(9b)
out IO_(GPIOR1), ZL
lhret
; Cycles until first PORTC write: 9
; (This is just a copy/paste of linehandler_80x50x256, but with a different
; bitmask applied to the line number)
.global linehandler_80x25x256
rjmp framehandler
linehandler_80x25x256:
9: in isr_tmp, IO_(SREG) ; [0] save SREG in GPIOR0
out IO_(GPIOR0), isr_tmp ; [1]
movw Z, vptr ; [2]
out IO_(GPIOR1), r16 ; [3]
ldi r16, 80 ; [0]
dec linenum ; [1]
; 8 cycles per pixel (2 shift register periods)
1: ld isr_tmp, Z+ ; [2][3]
dec r16 ; [0]
out IO_(PORTC), isr_tmp ; [1]*
short_nop2 ; [2][3]
brne 1b ; [0][1]
; set Z flag if we need to advance to the next row
ldi r16, 7 ; [1]
and r16, linenum ; [2]
; blank video
clrnf isr_tmp ; [3]
nop ; [0]
out IO_(PORTC), isr_tmp ; [1]*
; if Z=0, advance vptr
brne 2f
movw vptr, Z
; restore registers
2: in isr_tmp, IO_(GPIOR0)
out IO_(SREG), isr_tmp
in r16, IO_(GPIOR1)
ldi ZL, pm_lo8(9b)
out IO_(GPIOR1), ZL
lhret
; Cycles until first PORTC write: 9
.global linehandler_Nx200x16
rjmp framehandler
linehandler_Nx200x16:
in isr_tmp, IO_(SREG) ; [0] save SREG
set ; [1] T flag indicates if vertical resolution should be halved
short_nop2 ; [2][3] for alignment with 160x100
.linehandler_4_bits_per_pixel:
movw Z, vptr ; [4]
; we can use vptr_lo and vptr_hi as spares
lds vptr_lo, bytesperline ; [5][6] use vptr_lo as loop count
1: ld vptr_hi, Z+ ; [7][0] 2 cycles
out IO_(PORTC), vptr_hi ; [1]* 1 cycle
dec vptr_lo ; [2] decrement loop count (1 cycle)
short_nop2 ; [3][4]
brne 1b ; [5][6] 2 cycles
; restore registers and blank video
short_nop2 ; [6][7]
clrnf vptr_hi ; [0]
out IO_(PORTC), vptr_hi ; [1]*
dec linenum
brts 2f ; if T is clear, rewind the bitmap ptr to the start of the line
lds vptr_lo, bytesperline
sub ZL, vptr_lo ; move Z back by # of bytes per line
sbc ZH, vptr_hi ; will be zero
2: out IO_(SREG), isr_tmp ; restore SREG
movw vptr, Z ; save updated bitmap ptr
lhret
; Cycles until first PORTC write: 9
.global linehandler_Nx100x16
rjmp framehandler
linehandler_Nx100x16:
in isr_tmp, IO_(SREG) ; [0] save SREG
bst linenum, 0 ; [1] every other line, rewind bitmap ptr
rjmp .linehandler_4_bits_per_pixel ; [2][3]
; Black screen
.global linehandler_null
rjmp framehandler
linehandler_null:
dec_line_num
lhret
; Cycles until first PORTC write: 25
.global linehandler_160x200x4
rjmp framehandler
linehandler_160x200x4:
in isr_tmp, IO_(SREG) ; [0] save SREG
dec linenum ; [1]
clt ; [2] T flag indicates if vertical resolution should be halved
short_nop2 ; [3][4]
.linehandler_40_bytes_per_line:
short_nop2 ; [5][6]
.linehandler_40_bytes_per_line_no_nop2:
movw Z, vptr ; [7]
movw vptr, X ; [0] use vptr to save previous X value
movw X, Z ; [1] so we can use X to point into the bitmap
lds ZL, tilemap_hi ; [2][3] specifies the bitspread table, i.e. the palette
out IO_(GPIOR0), ZL ; [4]
push r16 ; [5][6]
lds r16, bytesperline ; [7][0]
in ZH, IO_(GPIOR0) ; [1] Z points into bitspread table
short_nop2 ; [2][3]
1: ld ZL, X+ ; [4][5] get 4 pixels (2 cycles)
lpm ZH, Z ; [6][7][0] get 8 bits for left 2 pixels (3 cycles)
out IO_(PORTC), ZH ; [1]* output 8 bits for left 2 pixels (1 cycle)
swap ZL ; [2] select upper nibble (1 cycle)
dec r16 ; [3] decrement loop count (1 cycle)
in ZH, IO_(GPIOR0) ; [4] Z points into bitspread table again (1 cycle)
lpm ZL, Z ; [5][6][7] get 8 bits for right 2 pixels (3 cycles)
nop ; [0]
out IO_(PORTC), ZL ; [1]* output 8 bits for right 2 pixels (1 cycle)
brne 1b ; [2][3] loop if bytes left (2 cycles, 1 on last iteration)
; restore registers and blank video
pop r16 ; [3][4]
lds ZL, bytesperline ; [5][6]
nop ; [7]
clrnf ZH ; [0]
out IO_(PORTC), ZH ; [1]*
brtc 2f ; if T is set, rewind the bitmap ptr to the start of the line
sub XL, ZL
sbc XH, ZH
; restore SREG and X, save new bitmap ptr
2: out IO_(SREG), isr_tmp
movw Z, X
movw X, vptr ; restore previous X value
movw vptr, Z ; save updated bitmap ptr
lhret
; Cycles until first PORTC write: 25
.global linehandler_160x100x4
rjmp framehandler
linehandler_160x100x4:
in isr_tmp, IO_(SREG) ; [0] save SREG
dec linenum ; [1]
bst linenum, 0 ; [2] every other line, rewind bitmap ptr
rjmp .linehandler_40_bytes_per_line ; [3][4]
; Cycles until first PORTC write: 25
.global linehandler_160x50x4
rjmp framehandler
linehandler_160x50x4:
in isr_tmp, IO_(SREG) ; [0] save SREG
dec linenum ; [1]
bst linenum, 0 ; [2] every fourth line, rewind bitmap ptr
sbrc linenum, 1 ; [3]
set ; [4]
rjmp .linehandler_40_bytes_per_line_no_nop2 ; [5][6]
; Cycles until first PORTC write: 25
.global linehandler_80x25_text
rjmp framehandler
linehandler_80x25_text:
; initialize pointers, save registers
in isr_tmp, IO_(SREG) ; [0]
dec linenum ; [1]
movw Z, vptr ; [2]
movw vptr, X ; [3] use vptr to save previous X value
movw X, Z ; [4] so we can use X to point into the name table
; compute tilemap pointer high byte for this row
lds ZL, vscroll ; [5][6]
add ZL, linenum ; [7]
andi ZL, 7 ; [0]
lds ZH, tilemap_hi ; [1][2]
add ZH, ZL ; [3]
out IO_(GPIOR0), r16 ; [4] need a temp register, save in GPIOR0 instead of the stack
; is the tilemap in ROM or RAM?
lds ZL, tilemap_hh ; [5][6] tilemap pointer page byte
sbrc ZL, TILEMAP_IS_RAM_BIT ; [7][0] (if skipped)
rjmp .linehandler_80x25_text_ramfont ; [0][1] (if not skipped)
.linehandler_80x25_text_romfont:
; save previous RAMPZ0 bit in the carry flag, and set new RAMPZ0
; (only lowest bit of RAMPZ is significant on 128K flash parts)
in r16, IO_(RAMPZ) ; [1]
lsr r16 ; [2]
out IO_(RAMPZ), ZL ; [3] set new RAMPZ0
; do the first 2 characters
ld ZL, X+ ; [4][5] get character table offset (2 cycles)
elpm ZL, Z ; [6][7][0] get 8 pixels (3 cycles)
out IO_(PORTC), ZL ; [1] output (1 cycle)
ldi r16, 39 ; [2] initialize loop count (1 cycle)
nop ; [3] spare (1 cycle)
ld ZL, X+ ; [4][5] get character table offset (2 cycles)
elpm ZL, Z ; [6][7][0] get 8 pixels (3 cycles)
out IO_(PORTC), ZL ; [1] output (1 cycle)
short_nop2 ; [2][3] spare (2 cycles)
; loop (each iteration takes 16 cycles with 2 characters per iteration)
1: ld ZL, X+ ; [4][5] get character table offset (2 cycles)
elpm ZL, Z ; [6][7][0] get 8 pixels (3 cycles)
out IO_(PORTC), ZL ; [1] output (1 cycle)
dec r16 ; [2] decrement loop count (1 cycle)
nop ; [3] spare (1 cycle)
ld ZL, X+ ; [4][5] get character table offset (2 cycles)
elpm ZL, Z ; [6][7][0] get 8 pixels (3 cycles)
out IO_(PORTC), ZL ; [1] output (1 cycle)
brne 1b ; [2][3] loop if characters left (2 cycles, 1 on last iteration)
; blank video, restore registers
rol r16 ; [3] bring carry flag (old RAMPZ0) back into the low bit of a register
out IO_(RAMPZ), r16 ; [4] restore old RAMPZ0
.linehandler_80x25_text_common_end:
in r16, IO_(GPIOR0) ; [5] restore r16
clrnf ZL ; [6]
short_nop2 ; [7][0]
out IO_(PORTC), ZL ; [1] blank video
; unless this was the 8th row, rewind X back to the start of the line
lds ZL, tilemap_hi
cp ZH, ZL
breq 2f
subi XL, lo8(80)
sbci XH, hi8(80)
2: movw Z, X
movw X, vptr ; restore X register
movw vptr, Z ; save new vptr
out IO_(SREG), isr_tmp ; restore flags
lhret
.linehandler_80x25_text_ramfont:
; delay to match the horizontal alignment of rom font
nop ; [2]
; loop (each iteration takes 8 cycles)
ldi r16, 80 ; [3]
3: ld ZL, X+ ; [4][5] get character table offset (2 cycles)
ld ZL, Z ; [6][7] get 8 pixels (2 cycles)
dec r16 ; [0] decrement loop count (1 cycle)
out IO_(PORTC), ZL ; [1] output (1 cycle)
brne 3b ; [2][3] loop if characters left (2 cycles, 1 on last iteration)
rjmp .linehandler_80x25_text_common_end ; [3][4]
; number in [brackets] indicates expected value of TCNT2 at start of this instruction
; TCNT2 should always be 0 when entering a linehandler
; Cycles until first PORTC write: 33
.global linehandler_40x25_text
rjmp framehandler
linehandler_40x25_text:
9: movw Z, vptr ; [0]
movw vptr, X ; [1] use vptr to save previous X value
movw X, Z ; [2] so we can use X to point into the name table
in isr_tmp, IO_(SREG) ; [3]
dec linenum ; [4]
; compute tilemap pointer high byte for this row
lds ZL, vscroll ; [5][6]
add ZL, linenum ; [7]
andi ZL, 7 ; [0]
lds ZH, tilemap_hi ; [1][2]
add ZH, ZL ; [3]
; cache it in GPIOR0
out IO_(GPIOR0), ZH ; [4]
; is the tilemap in ROM or RAM?
lds ZL, tilemap_hh ; [5][6] tilemap pointer page byte
sbrc ZL, TILEMAP_IS_RAM_BIT ; [7][0] (if skipped)
rjmp .linehandler_40x25_text_ramfont ; [0][1] (if not skipped)
.linehandler_40x25_text_romfont:
; we need 2 more registers, use GPIOR1/2 so we don't need the stack
out IO_(GPIOR1), r16 ; [1]
lds r16, globalcolor ; [2][3]
out IO_(GPIOR2), r17 ; [4]
; save previous RAMPZ in the T flag and set new RAMPZ0
in r17, IO_(RAMPZ) ; [5]
bst r17, 0 ; [6]
out IO_(RAMPZ), ZL ; [7]
; prep for the first character
ld ZL, X+ ; [0][1] get first character (2 cycles)
elpm ZL, Z ; [2][3][4] get 8 pixels for first character (3 cycles)
mov ZH, r16 ; [5] Z now points into bitspread table (1 cycle)
; loop (16 cycles per character)
.rept 39
lpm r17, Z ; [6][7][0] get right 8 pixels from bitspread table (3 cycles)
out IO_(PORTC), r17 ; [1]* output left 8 pixels (1 cycle)
swap ZL ; [2] select upper nibble (1 cycle)
lpm r17, Z ; [3][4][5] get left 8 pixels from bitspread table (3 cycles)
ld ZL, X+ ; [6][7] get next character (2 cycles)
in ZH, IO_(GPIOR0) ; [0] Z points into tilemap (1 cycle)
out IO_(PORTC), r17 ; [1]* output right 8 pixels (1 cycle)
elpm ZL, Z ; [2][3][4] get 8 pixels for character (3 cycles)
mov ZH, r16 ; [5] Z now points into bitspread table (1 cycle)
.endr
; tidy up the last character
lpm r17, Z ; [6][7][0] get left 8 pixels from bitspread table (3 cycles)
out IO_(PORTC), r17 ; [1]* output left 8 pixels (1 cycle)
swap ZL ; [2] select upper nibble (1 cycle)
lpm ZH, Z ; [3][4][5] get right 8 pixels from bitspread table (3 cycles)
; use the spare cycles until the next shift register strobe to pop registers and restore RAMPZ
bld r17, 0 ; [6]
out IO_(RAMPZ), r17 ; [7]
in r16, IO_(GPIOR1) ; [0]
out IO_(PORTC), ZH ; [1]* output right 8 pixels (1 cycle)
in r17, IO_(GPIOR2) ; [2]
; restore proper values to GPIOR1/GPIOR2 and blank video
ldi ZL, pm_lo8(9b) ; [3]
out IO_(GPIOR1), ZL ; [4]
ldi ZL, pm_hi8(9b) ; [5]
out IO_(GPIOR2), ZL ; [6]
clrnf ZL ; [7]
nop ; [0]
out IO_(PORTC), ZL ; [1]* blank video
.linehandler_40x25_text_common_end:
; unless this was the 8th row, rewind X back to the start of the line
in ZH, IO_(GPIOR0)
lds ZL, tilemap_hi
cpse ZH, ZL
sbiw X, 40
; restore registers, save new vptr
.linehandler_40x25_text_common_end2:
movw Z, X
movw X, vptr ; restore X register
movw vptr, Z ; save new vptr
out IO_(SREG), isr_tmp ; restore flags
lhret
.linehandler_40x25_text_ramfont:
; only need one extra register here
out IO_(GPIOR2), r17 ; [2]
; spare cycles to match length of rom font branch
short_nop5 ; [3][4][5][6][7]
; prep for the first character
ld ZL, X+ ; [0][1] get first character (2 cycles)
ld ZL, Z ; [2][3] get 8 pixels for first character (2 cycles)
lds ZH, globalcolor ; [4][5]
; loop (16 cycles per character)
.rept 39
lpm r17, Z ; [6][7][0] get left 8 pixels from bitspread table (3 cycles)
out IO_(PORTC), r17 ; [1]* output left 8 pixels (1 cycle)
swap ZL ; [2] select upper nibble (1 cycle)
lpm r17, Z ; [3][4][5] get right 8 pixels from bitspread table (3 cycles)
ld ZL, X+ ; [6][7] get next character (2 cycles)
in ZH, IO_(GPIOR0) ; [0] Z points into tilemap (1 cycle)
out IO_(PORTC), r17 ; [1]* output right 8 pixels (1 cycle)
ld ZL, Z ; [2][3] get 8 pixels for character (2 cycles)
lds ZH, globalcolor ; [4][5] Z now points into bitspread table (2 cycles)
.endr
; tidy up the last character
lpm r17, Z ; [6][7][0] get left 8 pixels from bitspread table (3 cycles)
out IO_(PORTC), r17 ; [1]* output left 8 pixels (1 cycle)
swap ZL ; [2] select upper nibble (1 cycle)
lpm ZH, Z ; [3][4][5] get right 8 pixels from bitspread table (3 cycles)
; use the spare cycles until the next shift register strobe to pop registers
in r17, IO_(GPIOR2) ; [6]
ldi ZL, pm_hi8(9b) ; [7] restore GPIOR2
out IO_(GPIOR2), ZL ; [0]
out IO_(PORTC), ZH ; [1]* output right 8 pixels
; blank video
short_nop3 ; [2][3][4]
short_nop3 ; [5][6][7]
clrnf ZL ; [0]
out IO_(PORTC), ZL ; [1]*
rjmp .linehandler_40x25_text_common_end
; Default framehandler for all modes.
framehandler:
; reset pixel pointer to start of buffer
lds ZL, screen_ptr
lds ZH, screen_ptr+1
movw vptr, Z
; initialize line count
; linehandler is responsible for decrementing it!
ldi r31, ACTIVE_VIDEO_LINES
mov linenum, r31
fhret
.global linehandler_40x25_color_text_romfont
rjmp framehandler
linehandler_40x25_color_text_romfont:
9: ; initialize pointers, save registers
in isr_tmp, IO_(SREG) ; [0]
dec linenum ; [1]
movw Z, vptr ; [2]
movw vptr, X ; [3] use vptr to save previous X value
movw X, Z ; [4] so we can use X to point into the name table
out IO_(GPIOR1), YL ; [5] save Y in GPIOR1/2 instead of the stack
out IO_(GPIOR2), YH ; [6]
; Y points to the color table (1000 bytes past the name table)
movw Y, X ; [7]
subi YL, lo8(-1000) ; [0]
sbci YH, hi8(-1000) ; [1]
; compute tilemap address high byte for this line
lds ZL, vscroll ; [2][3]
add ZL, linenum ; [4]
andi ZL, 7 ; [5]
lds ZH, tilemap_hi ; [6][7]
add ZH, ZL ; [0]
; cache it in GPIOR0
out IO_(GPIOR0), ZH ; [1]
; save previous RAMPZ0 bit in the carry flag, and set new RAMPZ0
; (only lowest bit of RAMPZ is significant on 128K flash parts)
push r16 ; [2][3]
lds ZL, tilemap_hh ; [4][5] tilemap pointer page byte
in r16, IO_(RAMPZ) ; [6]
lsr r16 ; [7]
out IO_(RAMPZ), ZL ; [0] set new RAMPZ0
; this is where things get crazy... this mode requires 17 cycles to get
; the pixels for each tile, but tiles are output every 16 cycles.
; so we preload the first few pixels in registers, which requires quite
; a bit of time (hence the large X offset correction).
; the code to read and output the pixel data is fully unrolled, and
; autogenerated using the script `codegen_40x25_color_text_romfont.py`.
push r17 ; [1][2]
push r18 ; [3][4]
push r19 ; [5][6]
push r20 ; [7][0]
#include "linehandler_40x25_color_text_romfont.inc"
pop r20
pop r19
pop r18
clrnf ZL
out IO_(PORTC), ZL
pop r17
rol r16 ; bring carry flag (old RAMPZ0) back into the low bit of a register
out IO_(RAMPZ), r16 ; restore old RAMPZ0
pop r16
; unless this was the 8th row, rewind X back to the start of the line
lds ZL, tilemap_hi
in ZH, IO_(GPIOR0)
cpse ZH, ZL
sbiw X, 40
in YL, IO_(GPIOR1)
in YH, IO_(GPIOR2)
ldi ZL, pm_lo8(9b)
out IO_(GPIOR1), ZL
ldi ZL, pm_hi8(9b)
out IO_(GPIOR2), ZL
rjmp .linehandler_40x25_text_common_end2
; Cycles until first PORTC write: 33
.global linehandler_40x25_color_text_ramfont
rjmp framehandler
linehandler_40x25_color_text_ramfont:
9: ; initialize pointers, save registers
in isr_tmp, IO_(SREG) ; [0]
dec linenum ; [1]
movw Z, vptr ; [2]
movw vptr, X ; [3] use vptr to save previous X value
movw X, Z ; [4] so we can use X to point into the name table
out IO_(GPIOR1), YL ; [5] save Y in GPIOR1/2 instead of the stack
out IO_(GPIOR2), YH ; [6]
; Y points to the color table (1000 bytes past the name table)
movw Y, X ; [7]
subi YL, lo8(-1000) ; [0]
sbci YH, hi8(-1000) ; [1]
; compute tilemap address high byte for this line
lds ZL, vscroll ; [2][3]
add ZL, linenum ; [4]
andi ZL, 7 ; [5]
lds ZH, tilemap_hi ; [6][7]
add ZH, ZL ; [0]
; cache it in GPIOR0
out IO_(GPIOR0), ZH ; [1]
; set Z flag if this is an 8th row
lds ZL, tilemap_hi ; [2][3]
cp ZH, ZL ; [4]
; only need one temporary
push r16 ; [5][6]
; align to the shift register strobe
nop ; [7]
; prep for the first character
ld ZL, X+ ; [0][1] get first character (2 cycles)
ld ZL, Z ; [2][3] get 8 pixels for first character (2 cycles)
ld ZH, Y+ ; [4][5] get color for first character (2 cycle)
; loop (16 cycles per character)
.rept 39
lpm r16, Z ; [6][7][0] get left 8 pixels from bitspread table (3 cycles)
out IO_(PORTC), r16 ; [1]* output left 8 pixels (1 cycle)
swap ZL ; [2] select upper nibble (1 cycle)
lpm r16, Z ; [3][4][5] get right 8 pixels from bitspread table (3 cycles)
ld ZL, X+ ; [6][7] get next character (2 cycles)
in ZH, IO_(GPIOR0) ; [0] Z points into tilemap (1 cycle)
out IO_(PORTC), r16 ; [1]* output right 8 pixels (1 cycle)
ld ZL, Z ; [2][3] get 8 pixels for character (2 cycles)
ld ZH, Y+ ; [4][5] get color for character, Z now points into bitspread table (2 cycles)
.endr
; tidy up the last character
lpm r16, Z ; [6][7][0] get left 8 pixels from bitspread table (3 cycles)
out IO_(PORTC), r16 ; [1]* output left 8 pixels (1 cycle)
swap ZL ; [2] select upper nibble (1 cycle)
nop ; [3]
lpm ZH, Z ; [4][5][6] get right 8 pixels from bitspread table (3 cycles)
; use the spare cycles until the next shift register strobe to pop registers
pop r16 ; [7][0]
out IO_(PORTC), ZH ; [1]* output right 8 pixels (1 cycle)
in YL, IO_(GPIOR1) ; [2]
in YH, IO_(GPIOR2) ; [3]
ldi ZL, pm_lo8(9b) ; [4]
out IO_(GPIOR1), ZL ; [5]
ldi ZL, pm_hi8(9b) ; [6]
out IO_(GPIOR2), ZL ; [7]
; blank video
clrnf ZL ; [0]
out IO_(PORTC), ZL ; [1]*
; epilogue is the same as mono mode
rjmp .linehandler_40x25_text_common_end
; Cycles until first PORTC write: 33
.global linehandler_80x100x4
rjmp framehandler
linehandler_80x100x4:
9: in isr_tmp, IO_(SREG) ; [0] save SREG
dec linenum ; [1]
movw Z, vptr ; [2]
movw vptr, X ; [3] use vptr to save previous X value
movw X, Z ; [4] so we can use X to point into the bitmap
lds ZL, tilemap_hi ; [5][6] specifies the bitspread table, i.e. the palette
out IO_(GPIOR0), ZL ; [7] store in GPIOR0
; we need 3 temp registers; use GPIOR1/2 to save 2 of them
out IO_(GPIOR1), r16 ; [0]
out IO_(GPIOR2), r17 ; [1]
push r18 ; [2][3]
clr r17 ; [4]
clr r18 ; [5]
.rept 20
ld ZL, X+ ; [6][7] get 4 pixels
; expand 8 bits to 16 bits
in ZH, IO_(GPIOR0) ; [0] ; Z points into bitspread table
out IO_(PORTC), r18 ; [1]* output third pixel from previous byte
lpm r16, Z ; [2][3][4] get left 2 pixels
swap ZL ; [5]
lpm r18, Z ; [6][7][0] get right 2 pixels
; expand 16 bits to 32 bits
out IO_(PORTC), r17 ; [1]* output fourth pixel from previous byte
mov ZL, r16 ; [2] r16 contains left 2 pixels from this byte
andi ZL, 0b11110000 ; [3] duplicate upper nibble
mov ZH, ZL ; [4]
swap ZH ; [5]
or ZL, ZH ; [6] ZL now contains first pixel from this byte
andi r16, 0b00001111 ; [7] duplicate lower nibble
mov ZH, r16 ; [0]
out IO_(PORTC), ZL ; [1]* output first pixel from this byte
swap ZH ; [2]
or r16, ZH ; [3] r16 now contains second pixel from this byte
mov r17, r18 ; [4] r18 contains upper 2 pixels from this byte
andi r18, 0b11110000 ; [5] duplicate upper nibble
mov ZH, r18 ; [6]
swap ZH ; [7]
or r18, ZH ; [0] r18 now contains third pixel from this byte
out IO_(PORTC), r16 ; [1]* output second pixel from this byte
andi r17, 0b00001111 ; [2] duplicate lower nibble
mov ZH, r17 ; [3]
swap ZH ; [4]
or r17, ZH ; [5] r17 now contains fourth pixel from this byte
.endr
; finish up last 2 pixels from last byte, restore registers
short_nop3 ; [6][7][0]
out IO_(PORTC), r18 ; [1]* output third pixel from last byte
pop r18 ; [2][3]
in r16, IO_(GPIOR1) ; [4]
ldi ZL, pm_lo8(9b) ; [5]
out IO_(GPIOR1), ZL ; [6]
short_nop2 ; [7][0]
out IO_(PORTC), r17 ; [1]* output fourth pixel from last byte
; finish restoring registers and blank video
in r17, IO_(GPIOR2) ; [2]
ldi ZL, pm_hi8(9b) ; [3]
out IO_(GPIOR2), ZL ; [4]
short_nop3 ; [5][6][7]
clrnf ZL ; [0]
out IO_(PORTC), ZL ; [1]*
sbrc linenum, 0 ; rewind bitmap ptr every other line
sbiw X, 20
; restore SREG and X, save new bitmap ptr
out IO_(SREG), isr_tmp
movw Z, X
movw X, vptr ; restore previous X value
movw vptr, Z ; save updated bitmap ptr
jmp linehandler_end
; Cycles until first PORTC write: 17
.global linehandler_160x100_mono
rjmp framehandler
linehandler_160x100_mono:
in isr_tmp, IO_(SREG) ; [0] save SREG
dec linenum ; [1]
bst linenum, 0 ; [2] every other line, rewind bitmap ptr
rjmp .linehandler_20_bytes_per_line_mono ; [3][4]
; Cycles until first PORTC write: 17
.global linehandler_160x200_mono
rjmp framehandler
linehandler_160x200_mono:
in isr_tmp, IO_(SREG) ; [0] save SREG
dec linenum ; [1]
clt ; [2] T flag indicates if vertical resolution should be halved
short_nop2 ; [3][4]
.linehandler_20_bytes_per_line_mono:
short_nop3 ; [5][6][7]
movw Z, vptr ; [0]
movw vptr, r16 ; [1] use vptr to save two high registers
.rept 20
ld r16, Z+ ; [2][3] get 8 pixels
clr r17 ; [4]
sbrc r16, 6 ; [5]
ori r17, 0b00001111 ; [6]
sbrc r16, 7 ; [7]
ori r17, 0b11110000 ; [0]
out IO_(PORTC), r17 ; [1]* output two pixels
short_nop2 ; [2][3]
clr r17 ; [4]
sbrc r16, 4 ; [5]
ori r17, 0b00001111 ; [6]
sbrc r16, 5 ; [7]
ori r17, 0b11110000 ; [0]
out IO_(PORTC), r17 ; [1]* output two pixels
short_nop2 ; [2][3]
clr r17 ; [4]
sbrc r16, 2 ; [5]
ori r17, 0b00001111 ; [6]
sbrc r16, 3 ; [7]
ori r17, 0b11110000 ; [0]
out IO_(PORTC), r17 ; [1]* output two pixels
short_nop2 ; [2][3]
clr r17 ; [4]
sbrc r16, 0 ; [5]
ori r17, 0b00001111 ; [6]
sbrc r16, 1 ; [7]
ori r17, 0b11110000 ; [0]
out IO_(PORTC), r17 ; [1]* output two pixels
.endr
; blank video
clrnf r17 ; [0]
nop3 ; [1][2][3]
nop3 ; [5][6][7]
out IO_(PORTC), r17 ; [1]*
; restore registers
movw r16, vptr
brtc 2f ; if T is set, rewind the bitmap ptr to the start of the line
sbiw Z, 20
2: movw vptr, Z
out IO_(SREG), isr_tmp
jmp linehandler_end
; 40x25 text mode. Hardcoded to ROM font and white-on-black. vscroll has no effect.
; Useful for split-screen modes.
; Cycles until first PORTC write: 25
.global linehandler_40x25_basictext
rjmp framehandler
linehandler_40x25_basictext:
9: movw Z, vptr ; [0]
movw vptr, X ; [1] use vptr to save previous X value
movw X, Z ; [2] so we can use X to point into the name table
in isr_tmp, IO_(SREG) ; [3]
dec linenum ; [4]
; compute tilemap pointer high byte for this row
; (does not take vscroll into account)
ldi ZL, 7 ; [5]
and ZL, linenum ; [6]
ldi ZH, hi8(amscii_font_8x8) ; [7]
add ZH, ZL ; [0]
; cache it in GPIOR0
out IO_(GPIOR0), ZH ; [1]
; save r16
out IO_(GPIOR1), r16 ; [2]
short_nop5 ; [3][4][5][6][7]
; prep for the first character
ld ZL, X+ ; [0][1] get first character (2 cycles)
lpm ZL, Z ; [2][3][4] get 8 pixels for first character (3 cycles)
ldi ZH, hi8(bitspreadtable+(256*15)) ; [5] Z now points into bitspread table (1 cycle)
; loop (16 cycles per character)
.rept 39
lpm r16, Z ; [6][7][0] get right 8 pixels from bitspread table (3 cycles)
out IO_(PORTC), r16 ; [1]* output left 8 pixels (1 cycle)
swap ZL ; [2] select upper nibble (1 cycle)
lpm r16, Z ; [3][4][5] get left 8 pixels from bitspread table (3 cycles)
ld ZL, X+ ; [6][7] get next character (2 cycles)
in ZH, IO_(GPIOR0) ; [0] Z points into tilemap (1 cycle)
out IO_(PORTC), r16 ; [1]* output right 8 pixels (1 cycle)
lpm ZL, Z ; [2][3][4] get 8 pixels for character (3 cycles)
ldi ZH, hi8(bitspreadtable+(256*15)) ; [5] Z now points into bitspread table (1 cycle)
.endr
; tidy up the last character
lpm r16, Z ; [6][7][0] get left 8 pixels from bitspread table (3 cycles)
out IO_(PORTC), r16 ; [1]* output left 8 pixels (1 cycle)
swap ZL ; [2] select upper nibble (1 cycle)
lpm ZH, Z ; [3][4][5] get right 8 pixels from bitspread table (3 cycles)
; restore r16 and GPIOR1
in r16, IO_(GPIOR1) ; [6]
ldi ZL, pm_lo8(9b) ; [7]
out IO_(GPIOR1), ZL ; [0]
out IO_(PORTC), ZH ; [1]* output right 8 pixels (1 cycle)
; blank video
short_nop2 ; [2][3]
short_nop2 ; [4][5]
in ZH, IO_(GPIOR0) ; [6]
cpi ZH, hi8(amscii_font_8x8) ; [7] set Z flag if this was the 8th for
clrnf ZL ; [0]
out IO_(PORTC), ZL ; [1]*
; unless this was the 8th row, rewind X back to the start of the line
breq 1f
sbiw X, 40
; restore registers, save new vptr
1: movw Z, X
movw X, vptr ; restore X register
movw vptr, Z ; save new vptr
out IO_(SREG), isr_tmp ; restore flags
jmp linehandler_end
; ; use the spare cycles until the next shift register strobe to pop registers and restore RAMPZ
; bld r17, 0 ; [6]
; out IO_(RAMPZ), r17 ; [7]
; in r16, IO_(GPIOR1) ; [0]
; out IO_(PORTC), ZH ; [1]* output right 8 pixels (1 cycle)
; in r17, IO_(GPIOR2) ; [2]
; ; restore proper values to GPIOR1/GPIOR2 and blank video
; ldi ZL, pm_lo8(9b) ; [3]
; out IO_(GPIOR1), ZL ; [4]
; ldi ZL, pm_hi8(9b) ; [5]
; out IO_(GPIOR2), ZL ; [6]
; clrnf ZL ; [7]
; nop ; [0]
; out IO_(PORTC), ZL ; [1]* blank video
; unless this was the 8th row, rewind X back to the start of the line
; in ZH, IO_(GPIOR0)
; lds ZL, tilemap_hi
; cpse ZH, ZL
; sbiw X, 40
; restore registers, save new vptr
; .linehandler_40x25_text_common_end2:
; movw Z, X
; movw X, vptr ; restore X register
; movw vptr, Z ; save new vptr
; out IO_(SREG), isr_tmp ; restore flags
; lhret
.section .text
.end
|
74hc595/Amethyst
| 2,898
|
system/minio_decimal.S
|
; Minimal functions for printing 8- and 16-bit integers as signed or
; unsigned decimal.
.text
.global mio_d8
mio_d8:
tst r24
brpl mio_u8
push r28
mov r28, r24
neg r28
ldi r24, '-'
lds ZL, mio_putc
lds ZH, mio_putc+1
icall
rjmp .mio_u8
.global mio_u8
mio_u8:
push r28
mov r28, r24
.mio_u8:
cpi r28, 10
brlo .ones
cpi r28, 100
brlo .tens
.hundreds_u8:
ldi r24, '/'
1: inc r24
subi r28, 100
brsh 1b
lds ZL, mio_putc
lds ZH, mio_putc+1
icall
subi r28, -100
.tens:
ldi r24, '/'
2: inc r24
subi r28, 10
brsh 2b
lds ZL, mio_putc
lds ZH, mio_putc+1
icall
subi r28, -10
.ones:
mov r24, r28
subi r24, -'0'
pop r28
lds ZL, mio_putc
lds ZH, mio_putc+1
ijmp
.global mio_d16
mio_d16:
tst r25
breq mio_u8 ; defer to 8-bit function if <= 255
brpl .mio_u16 ; nothing to do if already positive
; otherwise, print minus sign and take two's complement of value
com r25
neg r24
sbci r25, -1
push r24
push r25
ldi r24, '-' ; print minus sign
lds ZL, mio_putc
lds ZH, mio_putc+1
icall
pop r25
pop r24
rjmp mio_d16
.global mio_u16
mio_u16:
; defer to 8-bit function if <= 255
tst r25
breq mio_u8
.mio_u16:
push r28
push r29
movw r28, r24
ldi r25, hi8(1000)
cpi r28, lo8(1000)
cpc r29, r25
brlo .hundreds_u16
ldi r25, hi8(10000)
cpi r28, lo8(10000)
cpc r29, r25
brlo .thousands
.tenthousands:
ldi r24, '/'
3: inc r24
subi r28, lo8(10000)
sbci r29, hi8(10000)
brsh 3b
lds ZL, mio_putc
lds ZH, mio_putc+1
icall
subi r28, lo8(-10000)
sbci r29, hi8(-10000)
.thousands:
ldi r24, '/'
4: inc r24
subi r28, lo8(1000)
sbci r29, hi8(1000)
brsh 4b
lds ZL, mio_putc
lds ZH, mio_putc+1
icall
subi r28, lo8(-1000)
sbci r29, hi8(-1000)
.hundreds_u16:
ldi r24, '/'
5: inc r24
subi r28, lo8(100)
sbci r29, hi8(100)
brsh 5b
lds ZL, mio_putc
lds ZH, mio_putc+1
icall
subi r28, lo8(-100)
sbci r29, hi8(-100)
pop r29
rjmp .tens
|
74hc595/Amethyst
| 1,970
|
system/app_launch.S
|
; This function does not return, so it doesn't care about clobbering the
; caller-saved registers.
; Much of the implementation is adapted from libgcc's __do_clear_bss and
; __do_copy_data.
#include <avr/io.h>
.text
.global app_launch
app_launch:
cli ; interrupts must be reenabled by the app
clr r1 ; make sure the zero register is clear
; get entry point
movw Z, r24
lpm r8, Z+ ; entry point low byte
lpm r9, Z+ ; entry point high byte
; get data load start
lpm r10, Z+ ; data load start address low byte
lpm r11, Z+ ; data load start address middle byte
lpm r0, Z+ ; data load start address high byte
adiw Z, 1 ; skip padding byte
; get data end
lpm r12, Z+ ; data end address low byte
lpm r13, Z+ ; data end address high byte
; get bss end
lpm r14, Z+ ; bss end address low byte
lpm r15, Z+ ; bss end address high byte
; copy data from flash to RAM
ldi XL, lo8(__app_data_start)
ldi XH, hi8(__app_data_start)
out _SFR_IO_ADDR(RAMPZ), r0
movw Z, r10
rjmp .copy_data_start
.copy_data_loop:
elpm r0, Z+
st X+, r0
.copy_data_start:
cp XL, r12 ; compare current address with end address
cpc XH, r13
brne .copy_data_loop
; clear bss
rjmp .clear_bss_start
.clear_bss_loop:
st X+, r1
.clear_bss_start:
cp XL, r14
cpc XH, r15
brne .clear_bss_loop
; clear SREG and reset stack/frame pointers
out _SFR_IO_ADDR(SREG), r1
out _SFR_IO_ADDR(RAMPZ), r1
ldi YL, lo8(__stack)
ldi YH, hi8(__stack)
out _SFR_IO_ADDR(SPL), YL
out _SFR_IO_ADDR(SPH), YH
; off we go!
movw Z, r8
ijmp
|
74hc595/Amethyst
| 14,584
|
system/isrs.S
|
#include <avr/io.h>
#include "videodefs.h"
#include "asm_macros.inc"
.global keymatrixrows
.global burst
.global raster_int_scanline
.global raster_int
.comm keymatrixrows, 8
.comm keymatrixhandler_lo, 1
.comm keymatrixcol, 1
.comm raster_int_scanline, 1
.comm raster_int, 2
; In order to support receiving data from the USART without visual corruption,
; we switch between interrupt driven (during vblank) and polling (during active
; video, once per hblank).
; Received bytes are placed into a user-supplied circular queue.
; The implementation is highly optimized for performance. Thus, the receive
; buffer must be 256 bytes in size and must be aligned to a 256 byte boundary.
; This allows the head and tail indexes to require only one byte.
; The implementation distinguishes between "empty" and "full" conditions by
; always leaving one cell in the queue free. Thus, if head == tail, the buffer
; is empty.
; This also allows the implementation to be completely lock-free (i.e. does not
; require any atomic operations that require explicitly disabling/re-enabling
; interrupts).
; As an added bonus, the implementation does not affect the SREG flags.
.global recvbuf_tail
.global recvbuf_head
.global recvbuf_hi
.comm recvbuf_head, 1 ; or low byte of async rx callback
.comm recvbuf_tail, 1 ; or high byte of async rx callback
.comm recvbuf_hi, 1 ; if bit 7 is set, interpret head/tail as a callback function ptr
.section .jumptables
; NOP slide to synchronize the CPU with the shift register phase.
; This code should be reached via an `ijmp` with TCNT2 as the lower byte of the
; jump address. (TCNT2 will be in the range [0,7].)
; Put this table as high up in memory as we can.
.balign 512
colorburst_sync:
nop
nop
nop
nop
nop
nop
nop
; Emit a pulse for the length of the colorburst
ldi ZL, 0
sts UDR0, ZL ; emit low-going pulse for 16 bit times (8 colorburst cycles)
sts UDR0, ZL
movw Z, zsav ; restore regs
reti
; keymatrixhandler jump destinations.
; All code between __kmh_jumptable_start and __kmh_jumptable_end must live on
; the same 256-word page, since we only store the lower byte of the handler
; pointer. The linker script raises an error if this condition is violated.
; .section .bottomtext
.global __kmh_jumptable_start
__kmh_jumptable_start:
.kmh_init:
.kmh_row0:
; read keyboard row inputs and select next column strobe
in ZL, IO_(PINA)
sts keymatrixrows+0, ZL
ldi ZL, 0b11111101
sts keymatrixcol, ZL
ldi ZL, pm_lo8(.kmh_row1)
sts keymatrixhandler_lo, ZL
; preload the colorburst pattern into the shift register
ldi ZL, COLORBURST_PATTERN
out IO_(PORTC), ZL
movw Z, zsav
reti
.kmh_row1:
in ZL, IO_(PINA)
sts keymatrixrows+1, ZL
ldi ZL, 0b11111011
sts keymatrixcol, ZL
ldi ZL, pm_lo8(.kmh_row2)
sts keymatrixhandler_lo, ZL
ldi ZL, COLORBURST_PATTERN
out IO_(PORTC), ZL
movw Z, zsav
reti
.kmh_row2:
in ZL, IO_(PINA)
sts keymatrixrows+2, ZL
ldi ZL, 0b11110111
sts keymatrixcol, ZL
ldi ZL, pm_lo8(.kmh_row3)
sts keymatrixhandler_lo, ZL
ldi ZL, COLORBURST_PATTERN
out IO_(PORTC), ZL
movw Z, zsav
reti
.kmh_row3:
in ZL, IO_(PINA)
sts keymatrixrows+3, ZL
ldi ZL, 0b11101111
sts keymatrixcol, ZL
ldi ZL, pm_lo8(.kmh_row4)
sts keymatrixhandler_lo, ZL
ldi ZL, COLORBURST_PATTERN
out IO_(PORTC), ZL
movw Z, zsav
reti
.kmh_row4:
in ZL, IO_(PINA)
sts keymatrixrows+4, ZL
ldi ZL, 0b11011111
sts keymatrixcol, ZL
ldi ZL, pm_lo8(.kmh_row5)
sts keymatrixhandler_lo, ZL
ldi ZL, COLORBURST_PATTERN
out IO_(PORTC), ZL
movw Z, zsav
reti
.kmh_row5:
in ZL, IO_(PINA)
sts keymatrixrows+5, ZL
ldi ZL, 0b10111111
sts keymatrixcol, ZL
ldi ZL, pm_lo8(.kmh_row6)
sts keymatrixhandler_lo, ZL
ldi ZL, COLORBURST_PATTERN
out IO_(PORTC), ZL
movw Z, zsav
reti
.kmh_row6:
in ZL, IO_(PINA)
sts keymatrixrows+6, ZL
ldi ZL, 0b01111111
sts keymatrixcol, ZL
ldi ZL, pm_lo8(.kmh_row7)
sts keymatrixhandler_lo, ZL
ldi ZL, COLORBURST_PATTERN
out IO_(PORTC), ZL
movw Z, zsav
reti
.kmh_row7:
in ZL, IO_(PINA)
sts keymatrixrows+7, ZL
ldi ZL, COLORBURST_PATTERN
; linehandler sets up colorburst
sts keymatrixcol, ZL
out IO_(PORTC), ZL
; disable the keymatrix interrupt (OVF)
sbic color_video, color_video_bit
ldi ZL, _BV(OCIE1A)|_BV(OCIE1B)
sbis color_video, color_video_bit
ldi ZL, _BV(OCIE1A)
sts TIMSK1, ZL
out IO_(TIFR1), ZL
; if usart async rx is enabled, switch from interrupt mode to polled
sbic usart_async, usart_async_bit
rjmp 1f
movw Z, zsav
reti
; if usart async rx is enabled, switch from interrupt mode to polled
1: ldi ZL, _BV(RXEN1)|_BV(TXEN1) ; clear RXCIE1
sts UCSR1B, ZL
movw Z, zsav
reti
.global __kmh_jumptable_end
__kmh_jumptable_end:
; NOP slide to synchronize the CPU with the shift register phase.
; This code should be reached via an `ijmp` with TCNT2 as the lower byte of the
; jump address. (TCNT2 will be in the range [0,7].)
; Put this table as high up in memory as we can.
.balign 512
shiftreg_sync_delay:
nop ; [0]
nop ; [1]
nop ; [2]
nop ; [3]
nop ; [4]
nop ; [5]
nop ; [6]
ldi ZH, 0 ; [7]
out IO_(PORTC), ZH ; [0]
nop ; [1]
sts UCSR0B, ZH ; [2][3]
in ZL, linehandler_lo ; [4]
in ZH, linehandler_hi ; [5]
ijmp ; [6][7]
.section .bottomtext
; -------------------- UART interrupts --------------------
.global USART1_RX_vect
USART1_RX_vect:
movw zsav, Z
lds ZH, recvbuf_hi ; get upper byte of recvbuf address
lds ZL, recvbuf_head ; get lower byte of recvbuf address
lds isr_tmp, UDR1 ; read incoming byte
; if high bit of recvbuf_hi is set, interpret recvbuf_head and
; recvbuf_tail as a function pointer!
sbrc ZH, 7
rjmp .usart_invoke_async_callback
st Z+, isr_tmp ; store to buffer and advance head ptr
; if head is now equal to tail, buffer was full!
; don't store new head pointer, leave a one-cell gap.
; the received character is effectively dropped.
lds ZH, recvbuf_tail
cpse ZL, ZH
sts recvbuf_head, ZL ; save new head ptr
movw Z, zsav
reti
.usart_invoke_async_callback:
lds ZH, recvbuf_tail
icall
movw Z, zsav
reti
; -------------------- Vertical interrupts --------------------
; Start of vblank: set normal sync pulse polarity and enable colorburst
; *** Does not save SREG! Do not use instructions that modify flags! ***
.global TIMER3_OVF_vect
TIMER3_OVF_vect:
mov zsav, r31 ; need to grab a high register
sbic color_video, color_video_bit
ldi r31, _BV(OCIE1B)
sbis color_video, color_video_bit
ldi r31, 0
sts TIMSK1, r31
ldi r31, _BV(COM1B1)|_BV(COM1B0)|_BV(WGM11) ; normal sync waveform
sts TCCR1A, r31
mov r31, zsav
reti
; End of vblank: enable horizontal interrupts for keymatrix reading and
; active video
; *** Does not save SREG! Do not use instructions that modify flags! ***
.global TIMER3_COMPA_vect
TIMER3_COMPA_vect:
mov zsav, r31 ; need to grab a high register
ldi r31, pm_lo8(.kmh_init)
sts keymatrixhandler_lo, r31
ldi r31, 0b11111110 ; set initial strobe pattern
sts keymatrixcol, r31
sbic color_video, color_video_bit
ldi r31, _BV(TOIE1)|_BV(OCIE1A)|_BV(OCIE1B)
sbis color_video, color_video_bit
ldi r31, _BV(TOIE1)|_BV(OCIE1A)
out IO_(TIFR1), r31 ; ensure interrupt flags are clear
sts TIMSK1, r31 ; enable horizontal interrupt
mov r31, zsav
reti
; Start of vertical sync: invert sync pulse
; Horizontal interrupts are assumed to be disabled
; *** Does not save SREG! Do not use instructions that modify flags! ***
.global TIMER3_COMPB_vect
TIMER3_COMPB_vect:
movw zsav, Z ; need to grab a high register pair
ldi r31, _BV(COM1B1)|_BV(WGM11) ; invert sync waveform
sts TCCR1A, r31
; get address of frame handler (one word before line handler)
in ZL, linehandler_lo
in ZH, linehandler_hi
; perform a dummy read to decrement Z without affecting flags
ld isr_tmp, -Z
; invoke frame handler
ijmp
; -------------------- Horizontal interrupts --------------------
; Sync pulse falling edge: read key matrix row and emit colorburst
.global TIMER1_OVF_vect
TIMER1_OVF_vect:
movw zsav, Z
ldi ZH, pm_hi8(__kmh_jumptable_start) ; 1 cycle
lds ZL, keymatrixhandler_lo ; 2 cycles
ijmp ; 2 cycles
; Sync pulse rising edge: emit colorburst (color modes only)
; *** Does not save SREG! Do not use instructions that modify flags! ***
.global TIMER1_COMPB_vect
TIMER1_COMPB_vect:
movw zsav, Z
; Synchronize to shift register strobe to compensate for interrupt jitter.
ldi ZH, pm_hi8(colorburst_sync)
lds ZL, TCNT2
ijmp
; End of back porch: active video
; *** Does not save SREG! Do not use instructions that modify flags! ***
.global TIMER1_COMPA_vect
TIMER1_COMPA_vect:
movw zsav, Z
; Synchronize to shift register strobe and invoke linehandler
lds ZL, TCNT2
ldi ZH, pm_hi8(shiftreg_sync_delay)
ijmp
.section .linehandlers
.global framehandler_end
framehandler_end:
movw Z, zsav
; Update simple tone generator if bit 4 in PORTB is set
sbis tone_enabled, tone_enabled_bit
reti
in isr_tmp, IO_(SREG)
; Decrement tone duration
lds zsav_lo, tone_duration
dec zsav_lo
sts tone_duration, zsav_lo
breq .tone_off
out IO_(SREG), isr_tmp
reti
.tone_off:
out IO_(SREG), isr_tmp
clrnf isr_tmp
out IO_(OCR0A), isr_tmp
out IO_(OCR0B), isr_tmp
cbi tone_enabled, tone_enabled_bit
reti
.global linehandler_end
linehandler_end:
; gate the shift register clock by enabling the USART
ldi ZL, _BV(TXEN0)
sts UCSR0B, ZL
; PORTC no longer being used for video, set up key matrix column strobes
; (row inputs will be sampled before outputting the colorburst of the
; next line; hblank gives the row inputs time to stabilize)
lds isr_tmp, keymatrixcol
out IO_(PORTC), isr_tmp
; have we registered for a custom handler on this scanline?
lds ZL, raster_int_scanline
cpse linenum, ZL
; if not, just finish up this line normally
rjmp raster_int_end
; otherwise, load the handler pointer and jump to it
lds ZL, raster_int
lds ZH, raster_int+1
ijmp
.global raster_int_end
raster_int_end:
; if usart async rx is enabled, check for incoming serial data
sbis usart_async, usart_async_bit
rjmp .line_end
lds isr_tmp, UCSR1A ; have we received a character?
sbrs isr_tmp, RXC1
rjmp .line_end
lds ZH, recvbuf_hi ; get upper byte of recvbuf address
lds ZL, recvbuf_head ; get lower byte of recvbuf address
lds isr_tmp, UDR1 ; read incoming byte
; if high bit of recvbuf_hi is set, interpret recvbuf_head and
; recvbuf_tail as a function pointer!
sbrc ZH, 7
rjmp .usart_invoke_async_callback2
st Z+, isr_tmp ; store to buffer and advance head ptr
; if head is now equal to tail, buffer was full!
; don't store new head pointer, leave a one-cell gap.
; the received character is effectively dropped.
lds ZH, recvbuf_tail
cpse ZL, ZH
sts recvbuf_head, ZL ; save new head ptr
.line_end:
; restore Z
movw Z, zsav
; check line count; begin vblank if zero
clrnf isr_tmp
cpse linenum, isr_tmp
reti
.last_line_end:
; if this was the last line, disable horizontal interrupts
sts TIMSK1, isr_tmp
; set "new frame" flag
sbi new_frame, new_frame_bit
; if usart async rx is enabled, switch from polled to interrupt read
sbis usart_async, usart_async_bit
reti
.usart1_enable_interrupts:
mov zsav, r31 ; need to grab a high register, ick...
ldi r31, _BV(RXCIE1)|_BV(RXEN1)|_BV(TXEN1)
sts UCSR1B, r31
mov r31, zsav
reti
.usart_invoke_async_callback2:
lds ZH, recvbuf_tail
icall
rjmp .line_end
.text
; callable from C (r24 holds the return value)
.global serial_get_byte
serial_get_byte:
lds ZH, recvbuf_hi
lds ZL, recvbuf_tail
ld r24, Z+ ; get byte and advance tail pointer
sts recvbuf_tail, ZL
ret
|
74hc595/Amethyst
| 14,967
|
apps/forth/forth_words.S
|
#include "forth_opcodes.h"
#include "forth_macros.inc"
#include "forth_defs.h"
.macro dictheader, name
.byte . - lastentry
.set lastentry, .-1
.byte (9f-8f)
8:
.ascii "\name"
9:
.endm
; "Normal" word.
; Interpret: perform execution semantics
; Compile: compile execution semantics
.macro dictentry_colon, name
dictheader "\name"
.word pm(romdict_interpret_bytecode)
.word pm(romdict_compile_bytecode)
.byte (7f-6f)
6:
.endm
; "Compile-only" word.
; Interpret: error
; Compile: perform execution semantics
.macro dictentry_compileonly, name
dictheader "\name"
.word pm(err_compile_only)
.word pm(romdict_interpret_bytecode)
.byte (7f-6f)
6:
.endm
; A "normal" word that uses the return stack, and thus needs to save the return
; address in a temporary link register.
; Interpret: perform execution semantics
; Compile: compile execution semantics
.macro dictentry_colon_rstack, name
dictheader "\name"
.word pm(romdict_interpret_bytecode_linkcall)
.word pm(romdict_compile_bytecode)
.byte (7f-6f)
6:
.endm
; A "compile-only" word that uses the return stack, and thus needs to save the
; return address in a temporary link register.
; Interpret: error
; Compile: perform execution semantics
.macro dictentry_compileonly_rstack, name
dictheader "\name"
.word pm(err_compile_only)
.word pm(romdict_interpret_bytecode_linkcall)
.byte (7f-6f)
6:
.endm
; "Immediate" word.
; Interpret: perform execution semantics
; Compile: perform execution semantics
.macro dictentry_immediate, name
dictheader "\name"
.word pm(romdict_interpret_bytecode)
.word pm(romdict_interpret_bytecode)
.byte (7f-6f)
6:
.endm
; "Interpret-only" word.
; Interpret: perform execution semantics
; Compile: error
.macro dictentry_interpretonly, name
dictheader "\name"
.word pm(romdict_interpret_bytecode)
.word pm(err_interpret_only)
.byte (7f-6f)
6:
.endm
.macro dictentryend
7:
.if (7b-6b) > MAX_ROMDICT_ENTRY_SIZE
.error "ROM dictionary entry is too long"
.endif
.endm
.macro dictentry_interpretation_semantics
.byte (7f-6f)
6:
.endm
.macro dictentry_compilation_semantics
7:
.if (7b-6b) > MAX_ROMDICT_ENTRY_SIZE
.error "ROM dictionary entry is too long"
.endif
.byte (7f-6f)
6:
.endm
.macro cfunc_semantics, isem, csem
.word pm(\isem)
.word pm(\csem)
6:
.endm
.macro cfunc_immediate, fn
cfunc_semantics \fn, \fn
.endm
.macro cfunc_compile_only fn
cfunc_semantics err_compile_only, \fn
.endm
.macro cfunc_interpret_only fn
cfunc_semantics \fn, err_interpret_only
.endm
; macros for defining words in ROM
.macro op, o
.byte OP_\o
.endm
.macro opx, o
.byte OP_ext
.byte OPX_\o
.endm
.macro l8, n
.byte OP_lit8, \n
.endm
.macro l16, lsb, msb
.byte OP_lit16, \lsb, \msb
.endm
.macro laddr, addr
.byte OP_lit16, lo8(\addr), hi8(\addr)
.endm
.macro ccall, fn
op ccall
.word pm(\fn)
.endm
.macro enter_compile_mode
op minus1
op cstorebitshi
.byte FORTH_STATE_MASK
.byte HIGHADDR(forth_flags)
.endm
.macro exit_compile_mode
op zero
op cstorebitshi
.byte FORTH_STATE_MASK
.byte HIGHADDR(forth_flags)
.endm
; export the name token of a ROM word
.macro export_xt, name
.global xt_of_\name
.equ xt_of_\name, 0xC000+.-romdict
.endm
; convert LFA to NFA
.global lfa_to_nfa
lfa_to_nfa:
adiw r24, 1
ret
; get flags
.global ramdict_lfa_to_flags
ramdict_lfa_to_flags:
adiw r24, 1 ; get NFA
movw Z, r24
ld r24, Z ; get flags
andi r24, 0b11100000 ; mask off name length
ret
; set flags
.global ramdict_word_set_flags
ramdict_word_set_flags:
adiw r24, 1 ; get NFA
movw Z, r24
ld r24, Z ; get flags/namelength
andi r24, 0b00011111 ; clear old flags
andi r22, 0b11100000
or r24, r22 ; store new flags
st Z, r24
ret
; get name from LFA as a forth string (addr/len pair)
.global romdict_lfa_to_name
romdict_lfa_to_name:
adiw r24, 1 ; get NFA
movw Z, r24
lpm r24, Z+ ; get name length/flags
andi r24, 0b00011111 ; mask off flags
ldi r25, 0x80 ; set ROM bit
movw r22, Z ; address of first character in name
ret
.global ramdict_lfa_to_name
ramdict_lfa_to_name:
adiw r24, 1 ; get NFA
movw Z, r24
ld r24, Z+ ; get name length/flags
andi r24, 0b00011111 ; mask off flags
clr r25 ; clear ROM bit
movw r22, Z ; address of first character in name
ret
; convert LFA to code field address
; (ROM words only; RAM words don't have a code field)
.global romdict_lfa_to_cfa
romdict_lfa_to_cfa:
adiw r24, 1 ; get NFA
movw Z, r24
lpm ZL, Z ; get name length/flags
andi ZL, 0b00011111 ; mask off flags
inc ZL ; add 1 to length so we skip the length/flags byte
add r24, ZL ; advance past name
adc r25, r1
ret
; convert LFA to DFA (RAM words only)
.global ramdict_lfa_to_dfa
ramdict_lfa_to_dfa:
adiw r24, 1 ; get NFA
movw Z, r24
ld ZL, Z ; get name length/flags
andi ZL, 0b00011111 ; mask off flags
inc ZL ; add 1 to length so we skip the length/flags byte
add r24, ZL ; advance past name
adc r25, r1
ret
; convert LFA to LFA of next entry (returning NULL if last entry)
.global romdict_lfa_link
romdict_lfa_link:
movw Z, r24
lpm ZL, Z
1: tst ZL
brne 2f
clr r24
clr r25
ret
2: sub r24, ZL
sbc r25, r1
ret
; convert LFA to LFA of next entry in RAM (returning NULL if last entry)
.global ramdict_lfa_link
ramdict_lfa_link:
movw Z, r24
ld ZL, Z
rjmp 1b
.section .progmem.forth
.set lastentry, .
.global romdict
romdict:
; Default behavior for uninitialized child words.
dictentry_colon " "
dictentryend
; Addresses of AVR IO registers
; Requires about 1.5K of flash space, so this is optional.
; #include "hwregs.words"
; generate dictionary entries for standard opcodes
#undef X
#define X(opnum,str,props,asmid,enumid,visibility) \
.if ((visibility) & OP_VISIBLE) $ \
.if ((visibility) & OP_COMPILEONLY) $ \
.if ((visibility) & OP_USES_RSTACK) $ \
dictentry_compileonly_rstack str $ .byte (opnum) $ dictentryend $ \
.else $ \
dictentry_compileonly str $ .byte (opnum) $ dictentryend $ \
.endif $ \
.else $ \
.if ((visibility) & OP_USES_RSTACK) $ \
dictentry_colon_rstack str $ .byte (opnum) $ dictentryend $ \
.else $ \
dictentry_colon str $ .byte (opnum) $ dictentryend $ \
.endif $ \
.endif $ \
.endif $
OPCODES
; generate dictionary entries for extended opcodes
#undef X
#define X(opnum,str,props,asmid,enumid,visibility) \
.if ((visibility) & OP_VISIBLE) $ \
.if ((visibility) & OP_COMPILEONLY) $ \
dictentry_compileonly str $ .byte OP_ext, (opnum) $ dictentryend $ \
.else $ \
dictentry_colon str $ .byte OP_ext, (opnum) $ dictentryend $ \
.endif $ \
.endif $
EXT_OPCODES
;-------------------------------------------------------------------------------
; Immediate words for interacting with the interpretaer
;-------------------------------------------------------------------------------
dictheader "COLD"
cfunc_immediate forth_cold_start
dictentryend
dictheader "WARM"
cfunc_immediate forth_warm_start
dictentryend
;-------------------------------------------------------------------------------
; Forth aliases for VM opcodes
;-------------------------------------------------------------------------------
dictentry_colon "FALSE"
op zero
dictentryend
dictentry_colon "TRUE"
op minus1
dictentryend
; this implementation can always emit, always return true
dictentry_colon "EMIT?"
op minus1
dictentryend
dictentry_colon "CELLS"
op twostar
dictentryend
dictentry_colon_rstack "I"
op rfetch
dictentryend
dictentry_colon "CELL+"
op twoplus
dictentryend
dictentry_colon "CHAR+"
op oneplus
dictentryend
dictentry_colon_rstack "UNLOOP"
op twordrop
dictentryend
dictentry_colon "NOT"
op eq0
dictentryend
dictentry_colon "D>S"
op drop
dictentryend
dictentry_colon "LFA>NFA"
op oneplus
dictentryend
dictentry_colon "NFA>LFA"
op oneminus
dictentryend
; S>DU ( n -- d ) unsigned expand single cell into double cell
; i.e. just push a zero
dictentry_colon "S>DU"
op zero
dictentryend
; COUNT ( addr1 -- addr2 u ) convert counted string to forth string
dictentry_colon "COUNT"
op cfetchplus
dictentryend
; alias for :NONAME
dictentry_colon ":["
opx noname
dictentryend
; does nothing (multiplies TOS by 1)
dictentry_colon "CHARS"
dictentryend
; does nothing (this implementation does not have any alignment restrictions)
dictentry_colon "ALIGN"
dictentryend
; does nothing (this implementation does not have any alignment restrictions)
dictentry_colon "ALIGNED"
dictentryend
;-------------------------------------------------------------------------------
; Inlined words; aliases for short VM opcode sequences (typically 2 or 3 bytes)
;-------------------------------------------------------------------------------
dictentry_colon "0<>"
op eq0
op invert
dictentryend
dictentry_colon "0<="
op gt0
op invert
dictentryend
dictentry_colon "0>="
op lt0
op invert
dictentryend
dictentry_colon "<>"
op eq
op invert
dictentryend
dictentry_colon "<="
op gt
op invert
dictentryend
dictentry_colon ">="
op lt
op invert
dictentryend
dictentry_colon "U<="
op ugt
op invert
dictentryend
dictentry_colon "U>="
op ult
op invert
dictentryend
dictentry_colon "M-"
op negate
opx mplus
dictentryend
; I' ( -- n ) limit of current DO loop
dictentry_colon_rstack "I'"
op rfetchlitoffset
.byte 3
dictentryend
; J ( -- n ) index of outer DO loop
dictentry_colon_rstack "J"
op rfetchlitoffset
.byte 5
dictentryend
; J' ( -- n ) limit of outer DO loop
dictentry_colon_rstack "J'"
op rfetchlitoffset
.byte 7
dictentryend
dictentry_colon_rstack "K"
op rfetchlitoffset
.byte 9
dictentryend
dictentry_colon_rstack "K'"
op rfetchlitoffset
.byte 11
dictentryend
dictentry_colon "BL"
l8 ' '
dictentryend
dictentry_colon "SPACE"
op emitlit
.byte ' '
dictentryend
dictentry_colon "CR"
op emitlit
.byte '\n'
dictentryend
dictentry_colon "PAGE"
op emitlit
.byte '\f'
dictentryend
dictentry_colon "?"
op fetch
opx dot
dictentryend
dictentry_colon "U?"
op fetch
opx udot
dictentryend
dictentry_colon "C?"
op cfetch
opx dot
dictentryend
; .. ( n1 n2 -- ) print n1 followed by n2 using .
dictentry_colon ".."
op swap
opx dot
opx dot
dictentryend
; U.. ( u1 u2 -- ) print u1 followed by u2 using U.
dictentry_colon "U.."
op swap
opx udot
opx udot
dictentryend
; DH. ( ud1 -- ) print double-cell number as 8 hex digits (with leading zeros)
dictentry_colon "DH."
op hdot
op hdot
dictentryend
dictentry_colon "BLANK"
l8 ' '
op fill
dictentryend
dictentry_colon "ERASE"
op zero
op fill
dictentryend
dictentry_colon "<#"
op zero
.byte OP_cstorelithi, HIGHADDR(forth_hld)
dictentryend
; [ - exit compile mode. This is an immediate word.
dictentry_compileonly "["
exit_compile_mode
dictentryend
; ] - enter compile mode. This is (currently) an immediate word.
dictentry_immediate "]"
enter_compile_mode
dictentryend
; STATE ( -- flag ) leave true flag if in compile mode
dictentry_colon "STATE@"
op cfetchbitshi
.byte FORTH_STATE_MASK
.byte HIGHADDR(forth_flags)
dictentryend
dictentry_colon "BINARY"
l8 2
.byte OP_cstorelithi, HIGHADDR(forth_base)
dictentryend
dictentry_colon "DECIMAL"
l8 10
.byte OP_cstorelithi, HIGHADDR(forth_base)
dictentryend
dictentry_colon "HEX"
l8 16
.byte OP_cstorelithi, HIGHADDR(forth_base)
dictentryend
dictentry_colon "QUIT"
laddr FE_QUIT
op throw
dictentryend
dictentry_colon "ABORT"
op minus1
op throw
dictentryend
dictentry_colon "DEFER@"
opx tobody
op fetch
dictentryend
dictentry_colon "DEFER!"
opx tobody
op store
dictentryend
;-------------------------------------------------------------------------------
; These words provide access to what Forth traditionally calls "user variables"
;-------------------------------------------------------------------------------
; NOTE: this word returns a *byte* address, must use C@
dictentry_colon "BASE"
laddr forth_base
dictentryend
; NOTE: this word returns a *byte* address, must use C@
dictentry_colon ">IN"
laddr forth_inputpos
dictentryend
; NOTE: this word returns a *byte* address, must use C@
; value is a nonnegative offset from start of pictured numeric output buffer
dictentry_colon "HLD"
laddr forth_hld
dictentryend
dictentry_colon "LATEST"
laddr forth_latest
dictentryend
dictentry_colon "CP"
laddr forth_cp
dictentryend
; "DP" is a more standard Forth word, here it's a synonym for CP.
dictentry_colon "DP"
laddr forth_cp
dictentryend
dictentry_colon "CP0"
laddr forth_cp0
dictentryend
; "DP0" is a more standard Forth word, here it's a synonym for CP0
dictentry_colon "DP0"
laddr forth_cp0
dictentryend
dictentry_colon "NP0"
.byte OP_fetchlithi, HIGHADDR(forth_np0)
dictentryend
dictentry_colon "NP"
laddr forth_np
dictentryend
; Maximum RAM address available for name space. Memory past this point is
; reserved for the screen buffer, stacks, Forth runtime, and system.
dictentry_colon "NPMAX"
.byte OP_fetchlithi, HIGHADDR(forth_npmax)
dictentryend
dictentry_colon "RP0"
laddr forth_rp0
dictentryend
dictentry_colon_rstack "RP@"
.byte OP_fetchlit, lo8(RSP), hi8(RSP)
dictentryend
dictentry_colon_rstack "RP!"
.byte OP_storelit, lo8(RSP), hi8(RSP)
dictentryend
dictentry_colon "SP0"
laddr forth_sp0
dictentryend
; PAD returns a location just past the pictured numeric output buffer.
dictentry_colon "PAD"
.byte OP_fetchlithi, HIGHADDR(forth_hld0)
l8 FORTH_HOLD_BUFFER_SIZE
op plus
dictentryend
; Address where RAM begins. AVR RAM starts at 0x0100.
dictentry_colon "MINMEM"
laddr 0x0100
dictentryend
; Address where available RAM ends. Memory past this point is reserved for
; the stacks, the Forth runtime, and the system.
dictentry_colon "MAXMEM"
laddr forth_pmax
dictentryend
; /EE ( -- u ) size of EEPROM
dictentry_colon "/EE"
laddr E2END+1
dictentryend
#include "controlstructures.words"
#include "defining.words"
#include "compiling.words"
#include "parsing.words"
#include "block.words"
#include "bcd.words"
#include "bytepair.words"
#include "iovec.words"
#include "random.words"
#include "video.words"
#include "console.words"
#include "keyboard.words"
#include "debug.words"
#include "special.words"
.global romdict_end
.equ romdict_end, lastentry
;-------------------------------------------------------------------------------
; Environment queries
;-------------------------------------------------------------------------------
.set lastentry, .
.global environment
environment:
.macro enventry, name
dictentry_colon \name
.endm
.macro enventryend
op minus1
dictentryend
.endm
#include "environment.words"
.global environment_end
.equ environment_end, lastentry
|
74hc595/Amethyst
| 104,801
|
apps/forth/forth_opcodes_2.S
|
#include "forth_opcodes.h"
#include "forth_macros.inc"
#include "forth_defs.h"
#include "spi.h"
; ?DUP ( n -- 0 | n n ) duplicate TOS if non-zero
ext_opcode_qdup:
tstw TOS
breq 1f
pushd
1: rnext
; -ROT ( n1 n2 n3 -- n3 n1 n2 ) push top element down to 3rd position
ext_opcode_nrot:
movw TMP, TOS
ld TOSL, DSP
ldd TOSH, DSP+1
ldd IR, DSP+2
st DSP, IR
ldd IR, DSP+3
std DSP+1, IR
std DSP+2, TMPL
std DSP+3, TMPH
rnext
; TUCK ( n1 n2 -- n2 n1 n2 ) copy top item below second item
ext_opcode_tuck:
movw TMP, TOS ; save n2
ld r20, DSP ; save n1
ldd r21, DSP+1
pushd ; duplicate n2 ( -- n1 n2 n2 )
st DSP, r20 ; store n1 where n2 was
std DSP+1, r21
std DSP+2, TMPL ; store n2 where n1 was
std DSP+3, TMPH
rnext
; PICK ( xu...x1 x0 u -- xu...x1 x0 xu ) replace u with xu
ext_opcode_pick:
lsl TOSL ; multiply TOS by cell size
rol TOSH
movw Z, DSP
add ZL, TOSL ; add cell offset to stack pointer
adc ZH, TOSH
ld TOSL, Z ; get value from stack
ldd TOSH, Z+1
rnext
; ROLL ( xu xu-1 ... x0 u -- xu-1 ... x0 xu ) rotate u+1 items on top of stack
ext_opcode_roll:
tstw TOS ; skip if TOS=0
breq 2f
movw Z, DSP ; get stack pointer
ld TMPL, Z+ ; get the "replacer" value
ld TMPH, Z+
1: ld r20, Z ; get the value to be replaced
ldd r21, Z+1
st Z+, TMPL
st Z+, TMPH
movw TMP, r20 ; replacee now becomes the replacer
sbiw TOS, 1
brne 1b
st DSP, r20
std DSP+1, r21
2: popd ; drop count
rnext
; 2SWAP ( x1 x2 x3 x4 -- x3 x4 x1 x2 )
; x4 - TOS (r25:24) -> DSP+3:DSP+2
; x3 - DSP+1:DSP -> DSP+5:DSP+4
; x2 - DSP+3:DSP+2 -> TOS (r25:r24)
; x1 - DSP+5:DSP+4 -> DSP+1:DSP
ext_opcode_twoswap:
ld TMPL, DSP ; get x3
ldd TMPH, DSP+1
ldd r20, DSP+2 ; get x2
ldd r21, DSP+3
ldd r18, DSP+4 ; get x1
ldd r19, DSP+5
std DSP+2, TOSL ; store x4
std DSP+3, TOSH
std DSP+4, TMPL ; store x3
std DSP+5, TMPH
movw TOS, r20 ; store x2
st DSP, r18 ; store x1
std DSP+1, r19
rnext
; 2OVER ( x1 x2 x3 x4 -- x1 x2 x3 x4 x1 x2 )
ext_opcode_twoover:
pushd
ldd TOSL, DSP+6 ; push x1
ldd TOSH, DSP+7
pushd
ldd TOSL, DSP+6 ; push x2
ldd TOSH, DSP+7
rnext
; 2ROT ( x1 x2 x3 x4 x5 x6 -- x3 x4 x5 x6 x1 x2 )
; x6 - TOS (r25:r24) -> DSP+3:DSP+2
; x5 - DSP+1:DSP -> DSP+5:DSP+4
; x4 - DSP+3:DSP+2 -> DSP+9:DSP+8
; x3 - DSP+5:DSP+4 -> DSP+7:DSP+6
; x2 - DSP+7:DSP+6 -> TOS (r25:r24)
; x1 - DSP+9:DSP+8 -> DSP+1:DSP
ext_opcode_tworot:
ldd TMPL, DSP+8 ; get x1
ldd TMPH, DSP+9
ldd r20, DSP+6 ; get x2
ldd r21, DSP+7
ldd r18, DSP+4 ; get x3
ldd r19, DSP+5
std DSP+8, r18 ; store x3
std DSP+9, r19
ldd r18, DSP+2 ; get x4
ldd r19, DSP+3
std DSP+6, r18 ; store x4
std DSP+7, r19
ld r18, DSP ; get x5
ldd r19, DSP+1
std DSP+4, r18 ; store x5
std DSP+5, r19
std DSP+2, TOSL ; store x6
std DSP+3, TOSH
st DSP, TMPL ; store x1
std DSP+1, TMPH
movw TOS, r20 ; store x2
rnext
; 2SELECT ( true-d false-d flag -- d ) IF 2DROP ELSE 2NIP THEN
; pop flag from stack, if zero, discard second stack item leaving false-n,
; if nonzero, drop top of stack, leaving true-n
; like the ternary operator in other languages, but does not short-circuit
; n1 n2 n3 n4 -- n1 n2 .. .. 2DROP
; n1 n2 n3 n4 | -- .. .. n3 n4 2NIP
ext_opcode_twoselect:
tstw TOS
popd
brne 1f
ld TMPL, DSP
ldd TMPH, DSP+1
adiw DSP, 4
st DSP, TMPL
std DSP+1, TMPH
rnext
1: drop2
rnext
; C>S ( c -- n ) sign-extend byte in TOS to word width
ext_opcode_signextend:
clr TOSH
sbrc TOSL, 7
ser TOSH
rnext
; MIN ( n1 n2 -- n ) keep smaller of top two items on stack
ext_opcode_min:
nip
cp TOSL, TMPL ; is TOS < TMP?
cpc TOSH, TMPH
brlt 1f ; if so, TOS is smallest, keep it
movw TOS, TMP ; otherwise, move TMP to TOS
1: rnext
; MAX ( n1 n2 -- n ) keep larger of top two items on stack
ext_opcode_max:
nip
cp TMPL, TOSL ; is TMP < TOS?
cpc TMPH, TOSH
brlt 1f ; if so, TOS is largest, keep it
movw TOS, TMP ; otherwise, move TMP to TOS
1: rnext
; UMIN ( u1 u2 -- u ) keep smaller of top two items on stack, unsigned
ext_opcode_umin:
nip
cp TOSL, TMPL ; is TOS < TMP?
cpc TOSH, TMPH
brlo 1f ; if so, TOS is smallest, keep it
movw TOS, TMP ; otherwise, move TMP to TOS
1: rnext
; MAX ( u1 u2 -- u ) keep larger of top two items on stack, unsigned
ext_opcode_umax:
nip
cp TMPL, TOSL ; is TMP < TOS?
cpc TMPH, TOSH
brlo 1f ; if so, TOS is largest, keep it
movw TOS, TMP ; otherwise, move TMP to TOS
1: rnext
; WITHIN ( n1|u1 n2|u2 n3|u3 -- flag ) is n2 <= n1 < n3?
; the reference implementation (that works for signed and unsigned values) is:
; : WITHIN ( test low high -- flag ) OVER - >R - R> U< ;
; in C syntax, this is:
; within(test,low,high) { return (uint16_t)(test-low) < (uint16_t)(high-low); }
ext_opcode_within:
; upper limit is already in r25:r24
nip ; lower limit in r23:r22
ld r20, DSP+ ; test value in r21:r20
ld r21, DSP+
sub r20, TMPL ; compute (test-low)
sbc r21, TMPH
sub TOSL, TMPL ; compute (high-low)
sbc TOSH, TMPH
cp r20, TOSL
cpc r21, TOSH
brlo 1f
movw TOS, ZERO
rnext
1: movw TOS, TRUE
rnext
; LSHIFT ( n1 u -- n2 ) logical shift left by u bits
ext_opcode_lshift:
nip
rjmp 2f
1: lsl TMPL
rol TMPH
2: dec TOSL
brpl 1b
movw TOS, TMP
rnext
; RSHIFT ( u1 u -- u2 ) logical shift right by u bits
ext_opcode_rshift:
nip
rjmp 2f
1: lsr TMPH
ror TMPL
2: dec TOSL
brpl 1b
movw TOS, TMP
rnext
; ARSHIFT ( n1 u -- n2 ) arithetic shift right by u bits
ext_opcode_arshift:
nip
rjmp 2f
1: asr TMPH
ror TMPL
2: dec TOSL
brpl 1b
movw TOS, TMP
rnext
; C+! ( c c-addr -- ) add c to byte at address
ext_opcode_caddstore:
movw Z, TOS
ld TMPL, Z
popd
add TMPL, TOSL
st Z, TMPL
popd
rnext
; CBIT@ ( c c-addr -- c ) test bits in byte at address
ext_opcode_cbittest:
movw Z, TOS
ld TMPL, Z
popd
and TOSL, TMPL
clr TOSH
rnext
; CBIC! ( c c-addr -- ) clear bits in byte at address
ext_opcode_cbitclear:
movw Z, TOS
ld TMPL, Z
popd
com TOSL
and TMPL, TOSL
st Z, TMPL
popd
rnext
; CBIS! ( c c-addr -- ) set bits in byte at address
ext_opcode_cbitset:
movw Z, TOS
ld TMPL, Z
popd
or TMPL, TOSL
st Z, TMPL
popd
rnext
; CXOR! ( c c-addr -- ) flip bits in byte at address (xor)
ext_opcode_cbitflip:
movw Z, TOS
ld TMPL, Z
popd
eor TMPL, TOSL
st Z, TMPL
popd
rnext
; S>D ( n -- d ) sign-extend single cell value to double cell
ext_opcode_stod:
pushd ; duplicate TOS
lsl TOSH ; get sign bit
movw TOS, ZERO ; clear TOS
sbc TOSL, ZEROL ; invert TOS if sign bit was set
sbc TOSH, ZEROH
rnext
; D0= ( xd -- flag ) check if double-cell is equal to zero
; r25:r24:r23:r22 = xd
ext_opcode_deq0:
nip
or TOSH, TOSL
or TOSH, TMPH
or TOSH, TMPL
breq .dflag_true
movw TOS, ZERO
rnext
; D0<> ( xd -- flag ) check if double-cell is not equal to zero
; r25:r24:r23:r22 = xd
ext_opcode_dne0:
nip
or TOSH, TOSL
or TOSH, TMPH
or TOSH, TMPL
brne .dflag_true
movw TOS, ZERO
rnext
; D= ( xd1 xd2 -- flag ) compare two double-cells for equality
; r25:r24:r23:r22 = xd1
; r21:r20:r19:r18 = xd2
ext_opcode_deq:
ld TMPL, DSP+ ; byte 0 (LSB) of xd2
ld TMPH, DSP+ ; byte 1 of xd2
ld r20, DSP+ ; byte 2 of xd1
ld r21, DSP+ ; byte 3 (MSB) of xd1
ld r18, DSP+ ; byte 0 (LSB) of xd1
ld r19, DSP+ ; byte 1 of xd1
cp TMPL, r18
cpc TMPH, r19
cpc TOSL, r20
cpc TOSH, r21
breq .dflag_true
movw TOS, ZERO
rnext
; D<> ( xd1 xd2 -- flag ) compare two double-cells for inequality
; r25:r24:r23:r22 = xd1
; r21:r20:r19:r18 = xd2
ext_opcode_dne:
ld TMPL, DSP+ ; byte 0 (LSB) of xd2
ld TMPH, DSP+ ; byte 1 of xd2
ld r20, DSP+ ; byte 2 of xd1
ld r21, DSP+ ; byte 3 (MSB) of xd1
ld r18, DSP+ ; byte 0 (LSB) of xd1
ld r19, DSP+ ; byte 1 of xd1
cp TMPL, r18
cpc TMPH, r19
cpc TOSL, r20
cpc TOSH, r21
brne .dflag_true
movw TOS, ZERO
rnext
; D0< ( xd -- flag ) is xd less than zero?
; r25:r24:r23:r22 = xd
ext_opcode_dlt0:
nip
tst TOSH
brmi .dflag_true
movw TOS, ZERO
rnext
; D0>= ( xd -- flag ) is xd greater than or equal to zero?
; r25:r24:r23:r22 = xd
ext_opcode_dge0:
nip
tst TOSH
brpl .dflag_true
movw TOS, ZERO
rnext
.dflag_true:
movw TOS, TRUE
rnext
; D0> ( xd -- flag ) is xd greater than zero? (signed comparison)
; r25:r24:r23:r22 = xd
ext_opcode_dgt0:
nip
cp ZERO, TMPL
cpc ZERO, TMPH
cpc ZERO, TOSL
cpc ZERO, TOSH
brlt .dflag_true
movw TOS, ZERO
rnext
; D0<= ( xd -- flag ) is xd less than or equal to zero? (signed comparison)
; r25:r24:r23:r22 = xd
ext_opcode_dle0:
nip
cp ZERO, TMPL
cpc ZERO, TMPH
cpc ZERO, TOSL
cpc ZERO, TOSH
brge .dflag_true
movw TOS, ZERO
rnext
; D< ( xd1 xd2 -- flag ) is xd1 less than xd2? (signed)
ext_opcode_dlt:
ld TMPL, DSP+ ; byte 0 (LSB) of xd2
ld TMPH, DSP+ ; byte 1 of xd2
ld r20, DSP+ ; byte 2 of xd1
ld r21, DSP+ ; byte 3 (MSB) of xd1
ld r18, DSP+ ; byte 0 (LSB) of xd1
ld r19, DSP+ ; byte 1 of xd1
cp r18, TMPL
cpc r19, TMPH
cpc r20, TOSL
cpc r21, TOSH
brlt .dflag_true
movw TOS, ZERO
rnext
; D>= ( xd1 xd2 -- flag ) is xd1 greater than or equal to than xd2? (signed)
ext_opcode_dge:
ld TMPL, DSP+ ; byte 0 (LSB) of xd2
ld TMPH, DSP+ ; byte 1 of xd2
ld r20, DSP+ ; byte 2 of xd1
ld r21, DSP+ ; byte 3 (MSB) of xd1
ld r18, DSP+ ; byte 0 (LSB) of xd1
ld r19, DSP+ ; byte 1 of xd1
cp r18, TMPL
cpc r19, TMPH
cpc r20, TOSL
cpc r21, TOSH
brge .dflag_true
movw TOS, ZERO
rnext
; D> ( xd1 xd2 -- flag ) is xd1 greater than xd2? (signed)
ext_opcode_dgt:
ld TMPL, DSP+ ; byte 0 (LSB) of xd2
ld TMPH, DSP+ ; byte 1 of xd2
ld r20, DSP+ ; byte 2 of xd1
ld r21, DSP+ ; byte 3 (MSB) of xd1
ld r18, DSP+ ; byte 0 (LSB) of xd1
ld r19, DSP+ ; byte 1 of xd1
cp TMPL, r18
cpc TMPH, r19
cpc TOSL, r20
cpc TOSH, r21
brlt .dflag_true2
movw TOS, ZERO
rnext
; D<= ( xd1 xd2 -- flag ) is xd1 less than or equal to xd2? (signed)
ext_opcode_dle:
ld TMPL, DSP+ ; byte 0 (LSB) of xd2
ld TMPH, DSP+ ; byte 1 of xd2
ld r20, DSP+ ; byte 2 of xd1
ld r21, DSP+ ; byte 3 (MSB) of xd1
ld r18, DSP+ ; byte 0 (LSB) of xd1
ld r19, DSP+ ; byte 1 of xd1
cp TMPL, r18
cpc TMPH, r19
cpc TOSL, r20
cpc TOSH, r21
brge .dflag_true2
movw TOS, ZERO
rnext
; DU< ( xd1 xd2 -- flag ) is xd1 less than xd2? (unsigned)
ext_opcode_dult:
ld TMPL, DSP+ ; byte 0 (LSB) of xd2
ld TMPH, DSP+ ; byte 1 of xd2
ld r20, DSP+ ; byte 2 of xd1
ld r21, DSP+ ; byte 3 (MSB) of xd1
ld r18, DSP+ ; byte 0 (LSB) of xd1
ld r19, DSP+ ; byte 1 of xd1
cp r18, TMPL
cpc r19, TMPH
cpc r20, TOSL
cpc r21, TOSH
brlo .dflag_true2
movw TOS, ZERO
rnext
.dflag_true2:
movw TOS, TRUE
rnext
; DU>= ( xd1 xd2 -- flag ) is xd1 greater than or equal to xd2? (unsigned)
ext_opcode_duge:
ld TMPL, DSP+ ; byte 0 (LSB) of xd2
ld TMPH, DSP+ ; byte 1 of xd2
ld r20, DSP+ ; byte 2 of xd1
ld r21, DSP+ ; byte 3 (MSB) of xd1
ld r18, DSP+ ; byte 0 (LSB) of xd1
ld r19, DSP+ ; byte 1 of xd1
cp r18, TMPL
cpc r19, TMPH
cpc r20, TOSL
cpc r21, TOSH
brsh .dflag_true2
movw TOS, ZERO
rnext
; DU> ( xd1 xd2 -- flag ) is xd1 greater than xd2? (unsigned)
ext_opcode_dugt:
ld TMPL, DSP+ ; byte 0 (LSB) of xd2
ld TMPH, DSP+ ; byte 1 of xd2
ld r20, DSP+ ; byte 2 of xd1
ld r21, DSP+ ; byte 3 (MSB) of xd1
ld r18, DSP+ ; byte 0 (LSB) of xd1
ld r19, DSP+ ; byte 1 of xd1
cp TMPL, r18
cpc TMPH, r19
cpc TOSL, r20
cpc TOSH, r21
brlo .dflag_true2
movw TOS, ZERO
rnext
; DU<= ( xd1 xd2 -- flag ) is xd1 less than or equal to xd2? (unsigned)
ext_opcode_dule:
ld TMPL, DSP+ ; byte 0 (LSB) of xd2
ld TMPH, DSP+ ; byte 1 of xd2
ld r20, DSP+ ; byte 2 of xd1
ld r21, DSP+ ; byte 3 (MSB) of xd1
ld r18, DSP+ ; byte 0 (LSB) of xd1
ld r19, DSP+ ; byte 1 of xd1
cp TMPL, r18
cpc TMPH, r19
cpc TOSL, r20
cpc TOSH, r21
brsh .dflag_true2
movw TOS, ZERO
rnext
; D2* ( xd1 -- xd2 ) double-cell logical shift left
; TOSH is byte 3 (MSB)
; TOSL is byte 2 (low byte of high word)
; [DSP+1] is byte 1 (high byte of low word)
; [DSP] is byte 0 (LSB)
ext_opcode_dtwostar:
ld TMPL, DSP
ldd TMPH, DSP+1
lsl TMPL
rol TMPH
rol TOSL
rol TOSH
st DSP, TMPL
std DSP+1, TMPH
rnext
; D2/ ( xd1 -- xd2 ) double-cell arithmetic shift right
ext_opcode_dtwoslash:
ld TMPL, DSP
ldd TMPH, DSP+1
asr TOSH
ror TOSL
ror TMPH
ror TMPL
st DSP, TMPL
std DSP+1, TMPH
rnext
; DU2/ ( xd1 -- xd2 ) double-cell logical shift right
ext_opcode_dutwoslash:
ld TMPL, DSP
ldd TMPH, DSP+1
lsr TOSH
ror TOSL
ror TMPH
ror TMPL
st DSP, TMPL
std DSP+1, TMPH
rnext
; DABS ( xd1 -- ud1 ) absolute value of double-cell
ext_opcode_dabs:
tst TOSH
brpl 1f ; don't negate if positive
; DNEGATE ( xd1 -- xd2 ) twos complement of double-cell
ext_opcode_dnegate:
ld TMPL, DSP
ldd TMPH, DSP+1
com TOSH
com TOSL
com TMPH
neg TMPL
sbci TMPH, -1
sbci TOSL, -1
sbci TOSH, -1
st DSP, TMPL
std DSP+1, TMPH
1: rnext
; DMIN ( d1 d2 -- d3 ) keep smaller of d1 and d2
ext_opcode_dmin:
movw r20, TOS
ld r18, DSP+
ld r19, DSP+
ld TOSL, DSP+
ld TOSH, DSP+
ld TMPL, DSP
ldd TMPH, DSP+1
cp r18, TMPL
cpc r19, TMPH
cpc r20, TOSL
cpc r21, TOSH
brlt 1f
rnext
1: movw TOS, r20
st DSP, r18
std DSP+1, r19
rnext
; DMAX ( d1 d2 -- d3 ) keep larger of d1 and d2
ext_opcode_dmax:
movw r20, TOS
ld r18, DSP+
ld r19, DSP+
ld TOSL, DSP+
ld TOSH, DSP+
ld TMPL, DSP
ldd TMPH, DSP+1
cp TMPL, r18
cpc TMPH, r19
cpc TOSL, r20
cpc TOSH, r21
brlt 1f
rnext
1: movw TOS, r20
st DSP, r18
std DSP+1, r19
rnext
; M+ ( d1 n1 -- d2 ) add single cell to double cell
ext_opcode_mplus:
movw r18, TOS ; get the single-cell value
movw r20, TOS ; and sign-extend it the way gcc does:
lsl r20 ; - get msb into carry flag
sbc r20, r20 ; - if carry clear, r20 and r21 are zeroed
sbc r21, r21 ; - if carry set, r20 and r21 will contain 0xFFFF
popd
ld TMPL, DSP ; now the double-cell value is in r25-r22
ldd TMPH, DSP+1
add TMPL, r18 ; add single-cell to low word
adc TMPH, r19
adc TOSL, r20
adc TOSH, r21
st DSP, TMPL
std DSP+1, TMPH
rnext
; D+ ( xd1 xd2 -- xd3 ) add xd1 and xd2 giving xd3
; r25:r24:r23:r22 = xd2 and xd3
; r21:r20:r19:r18 = xd1
ext_opcode_dplus:
ld TMPL, DSP+ ; byte 0 (LSB) of xd2
ld TMPH, DSP+ ; byte 1 of xd2
ld r20, DSP+ ; byte 2 of xd1
ld r21, DSP+ ; byte 3 (MSB) of xd1
ld r18, DSP ; byte 0 (LSB) of xd1
ldd r19, DSP+1 ; byte 1 of xd1
add TMPL, r18
adc TMPH, r19
adc TOSL, r20 ; upper word of sum is already in TOS
adc TOSH, r21
st DSP, TMPL ; store lower word of sum back to stack
std DSP+1, TMPH
rnext
; D- ( xd1 xd2 -- xd3 ) subtract xd1 and xd2 giving xd3
; r25:r24:r23:r22 = xd1 and xd3
; r21:r20:r19:r18 = xd2
ext_opcode_dminus:
movw r20, TOS ; bytes 2 and 3 (MSB) of xd2
ld r18, DSP+ ; byte 0 (LSB) of xd2
ld r19, DSP+ ; byte 1 of xd2
ld TOSL, DSP+ ; byte 2 of xd1
ld TOSH, DSP+ ; byte 3 (MSB) of xd1
ld TMPL, DSP ; byte 0 (LSB) of xd1
ldd TMPH, DSP+1 ; byte 1 of xd1
sub TMPL, r18
sbc TMPH, r19
sbc TOSL, r20 ; upper word of difference is already in TOS
sbc TOSH, r21
st DSP, TMPL ; store lower word of difference back to stack
std DSP+1, TMPH
rnext
; * ( n1 n2 -- n ) 16x16=16 multiplication
ext_opcode_star:
nip
; same code emitted by gcc
movw r20, TOS
mul r20, TMPL
movw TOS, r0
mul r20, TMPH
add TOSH, r0
mul r21, TMPL
add TOSH, r0
clr ZEROL
clr ZEROH
rnext
; */ ( n1 n2 n3 -- n4 ) compute (n1*n2) producing a double cell immediate,
; then divide by n3. (signed)
ext_opcode_starslash:
tstw TOS ; don't divide by zero
breq .div0
callc_prologue
ld TMPL, DSP+ ; LSB of n2
ld TMPH, DSP+ ; MSB of n2
ld r20, DSP+ ; LSB of n1
ld r21, DSP+ ; MSB of n1
call starslash
callc_epilogue
; */MOD ( n1 n2 n3 -- n4 n5 ) compute (n1*n2) producing a double-cell intermediate,
; then divide by n3, returning remainder as n4 and quotient as n5
ext_opcode_starslashmod:
tstw TOS ; don't divide by zero
breq .div0
callc_prologue
ld TMPL, DSP+ ; LSB of n2
ld TMPH, DSP+ ; MSB of n2
ld r20, DSP ; LSB of n1
ldd r21, DSP+1 ; MSB of n1
call starslashmod
st DSP, TMPL
std DSP+1, TMPH
callc_epilogue
; /MOD ( n1 n2 -- rem quot )
ext_opcode_slashmod:
tstw TOS ; don't divide by zero
breq .div0
movw TMP, TOS ; move divisor to TMP
ld TOSL, DSP ; get dividend into TOS
ldd TOSH, DSP+1
callc_prologue
call __divmodhi4 ; remainder in r24:r25, quotient in r22:r23
st DSP, TOSL ; put remainder into second item on stack
std DSP+1, TOSH
movw TOS, TMP ; put quotient into TOS
callc_epilogue
; U/MOD ( u1 u2 -- rem quot )
ext_opcode_uslashmod:
tstw TOS ; don't divide by zero
breq .div0
movw TMP, TOS ; move divisor to TMP
ld TOSL, DSP ; get dividend into TOS
ldd TOSH, DSP+1
callc_prologue
call __udivmodhi4 ; remainder in r24:r25, quotient in r22:r23
st DSP, TOSL ; put remainder into second item on stack
std DSP+1, TOSH
movw TOS, TMP ; put quotient into TOS
callc_epilogue
.div0:
throw FE_DIVIDE_BY_ZERO
; UM/MOD ( ud u1 -- u2 u3 ) divide double-cell ud by single-cell u1, giving
; single-cell remainder u2 and single-cell quotient u3. All values unsigned.
ext_opcode_umslashmod:
tstw TOS ; don't divide by zero
breq .div0
callc_prologue
ld TMPL, DSP+ ; byte 2 of ud
ld TMPH, DSP+ ; byte 3 (MSB) of ud
ld r20, DSP ; byte 0 (LSB) of ud
ldd r21, DSP+1 ; byte 1 of ud
call umslashmod
st DSP, TMPL
std DSP+1, TMPH
callc_epilogue
; SM/REM ( d1 n1 -- n2 n3 ) divide double-cell d1 by single-cell n1 using
; symmetric division (rounding towards zero), giving single-cell remainder n2
; and single-cell quotient n3. All values signed.
ext_opcode_smslashrem:
tstw TOS ; don't divide by zero
breq .div0
callc_prologue
ld TMPL, DSP+ ; byte 2 of d1
ld TMPH, DSP+ ; byte 3 (MSB) of d1
ld r20, DSP ; byte 0 (LSB) of d1
ldd r21, DSP+1 ; byte 1 of d1
call smslashrem
st DSP, TMPL
std DSP+1, TMPH
callc_epilogue
; FM/MOD ( d1 n1 -- n2 n3 ) divide double-cell d1 by single-cell n1 using
; floored division (rounding towards negative infinity), giving single-cell
; remainder n2 and single-cell quotient n3. All values signed.
ext_opcode_fmslashmod:
tstw TOS ; don't divide by zero
breq .div0
callc_prologue
ld TMPL, DSP+ ; byte 2 of d1
ld TMPH, DSP+ ; byte 3 (MSB) of d1
ld r20, DSP ; byte 0 (LSB) of d1
ldd r21, DSP+1 ; byte 1 of d1
call fmslashmod
st DSP, TMPL
std DSP+1, TMPH
callc_epilogue
; / ( n1 n2 -- n1/n2 ) 16/16=16 signed division
ext_opcode_slash:
tstw TOS ; don't divide by zero
breq .div0
movw TMP, TOS ; move divisor to TMP
popd ; get dividend into TOS
callc_prologue
call __divmodhi4
movw TOS, TMP ; move quotient to TOS
callc_epilogue
; MOD ( n1 n2 -- n1%n2 ) 16%16=16 signed remainder after division.
; Result has the sign of the dividend (n1).
ext_opcode_mod:
tstw TOS ; don't divide by zero
breq .div0a
movw TMP, TOS ; move divisor to TMP
popd ; get dividend into TOS
callc_prologue
call __divmodhi4 ; leaves remainder in TOS
callc_epilogue
; U/ ( u1 u2 -- u1/u2 ) 16/16=16 unsigned division
ext_opcode_uslash:
tstw TOS ; don't divide by zero
breq .div0a
movw TMP, TOS ; move divisor to TMP
popd ; get dividend into TOS
callc_prologue
call __udivmodhi4
movw TOS, TMP ; move quotient to TOS
callc_epilogue
.div0a:
throw FE_DIVIDE_BY_ZERO
; UMOD ( u1 u2 -- u1%u2 ) 16%16=16 unsigned remainder after division.
ext_opcode_umod:
tstw TOS ; don't divide by zero
breq .div0a
movw TMP, TOS ; move divisor to TMP
popd ; get dividend into TOS
callc_prologue
call __udivmodhi4 ; leaves remainder in TOS
callc_epilogue
; M*/ ( d1 n1 +n2 -- d2 ) double-single multiply/divide with triple-cell intermediate
ext_opcode_mstarslash:
tstw TOS ; don't divide by zero
breq .div0a
; n2 is already in r25:r24
ld TMPL, DSP+ ; nip n1 into r23:r22
ld TMPH, DSP+
ld r20, DSP+ ; nip high word of d1 into r21:r20
ld r21, DSP+
ld r18, DSP ; get low word of d1 into r19:r18
ldd r19, DSP+1
callc_prologue
call mstarslash
; put lower word of result back on the stack
st DSP, TMPL
std DSP+1, TMPH
callc_epilogue
; UM*/ ( ud1 u1 u2 -- ud2 ) double-single unsigned multiply/divide with triple-cell intermediate
ext_opcode_umstarslash:
tstw TOS ; don't divide by zero
breq .div0a
; n2 is already in r25:r24
ld TMPL, DSP+ ; nip n1 into r23:r22
ld TMPH, DSP+
ld r20, DSP+ ; nip high word of d1 into r21:r20
ld r21, DSP+
ld r18, DSP ; get low word of d1 into r19:r18
ldd r19, DSP+1
callc_prologue
call umstarslash
; put lower word of result back on the stack
st DSP, TMPL
std DSP+1, TMPH
callc_epilogue
; M* ( n1 n2 -- d ) multiply two single-cell numbers giving signed double-cell result
ext_opcode_mstar:
; __mulhisi3 is an exception to the stanard C calling convention:
; SI:22 = HI:26 * HI:18
callc_prologue ; need to save r27:r26
ld r18, DSP ; LSB of n1
ldd r19, DSP+1 ; MSB of n1
movw r26, TOS
call __mulhisi3
; put lower word of product back on the stack
st DSP, TMPL
std DSP+1, TMPH
callc_epilogue ; restore r27:r26 and clear ZEROL
; UM* ( u1 u2 -- ud ) multiply two unsigned single-cell numbers giving unsigned double-cell result
ext_opcode_umstar:
; __umulhisi3 is an exception to the stanard C calling convention:
; SI:22 = HI:26 * HI:18
callc_prologue ; need to save r27:r26
ld r18, DSP ; LSB of n1
ldd r19, DSP+1 ; MSB of n1
movw r26, TOS
call __umulhisi3
; put lower word of product back on the stack
st DSP, TMPL
std DSP+1, TMPH
callc_epilogue ; restore r27:r26 and clear ZEROL
.fwd_resolve:
callc_0arg_prologue
call here
movw TMP, TOS ; get value of HERE into TMP
callc_0arg_restore
sec
sbc TMPL, TOSL
sbc TMPH, TOSH
brmi .resolve_out_of_range ; fail if displacement is negative
cpse TMPH, ZERO
rjmp .resolve_out_of_range ; fail if displacement >= 256
movw Z, TOS
st Z, TMPL
popd
ret
; >RESOLVE ( addr -- ) resolve forward relative branch from addr to HERE
ext_opcode_resolve:
rcall .fwd_resolve
rnext
.resolve_out_of_range:
throw FE_BRANCH_OUT_OF_RANGE
; <RESOLVE ( addr branch-offset-addr -- ) resolve backward relative branch
ext_opcode_bresolve:
movw TMP, TOS ; get address of dummy branch offset
movw Z, TOS ; and get another copy
popd ; TOS is now address of branch destination
sec
sbc TMPL, TOSL
sbc TMPH, TOSH
brmi .resolve_out_of_range ; fail if displacement is negative
cpse TMPH, ZERO
rjmp .resolve_out_of_range ; fail if displacement >= 256
st Z, TMPL
popd
rnext
; (RAKE) ( -- ) ( R: i*n 0 -- ) resolve LEAVEs in a DO loop
; it's called RAKE because it cleans up the LEAVEs
; i didn't make that up, thank Wonyong Koh (author of hForth) for it
ext_opcode_rake:
pop ZL
pop ZH
tstw Z
breq .rake_done ; check for sentinel value (0)
pushd
movw TOS, Z
rcall .fwd_resolve ; otherwise, resolve branch at that address
rjmp ext_opcode_rake
.rake_done:
rnext
; EXIT ( R: a -- ) pop IP from return stack
; does the same as (EXIT) but is used for returns in the middle of a word.
; the (EXIT) opcode is recognizes as an end-of-word marker by the disassembler
ext_opcode_exit:
jmp opcode_endword
; ; ( -- ) finalize current word definition and return to interpretation state
ext_opcode_semicolon:
; check stack pointers (the ancient Forth term for this is "compiler security")
lds ZL, forth_saved_rsp
lds ZH, forth_saved_rsp+1
rsp_to_tmp
cp ZL, TMPL
cpc ZH, TMPH
brne 2f
lds ZL, forth_saved_dsp
lds ZH, forth_saved_dsp+1
cp ZL, DSPL
cpc ZH, DSPH
breq 1f
throw FE_CTRL_STRUCT_MISMATCH
1: callc_0arg_prologue
call do_semicolon
callc_0arg_epilogue
2: throw FE_RSTACK_IMBALANCE
; ]; ( xt -- ) finish current temporary definition, remove it from the dictionary,
; and execute the xt on the stack pushed by :NONAME/:[, and execute it immediately.
; TODO reduce code duplication here
ext_opcode_execsemicolon:
lds ZL, forth_saved_rsp
lds ZH, forth_saved_rsp+1
rsp_to_tmp
cp ZL, TMPL
cpc ZH, TMPH
brne 1b
lds ZL, forth_saved_dsp
lds ZH, forth_saved_dsp+1
cp ZL, DSPL
cpc ZH, DSPH
breq 3f
throw FE_CTRL_STRUCT_MISMATCH
3: callc_0arg_prologue
call do_semicolon
; forget latest word (but we should still have its xt on the stack from :NONAME)
lds TOSL, forth_latest
lds TOSH, forth_latest+1
call ramdict_forget_lfa
callc_0arg_restore
; now execute the word immediately
jmp opcode_execute
; CH. ( c -- ) write low byte to output device as 2 hexadecimal digits, without
; a trailing space (to allow printing of larger words)
ext_opcode_chdot:
callc_prologue
call mio_x8
popd
callc_epilogue
; U>HEX ( u -- d ) convert TOS to four ASCII characters (0-9A-F) returned on
; the stack as a double-cell.
; Equivalent to: DUP C>HEX SWAP >< C>HEX
ext_opcode_utohex:
mov r20, TOSH ; save high byte
; convert low byte
mov TOSH, TOSL ; copy into high byte
andi TOSH, 0x0F ; high byte will contain ASCII of low nibble
swap TOSL
andi TOSL, 0x0F ; low byte will contain ASCII of high nibble
; convert low nibble to ASCII
ldi TMPL, '0'
cpi TOSH, 10
brlo 1f
ldi TMPL, 'A'-10
1: add TOSH, TMPL
; convert high nibble to ASCII
ldi TMPL, '0'
cpi TOSL, 10
brlo 2f
ldi TMPL, 'A'-10
2: add TOSL, TMPL
; push, then fall through and convert high byte
pushd
mov TOSL, r20
; C>HEX ( c -- u ) convert low byte of TOS to two ASCII characters (0-9A-F)
; in display order (low byte of TOS contains ASCII of high nibble, high byte of
; TOS contains ASCII of low nibble)
; The equivalent of CH. is: C>HEX DUP EMIT >< EMIT
ext_opcode_ctohex:
mov TOSH, TOSL ; copy into high byte
andi TOSH, 0x0F ; high byte will contain ASCII of low nibble
swap TOSL
andi TOSL, 0x0F ; low byte will contain ASCII of high nibble
; convert low nibble to ASCII
ldi TMPL, '0'
cpi TOSH, 10
brlo 1f
ldi TMPL, 'A'-10
1: add TOSH, TMPL
; convert high nibble to ASCII
ldi TMPL, '0'
cpi TOSL, 10
brlo 2f
ldi TMPL, 'A'-10
2: add TOSL, TMPL
rnext
; . ( n -- ) write single-cell number to output device in current base
ext_opcode_dot:
callc_prologue
movw TMP, ZERO ; no width limit
call forth_dot
popd
callc_epilogue
; U. ( u -- ) write unsigned single-cell number to output device in current base
ext_opcode_udot:
callc_prologue
movw TMP, ZERO ; no width limit
call forth_udot
popd
callc_epilogue
; D. ( d -- ) write double-cell number to output device in current base
ext_opcode_ddot:
callc_prologue
nip
movw r20, ZERO ; no width limit
call forth_ddot
popd
callc_epilogue
; UD. ( d -- ) write unsigned double-cell number to output in current base
ext_opcode_uddot:
callc_prologue
nip
movw r20, ZERO ; no width limit
call forth_uddot
popd
callc_epilogue
; .R ( n1 n2 -- ) write single-cell number to output device, right-aligned in
; a field n2 characters wide
ext_opcode_dotr:
callc_prologue
movw TMP, TOS ; move width into tmp
popd ; move value to TOS
call forth_dot
popd
callc_epilogue
; U.R ( u n -- ) write single-cell unsigned number to output device,
; right-aligned in a field n characters wide
ext_opcode_udotr:
callc_prologue
movw TMP, TOS ; move width into tmp
popd ; move value to TOS
call forth_udot
popd
callc_epilogue
; D.R ( d n -- ) write double-cell number to output device, right-aligned in a
; field n characters wide
ext_opcode_ddotr:
callc_prologue
movw r20, TOS ; pop width
popd
nip ; get lower cell into r23:r22
call forth_ddot
popd
callc_epilogue
; LH. ( lh -- ) write byte-pair to output device in current base
ext_opcode_lhdot:
callc_prologue
call forth_lhdot
popd
callc_epilogue
; # ( ud1 -- ud2 ) extract digits to the pictured numeric output buffer
ext_opcode_nums:
callc_prologue
ld TMPL, DSP
ldd TMPH, DSP+1
call forth_extract_digits
st DSP, TMPL
std DSP+1, TMPH
callc_epilogue
; SIGN ( n -- ) add minus sign to pictured numeric output is TOS is negative
ext_opcode_sign:
tstw TOS
popd
brpl 1f
callc_0arg_prologue
ldi TOSL, '-'
call forth_hold
callc_0arg_epilogue
1: rnext
; #> ( ud -- c-addr len ) finalize pictured numeric output string
; Drops the double-cell number on the stack, reverses the contents of the
; pictured numeric output buffer, and pushes its address/length
ext_opcode_numend:
lds ZL, forth_hld0 ; get p.n.o. buffer base address
lds ZH, forth_hld0+1 ; Z points to the beginning of the string
st DSP, ZL ; store string start on stack
std DSP+1, ZH
rcall .forth_finalize_numeric_output
rnext
; void forth_finalize_numeric_output(void) - reverses the contents of the
; pictured numeric output buffer
.global forth_finalize_numeric_output
forth_finalize_numeric_output:
lds ZL, forth_hld0 ; get p.n.o. buffer base address
lds ZH, forth_hld0+1 ; Z points to the beginning of the string
.forth_finalize_numeric_output:
movw r20, X ; save X
lds TOSL, forth_hld ; get length of string
clr TOSH
movw X, Z
add XL, TOSL
adc XH, TOSH ; X points to the end of the string
1: ld TMPL, Z
ld TMPH, -X
st X, TMPL
st Z+, TMPH
cp ZL, XL
cpc ZH, XH
brlo 1b
movw X, r20 ; restore X
ret
; HOLDS ( c-addr len -- ) add string to pictured numeric output string
ext_opcode_holds:
callc_prologue
nip ; nip address into r23:r22
call forth_holds
popd ; drop remaining item on stack
callc_epilogue
; >MARKER ( -- latest cp np np0 ) push dictionary snapshot
; to get the size of name space:
; >MARKER - -ROT 2DROP .
ext_opcode_tomarker:
pushd
lds TOSL, forth_latest
lds TOSH, forth_latest+1
pushd
lds TOSL, forth_cp
lds TOSH, forth_cp+1
pushd
lds TOSL, forth_np
lds TOSH, forth_np+1
pushd
lds TOSL, forth_np0
lds TOSH, forth_np0+1
rnext
; Extended dispatch table aligned to a 256-word (512-byte) boundary.
.align 9
.global vm_ext_dispatch_table
vm_ext_dispatch_table:
create_dispatch_table .ext_opcode_, 256
.align 0
; MARKER> ( latest cp np np0 -- ) restore dictionary snapshot
; just does the inverse of the other one
ext_opcode_markerfrom:
sts forth_np0, TOSL
sts forth_np0+1, TOSH
popd
sts forth_np, TOSL
sts forth_np+1, TOSH
popd
sts forth_cp, TOSL
sts forth_cp+1, TOSH
popd
sts forth_latest, TOSL
sts forth_latest+1, TOSH
popd
rnext
; MARKER, ( latest cp np np0 -- ) compile dictionary snapshot
; into current dictionary entry
ext_opcode_markercomma:
callc_prologue
call comma ; store latest
popd
call comma ; store cp
popd
call comma ; store np
popd
call comma ; store np0
popd
rnext
; EMPTY ( -- ) clear entire dictionary (code space and name space)
ext_opcode_empty:
callc_0arg_prologue
call dict_init
callc_0arg_epilogue
; SHRED ( -- ) deletes name space, giving compiled code access
; to the entire Forth data space region.
; (you'll probably going to want to remember one or more xt's for words in
; code space, so you can actually get that compiled code running)
ext_opcode_shred:
ldi TMPL, lo8(forth_pmax)
ldi TMPH, hi8(forth_pmax)
sts forth_np0, TMPL
sts forth_np0+1, TMPH
sts forth_np, TMPL
sts forth_np+1, TMPH
sts forth_npmax, TMPL
sts forth_npmax+1, TMPH
rnext
; SPACES ( n -- ) write n space characters to output device
ext_opcode_spaces:
callc_prologue
call forth_spaces
popd
callc_epilogue
; KEY? ( -- flag ) return true if a character is available
ext_opcode_keyq:
pushd
callc_prologue
ldi TOSL, 1 ; nonblocking check
lds ZL, mio_getc
lds ZH, mio_getc+1
icall
callc_restore
; extend bool to forth flag
clr TOSH
tst TOSL
brne 1f
rnext
1: movw TOS, TRUE
rnext
; ACCEPT ( addr +n1 -- +n2 ) receive a string of at most +n1 characters
; readline() takes args in this order:
; r25:r24 - buffer address
; r23:r22 - buffer length
ext_opcode_accept:
movw TMP, TOS ; get buffer size into r23:r22
popd ; get buffer address into r25:r24
callc_prologue
call readline
callc_restore ; check if readline returned an error
sbrc TOSH, 7
rjmp 1f
rnext
1: throw FE_USER_INTERRUPT
; REFILL ( -- flag ) fill the input buffer from the current input source
ext_opcode_refill:
pushd
callc_prologue
call forth_refill
clr TOSH ; convert bool to forth flag
cpse TOSL, ZERO
movw TOS, TRUE
rnext
; EVALUATE ( i * x c-addr u -- j * x ) save input source, make the string
; the input source, and interpret. Restore input source afterward.
ext_opcode_evaluate:
movw r20, TOS ; move string length to r21:r20
nip ; nip address into r23:r22
popd ; drop TOS
; don't push a return address if invoked from the text interpreter, i.e.
; make this a tail call
call .was_called_from_text_interpreter
breq 1f
; not invoked from the text interpreter? push IP normally
pushr
1: jmp forth_evaluate_str
; :NONAME ( -- xt ) create a new colon-word with a zero-length name, push its
; execution token, and enter compilation state.
ext_opcode_noname:
pushd ; reserve space on the stack for the xt
movw TOS, ZERO ; name is the empty string
movw TMP, ZERO
ldi r20, FL_COLON ; it's a colon word
callc_prologue
call namespace_create_nonamecheck
; update saved dsp to prevent spurious "control structure mismatch"
sts forth_saved_dsp, DSPL
sts forth_saved_dsp+1, DSPH
rsp_to_z
sts forth_saved_rsp, ZL
sts forth_saved_rsp+1, ZH
; get execution token
lds TOSL, forth_latest
lds TOSH, forth_latest+1
call ramdict_lfa_to_xt
callc_restore
; enter compile mode
lds ZL, forth_flags
sbr ZL, (1<<FF_STATE_BIT)
sts forth_flags, ZL
rnext
; COMP' ( -- ct ) read a name from the input stream and push its compilation token
ext_opcode_comptick:
pushd
callc_prologue
call forth_parse_name
tstw TOS ; check for empty string
breq 1f
call find_ct
; 0 indicates no ct
tstw TOS
breq 2f
callc_epilogue
1: throw FE_ZERO_LENGTH_NAME
2: throw FE_UNDEFINED_WORD
; FIND ( c-addr -- c-addr 0 | xt 1 | xt -1 )
ext_opcode_find:
; convert counted string to addr+len
movw Z, TOS
pushd
callc_prologue
ld TOSL, Z+
movw TMP, Z
clr TOSH
call find_xt
tstw TOS
breq 1f
; found? store xt to second-on-stack
st DSP, TOSL
std DSP+1, TOSH
; immediate or not?
call xt_immediate_flag
1: callc_epilogue
; FIND-NAME ( addr len -- nt|0 ) return name token for word with name
ext_opcode_findname:
nip
callc_prologue
call find_name
callc_epilogue
; FORGET-NAME ( nt -- ) delete word and all words defined after it
ext_opcode_forgetname:
callc_prologue
call forget_name
popd
callc_epilogue
; >BODY ( xt -- addr ) obtain the body address of the word represented by xt
; Behavior is undefined if used on the xt of a non-child word.
ext_opcode_tobody:
; does the xt represent an lfa, or a code address?
mov TMPL, TOSH
andi TMPL, 0b11000000
cpi TMPL, 0b10000000 ; XT_NP0_LFA
brne .xt_is_code
; otherwise, convert xt to lfa
andi TOSH, 0b00111111 ; clear upper bits
lds TMPL, forth_np0
lds TMPH, forth_np0+1
add TOSL, TMPL ; add np0 to offset
adc TOSH, TMPH
callc_prologue
call ramdict_lfa_to_real_body
callc_epilogue
.xt_is_code:
; xt is a code address. the bodies of all child words start with a
; 3-byte (DODOES) call to the parent semantics, followed by the body data.
; so adding 3 gives the address of the word's body data.
adiw TOS, 3
rnext
; SP@ ( -- addr ) push address of stack pointer (before execution of this word)
ext_opcode_spfetch:
movw TMP, DSP
pushd
movw TOS, TMP
rnext
; SP! ( addr -- ) set stack pointer
ext_opcode_spstore:
movw DSP, TOS
rnext
; DEPTH ( -- u ) number of values on the stack (before execution of this word)
ext_opcode_depth:
ldi TMPL, lo8(forth_sp0)
ldi TMPH, hi8(forth_sp0)
sub TMPL, DSPL
sbc TMPH, DSPH
lsr TMPH
ror TMPL
pushd
movw TOS, TMP
rnext
; UNUSED ( -- u ) number of free bytes in dictionary
ext_opcode_unused:
pushd
callc_prologue
call forth_available_memory
callc_epilogue
; PARSE" ( -- addr u ) parse quote-delimited string from input stream
; building block for S" ." ABORT" and others
ext_opcode_parsequote:
pushd
ldi TOSL, '"'
jmp opcode_parse
; PARSE\" ( -- addr u ) parse quote-delimited string from input stream and
; convert escape
ext_opcode_parseslashquote:
pushd
callc_prologue
call parse_escaped_string
; upon return: addr in r23:r22, len in r25:r24
st -DSP, TMPH
st -DSP, TMPL
callc_epilogue
; WORD ( delim -- c-addr ) skip leading delimiters, parse string up to next
; occurrence of delimiter, copy to a transient region as a counted string, and
; push its address
ext_opcode_word:
callc_0arg_prologue ; makes a second copy of delim
call forth_consume_delim
; upon return: addr in r23:r22, len in r25:r24
movw TOS, TSAV
call forth_parse
; too long?
cpi TOSL, FORTH_HOLD_BUFFER_SIZE
cpc TOSH, ZEROH
brsh .too_big_for_tmpbuf
lds ZL, forth_hld0
lds ZH, forth_hld0+1
rjmp .place
.too_big_for_tmpbuf:
callc_restore
throw FE_PARSED_STR_OVERFLOW
; PLACE ( addr1 len dst -- addr2 ) write to memory as a counted string
ext_opcode_place:
movw Z, TOS ; save dest
popd ; TOS is now count
nip ; address in r23:r22
callc_prologue ; meh, need to do this
; dst=Z, src=r23:r22, len=r25:r24
.place:
st Z+, TOSL ; store count
; use memcpy: dst=r25:r24, src=r23:r22, len=r21:r20
movw r20, TOS ; length to r21:r20
movw TOS, Z ; dest address to r25:r24
call memcpy
sbiw TOS, 1 ; return value points at the count
callc_epilogue
; CMOVE ( c-addr1 c-addr2 u -- ) copy u bytes from c-addr1 to c-addr2
; Bytes are copied from lower addresses to higher addresses
ext_opcode_cmove:
tstw TOS
breq .nomove
; need 2 pointers... save IP so we can use X
; (TOS is byte count)
movw XSAV, IP
ld ZL, DSP+ ; Z is destination ptr
ld ZH, DSP+
ld XL, DSP+ ; X is source ptr
ld XH, DSP+
.cmove_fwd:
ld TMPL, X+
st Z+, TMPL
sbiw TOS, 1
brne .cmove_fwd
movw IP, XSAV ; don't forget to restore IP
popd
rnext
.nomove:
; drop args and return
drop3
rnext
; CMOVE> ( c-addr1 c-addr2 u -- ) copy u bytes from c-addr1 to c-addr2
; Bytes are copied from higher addresses to lower addresses
ext_opcode_cmoveup:
tstw TOS
breq .nomove
movw XSAV, IP
ld ZL, DSP+ ; Z is destination ptr
ld ZH, DSP+
ld XL, DSP+ ; X is source ptr
ld XH, DSP+
; advance source/dest pointers to the end of their respective regions
; (count is in TOS)
.cmove_rev:
add ZL, TOSL
adc ZH, TOSH
add XL, TOSL
adc XH, TOSH
1: ld TMPL, -X
st -Z, TMPL
sbiw TOS, 1
brne 1b
movw IP, XSAV ; don't forget to restore IP
popd
rnext
; MOVE ( addr1 addr2 u -- ) copy u bytes from addr1 to addr2
ext_opcode_move:
tstw TOS
breq .nomove
movw XSAV, IP
ld ZL, DSP+ ; Z is destination ptr
ld ZH, DSP+
ld XL, DSP+ ; X is source ptr
ld XH, DSP+
; if src < dest, use CMOVE> otherwise use CMOVE
cp XL, ZL
cpc XH, ZH
brlt .cmove_rev
rjmp .cmove_fwd
; ( x1 x2 x3 x4 -- x2 x1 x3 x4 )
; x4 - TOS (r25:24) -> TOS (r25:r24)
; x3 - DSP+1:DSP -> DSP+1:DSP
; x2 - DSP+3:DSP+2 -> DSP+5:DSP+4
; x1 - DSP+5:DSP+4 -> DSP+3:DSP+2
.swap_2_under:
ldd TMPL, DSP+2
ldd TMPH, DSP+3
ldd r20, DSP+4
ldd r21, DSP+5
std DSP+2, r20
std DSP+3, r21
std DSP+4, TMPL
std DSP+5, TMPH
ret
; >NUMBER ( ud1 addr1 len1 -- ud2 addr2 len2 ) string to number
ext_opcode_tonumber:
; forth_to_number() args:
; r25:r24 - string length
; r23:r22 - string address
; r21:r20 - pointer to double-cell value
; returns:
; r25:r24 - number of chars unconverted
; r23:r22 - address of first unconverted char
; the double-cell value needs to be word-swapped! TODO not great
rcall .swap_2_under
ld TMPL, DSP
ldd TMPH, DSP+1
movw r20, DSP
subi r20, lo8(-2)
sbci r21, hi8(-2)
callc_prologue
call forth_to_number
; write back to stack
st DSP, TMPL
std DSP+1, TMPH
rcall .swap_2_under
1: callc_epilogue
; -TRAILING ( addr u1 -- addr u2 ) delete trailing spaces from string
ext_opcode_dashtrailing:
ld ZL, DSP ; get address of string start
ldd ZH, DSP+1
add ZL, TOSL ; add length to get address of string end
adc ZH, TOSH
tstw TOS ; stop if string is empty
rjmp 2f
1: ld TMPL, -Z ; get character
cpi TMPL, ' ' ; is it a space?
brne 3f ; if so, end
sbiw TOS, 1 ; otherwise, delete character
2: brne 1b
3: rnext
; /STRING ( addr1 u1 n -- addr2 u2 ) delete/add n characters from beginning of
; string. No bounds-checking is performed.
ext_opcode_slashstring:
movw TMP, TOS ; pop n
popd
sub TOSL, TMPL ; adjust length
sbc TOSH, TMPH
ld r20, DSP ; adjust character address
ldd r21, DSP+1
add r20, TMPL
adc r21, TMPH
st DSP, r20
std DSP+1, r21
rnext
; COMPARE ( addr1 len1 addr2 len2 -- n ) compare string 1 and string 2
; this is memcmp(addr1, addr2, len1) if len1==len2, otherwise
; memcmp(addr1, addr2, min(len1,len2)) and if it returns 0 then return -1 if
; len1<len2 or 1 if len1>len2.
; int memcmp(const void *s1, const void *s2, size_t len);
; r25:r24 - s1
; r23:r22 - s2
; r21:r20 - len
ext_opcode_compare:
movw TSAV, ZERO ; prepare the constant 1
inc TSAVL
; move len2 to r21:r20
movw r20, TOS
; nip addr1, len1, and len2 into registers
ld r22, DSP+ ; nip addr2 into r23:r22
ld r23, DSP+
ld r18, DSP+ ; nip len1 into a temp register pair
ld r19, DSP+
ld r24, DSP+ ; nip addr1 into r25:r24
ld r25, DSP+
; are lengths equal?
cp r18, r20
cpc r19, r21
brlt .compare_s1_shorter
brne .compare_s2_shorter
; if lengths equal, return sign of memcmp() result
callc_prologue
call memcmp
callc_restore
tstw TOS
breq 1f ; if zero, just return zero
brmi .compare_return_minus1
.compare_return_plus1:
ldi TOSL, 1
clr TOSH
1: rnext
.compare_return_minus1:
movw TOS, TRUE
rnext
.compare_s1_shorter:
movw r20, r18 ; compare up to length of string1
movw TSAV, TRUE ; return -1 if 2 strings are different
.compare_s2_shorter:
callc_prologue
call memcmp
callc_restore
tstw TOS ; did memcmp return zero?
breq .compare_return_len_of_shorter ; if so, compare lengths
brmi .compare_return_minus1
rjmp .compare_return_plus1
.compare_return_len_of_shorter:
movw TOS, TSAV
rnext
; SEARCH ( addr1 len1 addr2 len2 -- addr3 len3 flag ) search string 1 for string 2
; this is just memmem(), but we need to get the args off the stack and into
; the right registers:
; void *memmem(const void *s1, size_t len1, const void *s2, size_t len2);
; r25:r24 - s1
; r23:r22 - len1
; r21:r20 - s2
; r19:r18 - len2
ext_opcode_search:
movw r18, TOS ; len2 to r19:r18
ld r20, DSP+ ; nip addr2 to r21:r20
ld r21, DSP+
ld r22, DSP ; len1 to r22:r23
ldd r23, DSP+1
ldd r24, DSP+2 ; addr1 to r25:r24
ldd r25, DSP+3
callc_0arg_prologue ; also copy addr1 to TSAV
call memmem
callc_restore
tstw TOS
breq .search_notfound
; found
std DSP+2, TOSL ; store pointer to match start
std DSP+3, TOSH
sub TOSL, TSAVL ; calculate offset from start
sbc TOSH, TSAVH
ld TMPL, DSP
ldd TMPH, DSP+1
sub TMPL, TOSL ; subtract offset from old length to get new length
sbc TMPH, TOSH
st DSP, TMPL ; store number of chars left in string
std DSP+1, TMPH
movw TOS, TRUE ; return true flag
.search_notfound:
; return with 0-flag in TOS and addr1/len1 unchanged
rnext
; ENVIRONMENT? ( addr len -- false | i*x true ) environmental query
ext_opcode_environmentq:
callc_prologue
nip ; nip address into r23:r22
call environment_find
tstw TOS ; if null returned, keep 0 on the stack
breq 1f
jmp opcode_execute ; execute the xt
1: callc_epilogue
; SOURCE ( -- c-addr u ) push address of and number of chars in the input buffer
ext_opcode_source:
pushd
callc_prologue
call forth_inputbuf
callc_restore
pushd
clr TOSH
lds TOSL, forth_inputlen
rnext
; CATCH ( i * x xt -- j * x 0 | i * x n )
ext_opcode_catch:
; drop xt from the stack
movw TMP, TOS ; drop xt from stack
popd
; make sure TOS register value is committed to RAM
pushd
adiw DSP, 2
; push stack pointer value onto return stack
push DSPH
push DSPL
; push current input source
ldi ZL, lo8(forth_inputsrc)
ldi ZH, hi8(forth_inputsrc)
ld r18, Z
push r18
ldd r18, Z+1
push r18
ldd r18, Z+2
push r18
ldd r18, Z+3
push r18
; don't push a return address if invoked from the text interpreter, i.e.
; make this a tail call
call .was_called_from_text_interpreter
breq 1f
; not invoked from the text interpreter? push IP normally
pushr
; push a new exception frame
1: push_exception_frame .catch_exception_handler
; push 0x0001 so the exception handler is invoked even if the word
; returns without throwing
push ZEROH
ldi ZL, 1
push ZL
; now EXECUTE
ser r18 ; tell forth_execute_xt NOT to push a return addr
jmp forth_execute_xt
; DELAY ( u -- ) wait a specific number of frames (1/60 sec intervals)
ext_opcode_delay:
tstw TOS ; do nothing if 0 frames specified
breq 2f
lds TMPL, screen_ptr+1 ; are we in tiny mode?
tst TMPL
brmi 1f
callc_prologue
movw TMP, TOS
ldi r24, lo8(fcon)
ldi r25, hi8(fcon)
callc_prologue
call console_delay
popd
callc_epilogue
1: sbis new_frame, new_frame_bit
rjmp 1b
cbi new_frame, new_frame_bit
sbiw TOS, 1
brne 1b
2: popd
rnext
; (ABORT") ( flag c-addr len -- ) runtime of ABORT"
ext_opcode_abortq:
ldd TMPL, DSP+2
ldd TMPH, DSP+3
or TMPL, TMPH
breq .noabortq
throw FE_ABORTQ
.noabortq:
drop3
rnext
; TEXT ( -- ) switch to 40x25 text mode
ext_opcode_fortycol:
callc_0arg_prologue
call forth_40x25_console
callc_0arg_epilogue
; HTEXT ( -- ) switch to 80x25 text mode
ext_opcode_eightycol:
callc_0arg_prologue
call forth_80x25_console
callc_0arg_epilogue
; CTEXT ( -- ) switch to 40x25 color text mode
ext_opcode_colorfortycol:
callc_0arg_prologue
call forth_40x25_color_console
callc_0arg_epilogue
; +COLOR ( -- ) enable colorburst
ext_opcode_coloron:
sbi color_video, color_video_bit
rnext
; -COLOR ( -- ) disable colorburst
ext_opcode_coloroff:
cbi color_video, color_video_bit
rnext
; (.S) ( -- ) print stack dump
; read byte from input stream to determine format:
; < 0 - signed in current base
; > 0 - unsigned in current base
; = 0 - unsigned hexadecimal
ext_opcode_dumpstack:
; stack pointer in r23:r22
movw TMP, DSP
; format byte in r20
ld r20, IP+
callc_prologue
; forth_dump_stack() preserves TOS
call forth_dump_stack
callc_epilogue
; BYE ( -- ) exit Forth
ext_opcode_bye:
jmp app_quit
; TINY ( i*x -- | R: j*y -- ) clear data stack and enter "tiny" mode:
; - Name space is deleted
; - 16 byte return stack
; - 16 byte data stack
; - No support for exceptions, graphical console, numeric formatting, anything
; that uses the dictionary or runtime
ext_opcode_tiny:
ldi DSPL, lo8(forth_tiny_sp0)
ldi DSPH, hi8(forth_tiny_sp0)
; set high bit of screen_ptr, indicating tiny mode
lds ZL, screen_ptr+1
ori ZL, 0b10000000
sts screen_ptr+1, ZL
rnext
ext_opcode_exittiny:
; clear high bit of screen_ptr
lds ZL, screen_ptr+1
andi ZL, 0b01111111
sts screen_ptr+1, ZL
jmp forth_cold_start
; +INT ( -- ) enable interrupts (i.e. video and keyboard polling)
ext_opcode_sei:
sei
rnext
; -INT ( -- ) disable interrupts (i.e. video and keyboard polling)
; This *will* hang the system if control is returned to the text interpreter
; before interrupts are re-enabled, requiring a hard reset.
; Disabling interrupts frees up the CPU from drawing video, allowing it to be
; 100% utilized for Forth code.
ext_opcode_cli:
cli
rnext
; BEEP ( -- ) simple beep, square wave, 8 frames long
ext_opcode_beep:
callc_0arg_prologue
call console_beep
callc_0arg_epilogue
; PTONE! ( freq duration dutycycle -- ) pulse wave, with given duty cycle
; (0-255, 128=50%), frequency (0-863) and duration in frames (1-255). Execution
; continues immediately, without waiting for the sound to finish.
ext_opcode_ptone:
movw r20, TOS ; get duty cycle into r21:r20
nip ; get duration into r23:r22
rjmp 1f
; TONE! ( freq duration -- ) square wave, with given frequency (0-863) and duration
; in frames (1-255). Execution continues immediately, without waiting for the
; sound to finish.
ext_opcode_tone:
ldi r20, 128 ; 50% duty cycle square wave
movw TMP, TOS ; get duration into r23:r22
1: popd ; get frequency into r25:r24
callc_prologue
call tone
popd
callc_epilogue
; PTONE ( freq duration dutycycle -- ) pulse wave, with given duty cycle
; (0-255, 128=50%), frequency (0-863) and duration in frames (1-255). Pauses
; execution until the sound finishes.
ext_opcode_ptonesync:
movw r20, TOS ; get duty cycle into r21:r20
nip ; get duration into r23:r22
rjmp 1f
; TONE ( freq duration -- ) square wave, with given frequency (0-863) and duration
; in frames (1-255). Pauses execution until the sound finishes.
ext_opcode_tonesync:
ldi r20, 128 ; 50% duty cycle square wave
movw TMP, TOS ; get duration into r23:r22
1: popd ; get frequency into r25:r24
callc_prologue
call tone
popd
callc_restore
1: sbic tone_enabled, tone_enabled_bit ; loop until the tone-enabled bit is cleared
rjmp 1b
rnext
; PNOTE! ( note duration dutycycle -- ) pulse wave, with given duty cycle
; (0-255, 128=50%), MIDI note number (0-127) and duration in frames (1-255).
; Execution continues immediately, without waiting for the sound to finish.
ext_opcode_pnote:
movw r20, TOS ; get duty cycle into r21:r20
nip ; get duration into r23:r22
rjmp 1f
; NOTE! ( note duration -- ) square wave, with MIDI note number (0-127) and duration
; in frames (1-255). Execution continues immediately, without waiting for the
; sound to finish.
ext_opcode_note:
ldi r20, 128 ; 50% duty cycle square wave
movw TMP, TOS ; get duration into r23:r22
1: popd ; get note number into r25:r24
callc_prologue
call note
popd
callc_epilogue
; PNOTE ( note duration dutycycle -- ) pulse wave, with given duty cycle
; (0-255, 128=50%), MIDI note number (0-127) and duration in frames (1-255).
; Pauses execution until the sound finishes.
ext_opcode_pnotesync:
movw r20, TOS ; get duty cycle into r21:r20
nip ; get duration into r23:r22
rjmp 1f
; NOTE ( freq duration -- ) square wave, with MIDI note number (0-127) and duration
; in frames (1-255). Pauses execution until the sound finishes.
ext_opcode_notesync:
ldi r20, 128 ; 50% duty cycle square wave
movw TMP, TOS ; get duration into r23:r22
1: popd ; get frequency into r25:r24
callc_prologue
call note
popd
callc_restore
1: sbic tone_enabled, tone_enabled_bit ; loop until the tone-enabled bit is cleared
rjmp 1b
rnext
; +SOUND ( -- ) enable audio output
ext_opcode_soundon:
callc_0arg_prologue
call audio_init
callc_0arg_epilogue
; -SOUND ( -- ) disable audio output. BEEP, TONE, NOTE, etc. have no effect.
ext_opcode_soundoff:
callc_0arg_prologue
call audio_off
callc_0arg_epilogue
; LOAD ( i*x n -- j*x ) load numbered block
ext_opcode_load:
tstw TOS
brmi .invalidblk
breq .noload
movw TMP, TOS
callc_prologue
call num_blocks
callc_restore
cp TOSL, TMPL
brlo .invalidblk
popd
; don't push a return address if invoked from the text interpreter, i.e.
; make this a tail call (same as with EVALUATE)
call .was_called_from_text_interpreter
breq 1f
; not invoked from the text interpreter? push IP normally
pushr
1: jmp forth_load_block
.invalidblk:
popd
throw FE_INVALID_BLOCK_NUMBER
; 0 LOAD does nothing
.noload:
popd
rnext
; CLS ( -- ) clear screen, reset margins, and return cursor to home
; (Use PAGE or 12 EMIT to clear only the scrolling region.)
ext_opcode_cls:
callc_0arg_prologue
ldi r24, lo8(fcon)
ldi r25, hi8(fcon)
call console_clrhome
callc_0arg_epilogue
; FORM ( -- rows cols ) returns dimensions of console scroll region
ext_opcode_form:
pushd
clr TOSH
lds TOSL, fcon_mbottom
andi TOSL, fcon_bitmask_mbottom
lds TMPL, fcon_mtop
andi TMPL, fcon_bitmask_mtop
sub TOSL, TMPL
inc TOSL
pushd
lds TOSL, fcon_mright
andi TOSL, fcon_bitmask_mright
lds TMPL, fcon_mleft
sub TOSL, TMPL
inc TOSL
rnext
; AT-XY ( col row -- ) set cursor position within scroll region
; console_gotoxy():
; r25:r24 console struct
; r23 x
; r22 y
ext_opcode_atxy:
nip ; get x pos into r22
mov r20, r24 ; get y pos into r20
ldi r24, lo8(fcon)
ldi r25, hi8(fcon)
callc_prologue
call console_gotoscrollxy
callc_restore
popd
rnext
; CURSOR@ ( -- xy ) get absolute cursor position
ext_opcode_getcursor:
pushd
lds TOSL, fcon_cx
andi TOSL, fcon_bitmask_cx
lds TOSH, fcon_cy
andi TOSL, fcon_bitmask_cy
rnext
; CURSOR! ( xy -- ) set absolute cursor position
ext_opcode_setcursor:
mov r22, TOSL ; get x pos into r22
mov r20, TOSH ; get y pos into r20
ldi r24, lo8(fcon)
ldi r25, hi8(fcon)
callc_prologue
call console_gotoxy
callc_restore
popd
rnext
; CURSOR+! ( xy -- ) add xy to cursor position
ext_opcode_movecursor:
mov r22, TOSL ; get x delta into r22
mov r20, TOSH ; get y delta into r20
ldi r24, lo8(fcon)
ldi r25, hi8(fcon)
callc_prologue
call console_movexy
callc_restore
popd
rnext
; WINDOW ( xy wh -- ) set console scrolling region
ext_opcode_window:
movw r22, TOS ; w to r22, h to r23
ld r20, DSP+ ; x to r20
ld r21, DSP+ ; y to r21
ldi TOSL, lo8(fcon)
ldi TOSH, hi8(fcon)
callc_prologue
call console_setmarginrect
callc_restore
popd
rnext
; XY>ADDR ( xy -- addr ) convert screen coordinate xy to pixel address in the
; screen buffer
ext_opcode_xytoaddr:
movw TMP, ZERO ; mul will clobber the zero regs
lds r0, bytesperline ; multiply y coord * bytes per line
mul r0, TOSH
add r0, TOSL ; add x coord
adc r1, TMPL ; will be zero
lds TOSL, screen_ptr ; add screen offset
lds TOSH, screen_ptr+1
add TOSL, r0
adc TOSH, r1
movw ZERO, TMP ; restore zero regs
rnext
; TSETCC ( cc xy -- ) set character (LSB of NOS) and color (MSB of NOS)
; of text cell at xy
ext_opcode_tsetcc:
nip ; get color into TMPH and char into TMPL
movw r20, ZERO ; mul will clobber the zero regs
lds r0, bytesperline ; multiply y coord * bytes per line
mul r0, TOSH
add r0, TOSL ; add x coord
adc r1, r20 ; will be zero
lds ZL, screen_ptr ; add screen offset
lds ZH, screen_ptr+1
add ZL, r0
adc ZH, r1
movw ZERO, r20 ; restore zero regs
st Z, TMPL ; store char
subi ZL, lo8(-1000) ; cell color is 1000 bytes ahead
sbci ZH, hi8(-1000)
ldi TMPL, hi8(bitspreadtable) ; TODO how to do this with one subi?
add TMPH, TMPL
st Z, TMPH ; store color
popd
rnext
; TBOX ( xy wh -- ) draw box in text console using box-drawing characters
; (interior is not filled)
; if w or h is 0, nothing is drawn
; if w is 1, a vertical line is drawn
; if h is 1, a horizontal line is drawn
; the current reverse-video and color (for color console) settings are used
ext_opcode_tbox:
movw r22, TOS ; w to r22, h to r23
ld r20, DSP+ ; x to r20
ld r21, DSP+ ; y to r21
ldi TOSL, lo8(fcon)
ldi TOSH, hi8(fcon)
callc_prologue
call console_box
callc_restore
popd
rnext
; TRECTC ( c xy wh -- ) set color of rectangular area of text buffer
; (color console only)
; no bounds checking is performed
ext_opcode_trectc:
; do nothing if width or height is zero
mov TMPL, TOSL
or TMPL, TOSH
breq .no_rect
ld TMPL, DSP ; x coord
ldd TMPH, DSP+1 ; y coord; color is 25 rows ahead
subi TMPH, -25 ; add 25 to y
ldd r20, DSP+2 ; get color index
ldi r21, hi8(bitspreadtable)
add r20, r21 ; get bitspread table offset
rjmp .rect
; TRECT ( c xy wh -- ) fill rectangular area of screen buffer with byte c
; no bounds checking is performed
ext_opcode_trect:
; do nothing if width or height is zero
mov TMPL, TOSL
or TMPL, TOSH
breq .no_rect
ld TMPL, DSP ; x coord
ldd TMPH, DSP+1 ; y coord
ldd r20, DSP+2 ; get fill value
.rect:
lds r21, bytesperline ; get screen width
lds ZL, screen_ptr ; screen base address
lds ZH, screen_ptr+1
add ZL, TMPL ; add x coord
adc ZH, ZEROH
mul r21, TMPH ; multiply y by screen width to get byte offset
add ZL, r0 ; add y byte offset
adc ZH, r1
clr ZEROL ; mul clobbers zero regs, restore them
clr ZEROH
sub r21, TOSL ; subtract rect width from screen width, giving byteskip btwn lines
; loop
; TOSL - width
; TOSH - y counter
; TMPL - x counter
; r21 - number of bytes to skip to get to next row
; r20 - value to fill with
.yloop: mov TMPL, TOSL
.xloop: st Z+, r20
dec TMPL
brne .xloop
; end of x loop
add ZL, r21
adc ZH, ZEROL
dec TOSH
brne .yloop
.no_rect:
drop3
rnext
; TRECTCC ( cc xy wh -- ) set rectangular area of color console to character
; and color. no bounds checking is performed
ext_opcode_trectcc:
; do nothing if width or height is zero
mov TMPL, TOSL
or TMPL, TOSH
breq .no_rect
ld TMPL, DSP ; x coord
ldd TMPH, DSP+1 ; y coord
ldd r20, DSP+2 ; get fill character
lds r21, bytesperline ; get screen width
lds ZL, screen_ptr ; screen base address
lds ZH, screen_ptr+1
add ZL, TMPL ; add x coord
adc ZH, ZEROH
mul r21, TMPH ; multiply y by screen width to get byte offset
add ZL, r0 ; add y byte offset
adc ZH, r1
clr ZEROL ; mul clobbers zero regs, restore them
clr ZEROH
sub r21, TOSL ; subtract rect width from screen width, giving byteskip btwn lines
ldd TMPH, DSP+3 ; get fill color
ldi TMPL, hi8(bitspreadtable)
add TMPH, TMPL ; get bitspread table offset
; loop
; TOSL - width
; TOSH - y counter
; TMPL - x counter
; r21 - number of bytes to skip to get to next row
; r20 - character to fill with
; TMPH - color to fill with
.ylp2: mov TMPL, TOSL
.xlp2: subi ZL, lo8(-1000)
sbci ZH, hi8(-1000)
st Z, TMPH ; set color
subi ZL, lo8(1000)
sbci ZH, hi8(1000)
st Z+, r20 ; set character
dec TMPL
brne .xlp2
; end of x loop
add ZL, r21
adc ZH, ZEROL
dec TOSH
brne .ylp2
drop3
rnext
; TSPRITE ( c-addr wh xy -- ) copy characters from c-addr to screen, organized
; as w by h, at point xy. the byte value 0 is interpreted as transparent.
; if h=0, it is considered the same as h=1. this allows this function to draw
; Forth strings (addr/len pairs) provided they are less than 256 chars.
; for color console, the sprite is drawn using the current color
; no bounds checking is performed
ext_opcode_tsprite:
ld TMPL, DSP ; width
tst TMPL
breq .no_rect
ldd TMPH, DSP+1 ; height
tst TMPH ; treat h=0 as h=1
brne 1f
ldi TMPH, 1
1: lds r21, bytesperline ; get screen width
ldd r18, DSP+2 ; srcptr lo
ldd r19, DSP+3 ; srcptr hi
lds ZL, screen_ptr ; screen base address
lds ZH, screen_ptr+1
add ZL, TOSL ; add x coord
adc ZH, ZEROH
mul r21, TOSH ; multiply y by screen width to get byte offset
add ZL, r0 ; add y byte offset
adc ZH, r1
movw TSAV, Z ; save a copy
clr ZEROL ; mul clobbers zero regs, restore them
clr ZEROH
sub r21, TMPL ; subtract rect width from screen width, giving byteskip btwn lines
movw XSAV, X
movw X, r18
mov TOSH, TMPH
; loop
; TMPL - width
; TMPH - height
; TOSH - y counter
; TOSL - x counter
; r21 - number of bytes to skip to get to next row
.ylps: mov TOSL, TMPL
.xlps: ld r20, X+ ; get byte from src
cpse r20, ZEROL ; don't write if zero
st Z, r20 ; write to dst
adiw Z, 1 ; advance dst
dec TOSL
brne .xlps
; end of x loop
add ZL, r21
adc ZH, ZEROL
dec TOSH
brne .ylps
; end of y loop
; need to do color?
lds r20, fcon_color
andi r20, fcon_bitmask_color
breq 2f
; reinitialize params
movw X, r18 ; src
movw Z, TSAV ; dst
subi ZL, lo8(-1000)
sbci ZH, hi8(-1000)
lds r18, globalcolor
; color loop
; TMPL - width
; TMPH - y counter
; TOSL - x counter
.ylpsc: mov TOSL, TMPL
.xlpsc: ld r20, X+ ; get byte from src
cpse r20, ZEROL ; don't write color if zero
st Z, r18 ; write color to dst
adiw Z, 1 ; advance dst
dec TOSL
brne .xlpsc
; end of color x loop
add ZL, r21
adc ZH, ZEROL
dec TMPH
brne .ylpsc
2: movw X, XSAV
.no_rect2:
drop3
rnext
; TSPRITECC ( c-addr wh xy -- ) copy characters and colors from c-addr to screen
; organized as w by h, at point xy. c-addr points to an array of (2*w*h) bytes,
; with the first w*h bytes specifying characters and the second w*h bytes
; specifying colors.
; the byte value 0 has two special interpretations:
; - if a character byte is 0, only the color is changed
; - if a color byte is 0, only the character is changed
; - if both are 0, the pixel is effectively transparent
; (Although zero indicates the color black, opaque black cells can still be
; drawn using the ASCII space character, and any of the colors 1-15).
; no bounds checking is performed
ext_opcode_tspritecc:
ld TMPL, DSP ; width
tst TMPL
breq .no_rect2
ldd TMPH, DSP+1 ; height
tst TMPH ; treat h=0 as h=1
brne 1f
ldi TMPH, 1
1: lds r21, bytesperline ; get screen width
movw XSAV, X
ldd XL, DSP+2 ; srcptr lo
ldd XH, DSP+3 ; srcptr hi
lds ZL, screen_ptr ; screen base address
lds ZH, screen_ptr+1
add ZL, TOSL ; add x coord
adc ZH, ZEROH
mul r21, TOSH ; multiply y by screen width to get byte offset
add ZL, r0 ; add y byte offset
adc ZH, r1
movw TSAV, Z ; save a copy
clr ZEROL ; mul clobbers zero regs, restore them
clr ZEROH
sub r21, TMPL ; subtract rect width from screen width, giving byteskip btwn lines
mov TOSH, TMPH
; loop
; TMPL - width
; TMPH - height
; TOSH - y counter
; TOSL - x counter
; r21 - number of bytes to skip to get to next row
.y3: mov TOSL, TMPL
.x3: ld r20, X+ ; get byte from src
cpse r20, ZEROL ; don't write if zero
st Z, r20 ; write to dst
adiw Z, 1 ; advance dst
dec TOSL
brne .x3
; end of x loop
add ZL, r21
adc ZH, ZEROL
dec TOSH
brne .y3
; end of y loop--do color
movw Z, TSAV ; dst
subi ZL, lo8(-1000)
sbci ZH, hi8(-1000)
ldi r18, hi8(bitspreadtable)
; color loop
; TMPL - width
; TMPH - y counter
; TOSL - x counter
.y4: mov TOSL, TMPL
.x4: ld r20, X+ ; get color from src
add r20, r18 ; convert color to bitspread table offset
cpse r20, r18 ; don't write color if zero
st Z, r20 ; write color to dst
adiw Z, 1 ; advance dst
dec TOSL
brne .x4
; end of color x loop
add ZL, r21
adc ZH, ZEROL
dec TMPH
brne .y4
movw X, XSAV
drop3
rnext
; GLYPH@ ( f-addr c -- d1 d2 ) get glyph c from font as 8 bytes on stack
ext_opcode_getglyph:
mov ZL, TOSL ; character index
ld ZH, DSP+ ; get address msb
ld TMPL, DSP+ ; get rom/ram page
sbrc TMPL, 7 ; rom or ram?
rjmp .getglyph_ram
.getglyph_rom:
; save RAMPZ and set new RAMPZ
in r18, _SFR_IO_ADDR(RAMPZ)
out _SFR_IO_ADDR(RAMPZ), TMPL
.rept 3
; row 0/2/4
elpm TOSL, Z
inc ZH
; row 1/3/5
elpm TOSH, Z
inc ZH
pushd
.endr
; row 6
elpm TOSL, Z
inc ZH
; row 7
elpm TOSH, Z
; restore RAMPZ
out _SFR_IO_ADDR(RAMPZ), r18
rnext
.getglyph_ram:
.rept 3
; row 0/2/4
ld TOSL, Z
inc ZH
; row 1/3/5
ld TOSH, Z
inc ZH
pushd
.endr
; row 6
ld TOSL, Z
inc ZH
; row 7
ld TOSH, Z
rnext
; (FONT:) runtime of FONT:
; Throw an exception if cp is not 256-byte aligned.
; Store 0xFF00|(cp>>8) in name space.
; Allot 2048 bytes in code space and preload it with a copy of the default font.
ext_opcode_makefont:
lds TMPL, forth_cp
tst TMPL
brne .makefont_unaligned
callc_0arg_prologue
lds TOSL, forth_cp+1 ; store msb in name space
ldi TOSH, 0xFF
call comma
ldi TOSL, lo8(2048) ; allot 2048 bytes for font
ldi TOSH, hi8(2048)
call codespace_allot
tstw TOS ; abort if allot failed
brne .makefont_nospace
movw TOS, TMP ; initialize with default font
ldi TMPL, lo8(amscii_font_8x8)
ldi TMPH, hi8(amscii_font_8x8)
ldi r20, lo8(2048)
ldi r21, hi8(2048)
call memcpy_P
callc_0arg_epilogue
.makefont_unaligned:
throw FE_ALIGNMENT
.makefont_nospace:
movw r20, TOS
throw_r21r20
; GMODE ( c -- ) set bitmap graphics mode 0-17
ext_opcode_gmode:
callc_prologue
call forth_set_bitmap_mode
popd
callc_epilogue
; GSPLIT ( c -- ) set split bitmap/text mode 0-17
ext_opcode_gsplit:
callc_prologue
call forth_set_split_screen_mode
popd
callc_epilogue
; LPAL! ( c -- ) set palette used for low-color (4-color) bitmap modes
; this actually just changes the bitspread table, but bitmap modes use
; tilemap_hi (not globalcolor)
ext_opcode_lpalette:
cpi TOSL, bitspreadtable_numpatterns
cpc TOSH, ZEROH
brlo 1f
ldi TOSL, bitspreadtable_numpatterns-1
1: ldi TOSH, hi8(bitspreadtable) ; TODO how to do this with one subi?
add TOSL, TOSH
sts tilemap_hi, TOSL
popd
rnext
; EEC@ ( e-addr -- c ) read byte from EEPROM
ext_opcode_eecfetch:
; wait for completion of previous write
1: sbic _SFR_IO_ADDR(EECR), EEPE
rjmp 1b
; set address
out _SFR_IO_ADDR(EEARL), TOSL
out _SFR_IO_ADDR(EEARH), TOSH
; start eeprom read
sbi _SFR_IO_ADDR(EECR), EERE
in TOSL, _SFR_IO_ADDR(EEDR)
clr TOSH
rnext
; EE@ ( e-addr -- n ) read word from EEPROM
ext_opcode_eefetch:
; wait for completion of previous write
1: sbic _SFR_IO_ADDR(EECR), EEPE
rjmp 1b
; set address
out _SFR_IO_ADDR(EEARL), TOSL
out _SFR_IO_ADDR(EEARH), TOSH
; read low byte
sbi _SFR_IO_ADDR(EECR), EERE
in TMPL, _SFR_IO_ADDR(EEDR)
; advance address by 1 byte
adiw TOS, 1
out _SFR_IO_ADDR(EEARL), TOSL
out _SFR_IO_ADDR(EEARH), TOSH
; read high byte
sbi _SFR_IO_ADDR(EECR), EERE
in TOSH, _SFR_IO_ADDR(EEDR)
mov TOSL, TMPL
rnext
; EEC! ( c e-addr -- ) write byte to EEPROM
ext_opcode_eecstore:
; wait for completion of previous write
1: sbic _SFR_IO_ADDR(EECR), EEPE
rjmp 1b
; get value to write
nip
; set address
out _SFR_IO_ADDR(EEARL), TOSL
out _SFR_IO_ADDR(EEARH), TOSH
; read first--don't do a write cycle if the value is the same
sbi _SFR_IO_ADDR(EECR), EERE
in TMPH, _SFR_IO_ADDR(EEDR)
cp TMPL, TMPH
breq 2f
; set data byte
out _SFR_IO_ADDR(EEDR), TMPL
; atomically set EEMPE and then EEPE
atomic_start
sbi _SFR_IO_ADDR(EECR), EEMPE
sbi _SFR_IO_ADDR(EECR), EEPE
atomic_end
2: popd
rnext
; EE! ( n e-addr -- ) write word to EEPROM
ext_opcode_eestore:
; wait for completion of previous write
1: sbic _SFR_IO_ADDR(EECR), EEPE
rjmp 1b
; get value to write
nip
; set address
out _SFR_IO_ADDR(EEARL), TOSL
out _SFR_IO_ADDR(EEARH), TOSH
; low byte
; read first--don't do a write cycle if the value is the same
sbi _SFR_IO_ADDR(EECR), EERE
in r20, _SFR_IO_ADDR(EEDR)
cp TMPL, r20
breq 3f
; set data byte
out _SFR_IO_ADDR(EEDR), TMPL
; atomically set EEMPE and then EEPE
atomic_start
sbi _SFR_IO_ADDR(EECR), EEMPE
sbi _SFR_IO_ADDR(EECR), EEPE
atomic_end
; wait for completion of write
2: sbic _SFR_IO_ADDR(EECR), EEPE
rjmp 2b
; high byte
3: adiw TOS, 1
out _SFR_IO_ADDR(EEARL), TOSL
out _SFR_IO_ADDR(EEARH), TOSH
; read first--don't do a write cycle if the value is the same
sbi _SFR_IO_ADDR(EECR), EERE
in r20, _SFR_IO_ADDR(EEDR)
cp TMPH, r20
breq 4f
; set data byte
out _SFR_IO_ADDR(EEDR), TMPH
; atomically set EEMPE and then EEPE
atomic_start
sbi _SFR_IO_ADDR(EECR), EEMPE
sbi _SFR_IO_ADDR(EECR), EEPE
atomic_end
4: popd
rnext
; EE>RAM ( e-addr-from addr-to u -- ) copy u bytes from eeprom to ram
ext_opcode_eetoram:
tstw TOS
breq .noeeread
movw r20, TOS ; save count
ld ZL, DSP+ ; Z is destination ptr
ld ZH, DSP+
ld TOSL, DSP+ ; start address
ld TOSH, DSP+
add r20, TOSL ; add to count, giving end address
adc r21, TOSH
; TOS has current eeprom address, r21:r20 has eeprom end address, Z has ram addr
; wait for completion of previous write
1: sbic _SFR_IO_ADDR(EECR), EEPE
rjmp 1b
.eereadloop:
; set address
out _SFR_IO_ADDR(EEARL), TOSL
out _SFR_IO_ADDR(EEARH), TOSH
; start eeprom read
sbi _SFR_IO_ADDR(EECR), EERE
in TMPL, _SFR_IO_ADDR(EEDR)
st Z+, TMPL
; advance eeprom address and compare to end address
adiw TOS, 1
cp r20, TOSL
cpc r21, TOSH
brne .eereadloop
; done
popd
rnext
.noeeread:
.noeewrite:
drop3
rnext
; RAM>EE ( addr-from e-addr-to u -- ) copy u bytes from ram to eeprom
ext_opcode_ramtoee:
tstw TOS
breq .noeewrite
movw r20, TOS ; get count
ld TOSL, DSP+ ; get eeprom dest address
ld TOSH, DSP+
ld ZL, DSP+ ; get source address
ld ZH, DSP+
add r20, TOSL ; add to count giving eeprom end address
adc r21, TOSH
.eewriteloop:
; wait for completion of previous write
sbic _SFR_IO_ADDR(EECR), EEPE
rjmp .eewriteloop
; set address
out _SFR_IO_ADDR(EEARL), TOSL
out _SFR_IO_ADDR(EEARH), TOSH
; get byte from ram
ld TMPL, Z+
; read byte from eeprom, skip if identical
sbi _SFR_IO_ADDR(EECR), EERE
in TMPH, _SFR_IO_ADDR(EEDR)
cp TMPL, TMPH
breq 1f
; set data byte and do write
out _SFR_IO_ADDR(EEDR), TMPL
atomic_start
sbi _SFR_IO_ADDR(EECR), EEMPE
sbi _SFR_IO_ADDR(EECR), EEPE
atomic_end
; advance eeprom address and compare to end address
1: adiw TOS, 1
cp r20, TOSL
cpc r21, TOSH
brne .eewriteloop
popd
rnext
; EEFILL ( e-addr u c -- ) fill u bytes of eeprom starting at e-addr with c
ext_opcode_eefill:
mov TMPL, TOSL ; get character
ld ZL, DSP+ ; get count
ld ZH, DSP+
tstw Z
breq .noeefill
ld TOSL, DSP+ ; get eeprom address
ld TOSH, DSP+
add ZL, TOSL ; add to count, giving eeprom end address in Z
adc ZH, TOSH
.eefillloop:
; wait for completion of previous write
sbic _SFR_IO_ADDR(EECR), EEPE
rjmp .eefillloop
; set address
out _SFR_IO_ADDR(EEARL), TOSL
out _SFR_IO_ADDR(EEARH), TOSH
; read previous byte, skip if identical
sbi _SFR_IO_ADDR(EECR), EERE
in TMPH, _SFR_IO_ADDR(EEDR)
cp TMPL, TMPH
breq 1f
; set data byte and do write
out _SFR_IO_ADDR(EEDR), TMPL
atomic_start
sbi _SFR_IO_ADDR(EECR), EEMPE
sbi _SFR_IO_ADDR(EECR), EEPE
atomic_end
; advance eeprom address and compare to end address
1: adiw TOS, 1
cp ZL, TOSL
cpc ZH, TOSH
brne .eefillloop
popd
rnext
.noeefill:
.noeetype:
drop2
rnext
; EETYPE ( e-addr u -- ) print string from eeprom
ext_opcode_eetype:
tstw TOS
breq .noeetype
movw LINKL, TOS ; save count in a register not clobbered by C
ld TOSL, DSP+ ; start address
ld TOSH, DSP+
add LINKL, TOSL ; add to count, giving end address
adc LINKH, TOSH
; TOS has current eeprom address, r21:r20 has eeprom end address
; wait for completion of previous write
1: sbic _SFR_IO_ADDR(EECR), EEPE
rjmp 1b
callc_prologue
.eetypeloop:
; set address
out _SFR_IO_ADDR(EEARL), TOSL
out _SFR_IO_ADDR(EEARH), TOSH
movw TSAV, TOS
; start eeprom read
sbi _SFR_IO_ADDR(EECR), EERE
in TOSL, _SFR_IO_ADDR(EEDR)
; print character
lds ZL, mio_putc ; TODO this could take 1 cycle if mio_putc was saved in a register pair
lds ZH, mio_putc+1
icall
movw TOS, TSAV
; advance eeprom address and compare to end address
adiw TOS, 1
cp LINKL, TOSL
cpc LINKH, TOSH
brne .eetypeloop
; done
callc_restore
popd
rnext
.macro spi_tx, reg
out _SFR_IO_ADDR(SPDR), \reg ; transmit byte
1: in TMPL, _SFR_IO_ADDR(SPSR) ; wait until complete
sbrs TMPL, SPIF
rjmp 1b
in \reg, _SFR_IO_ADDR(SPDR) ; get received byte
.endm
; SPI0 ( n -- n ) transmit/receive 2 bytes on SPI port 0, MSB first
ext_opcode_spi0:
cbi _SFR_IO_ADDR(SPI0_CS_PORT), SPI0_CS_PIN ; assert chip select
spi_tx TOSH
spi_tx TOSL
sbi _SFR_IO_ADDR(SPI0_CS_PORT), SPI0_CS_PIN ; deassert chip select
rnext
; CSPI0 ( c -- c ) transmit/receive 1 byte on SPI port 0
ext_opcode_cspi0:
cbi _SFR_IO_ADDR(SPI0_CS_PORT), SPI0_CS_PIN ; assert chip select
spi_tx TOSL
sbi _SFR_IO_ADDR(SPI0_CS_PORT), SPI0_CS_PIN ; deassert chip select
clr TOSH
rnext
; SPI1 ( n -- n ) transmit/receive 2 bytes on SPI port 1, MSB first
ext_opcode_spi1:
cbi _SFR_IO_ADDR(SPI1_CS_PORT), SPI1_CS_PIN ; assert chip select
spi_tx TOSH
spi_tx TOSL
sbi _SFR_IO_ADDR(SPI1_CS_PORT), SPI1_CS_PIN ; deassert chip select
rnext
; CSPI1 ( c -- c ) transmit/receive 1 byte on SPI port 1
ext_opcode_cspi1:
cbi _SFR_IO_ADDR(SPI1_CS_PORT), SPI1_CS_PIN ; assert chip select
spi_tx TOSL
sbi _SFR_IO_ADDR(SPI1_CS_PORT), SPI1_CS_PIN ; deassert chip select
clr TOSH
rnext
; SPI2 ( n -- n ) transmit/receive 2 bytes on SPI port 2 (player 1 controller), MSB first
ext_opcode_spi2:
cbi _SFR_IO_ADDR(SPI2_CS_PORT), SPI2_CS_PIN ; assert chip select
spi_tx TOSH
spi_tx TOSL
sbi _SFR_IO_ADDR(SPI2_CS_PORT), SPI2_CS_PIN ; deassert chip select
rnext
; CSPI2 ( c -- c ) transmit/receive 1 byte on SPI port 2 (player 1 controller)
ext_opcode_cspi2:
cbi _SFR_IO_ADDR(SPI2_CS_PORT), SPI2_CS_PIN ; assert chip select
spi_tx TOSL
sbi _SFR_IO_ADDR(SPI2_CS_PORT), SPI2_CS_PIN ; deassert chip select
clr TOSH
rnext
; SPI3 ( n -- n ) transmit/receive 2 bytes on SPI port 3 (player 2 controller), MSB first
ext_opcode_spi3:
cbi _SFR_IO_ADDR(SPI3_CS_PORT), SPI3_CS_PIN ; assert chip select
spi_tx TOSH
spi_tx TOSL
sbi _SFR_IO_ADDR(SPI3_CS_PORT), SPI3_CS_PIN ; deassert chip select
rnext
; CSPI3 ( c -- c ) transmit/receive 1 byte on SPI port 3 (player 2 controller)
ext_opcode_cspi3:
cbi _SFR_IO_ADDR(SPI3_CS_PORT), SPI3_CS_PIN ; assert chip select
spi_tx TOSL
sbi _SFR_IO_ADDR(SPI3_CS_PORT), SPI3_CS_PIN ; deassert chip select
clr TOSH
rnext
; XMSTAT ( -- c ) read external memory (SPI0) status register
ext_opcode_xmgetstatus:
pushd
callc_prologue
call spi_eeprom_status
callc_epilogue
; XMSTAT! ( c -- ) set external memory (SPI0) status register
ext_opcode_xmsetstatus:
callc_prologue
call spi_eeprom_set_status
popd
callc_epilogue
; XMC@ ( x-addr -- c ) fetch byte from external memory (SPI0)
ext_opcode_xmcfetch:
callc_prologue
call spi_eeprom_read_byte
clr TOSH
callc_epilogue
; XMC! ( c x-addr -- ) store byte to external memory (SPI0)
ext_opcode_xmcstore:
nip ; get value into r22
callc_prologue
call spi_eeprom_write_byte
popd
callc_epilogue
; RAM>XM ( addr-from x-addr-to u -- ) copy u bytes from ram to external memory (SPI0)
; void spi_eeprom_write_block(const uint8_t *src, uint16_t dst, uint16_t n)
; r25:r24 - src
; r23:r22 - dst
; r21:r20 - n
ext_opcode_ramtoxm:
movw r20, TOS ; move byte count
nip ; get dst addr into r23:r22
popd ; get src addr into r25:r24
callc_prologue
call spi_eeprom_write_block
popd
callc_epilogue
; XM>RAM ( x-addr-from addr-to u -- ) copy u bytes from external memory (SPI0) to ram
; void spi_eeprom_read_block(uint8_t *dst, uint16_t src, uint16_t n)
; r25:r24 - dst
; r23:r22 - src
; r21:r20 - n
ext_opcode_xmtoram:
movw r20, TOS ; move byte count
popd ; get dest addr into r25:r24
nip ; get src addr into r23:r22
callc_prologue
call spi_eeprom_read_block
popd
callc_epilogue
.macro daa reg
mov ZL, \reg
rcall decimal_adj_add
mov \reg, ZL
.endm
.macro das reg
mov ZL, \reg
rcall decimal_adj_sub
mov \reg, ZL
.endm
; #BLOCKS ( -- u ) number of blocks available for storage (internal and external)
ext_opcode_numblocks:
pushd
callc_prologue
call num_blocks
clr TOSH
callc_epilogue
; #XMBLOCKS ( -- u ) number of blocks available for storage in external memory
; returns 0 if no external memory device detected
ext_opcode_numxmblocks:
pushd
callc_prologue
call num_xmem_blocks
clr TOSH
callc_epilogue
; COPY-BLOCKS ( block-src block-dst u -- ) copy u blocks to block-dst, starting at block-src
; r24 - dstblk
; r22 - srcblk
; r20 - u
ext_opcode_copyblocks:
mov r20, TOSL ; get count into r20
ld TOSL, DSP+ ; get dest into r24
ld TOSH, DSP+
ld TMPL, DSP+ ; get src into r22
ld TMPH, DSP+
callc_prologue
call copy_blocks
popd
callc_epilogue
; FILL-BLOCKS ( block u c -- ) fill u blocks with byte c, starting at block
; void fill_blocks(uint8_t startblk, uint8_t nblocks, char c)
; r24 - startblk
; r22 - nblocks
; r20 - c
ext_opcode_fillblocks:
mov r20, TOSL ; get byte value
nip ; get count
popd ; get start block number
callc_prologue
call fill_blocks
popd
callc_epilogue
; BCD+ ( u1 u2 -- u ) add cells u1 and u2 as 4-digit binary-coded-decimal numbers
ext_opcode_bcdplus:
nip
add TOSL, TMPL
daa TOSL
adc TOSH, TMPH
daa TOSH
rnext
; BCD- ( u1 u2 -- u ) subtract cells u1 and u2 as 4-digit binary-coded-decimal numbers
ext_opcode_bcdminus:
nip
sub TMPL, TOSL
das TMPL
sbc TMPH, TOSH
das TMPH
movw TOS, TMP
rnext
; DBCD+ ( ud1 ud2 -- ud ) add double-cells ud1 and ud2 as 8-digit binary-coded-decimal numbers
ext_opcode_dbcdplus:
ld TMPL, DSP+ ; byte 0 (LSB) of xd2
ld TMPH, DSP+ ; byte 1 of xd2
ld r20, DSP+ ; byte 2 of xd1
ld r21, DSP+ ; byte 3 (MSB) of xd1
ld r18, DSP ; byte 0 (LSB) of xd1
ldd r19, DSP+1 ; byte 1 of xd1
.dbcdadd:
add TMPL, r18
daa TMPL
adc TMPH, r19
daa TMPH
adc TOSL, r20 ; upper word of sum is already in TOS
daa TOSL
adc TOSH, r21
daa TOSH
st DSP, TMPL ; store lower word of sum back to stack
std DSP+1, TMPH
rnext
; MBCD+ ( ud1 u2 -- ud ) add single-cell (4-digit) binary-coded-decimal-number to
; double-cell (8-digit) binary-coded-decimal number
ext_opcode_mbcdplus:
movw r18, TOS ; get the single-cell value
movw r20, TOS ; and zero-extend it
clr r20
clr r21
popd
ld TMPL, DSP ; now the double-cell value is in r25-r22
ldd TMPH, DSP+1
rjmp .dbcdadd
; DBCD- ( ud1 ud2 -- ud ) subtract double-cells du1 and ud2 as 8-digit binary-coded-decimal numbers
ext_opcode_dbcdminus:
movw r20, TOS ; bytes 2 and 3 (MSB) of xd2
ld r18, DSP+ ; byte 0 (LSB) of xd2
ld r19, DSP+ ; byte 1 of xd2
ld TOSL, DSP+ ; byte 2 of xd1
ld TOSH, DSP+ ; byte 3 (MSB) of xd1
ld TMPL, DSP ; byte 0 (LSB) of xd1
ldd TMPH, DSP+1 ; byte 1 of xd1
sub TMPL, r18
das TMPL
sbc TMPH, r19
das TMPH
sbc TOSL, r20 ; upper word of difference is already in TOS
das TOSL
sbc TOSH, r21
das TOSH
st DSP, TMPL ; store lower word of difference back to stack
std DSP+1, TMPH
rnext
; (BCD>ASCII!) ( u c-addr -- c-addr+4 ) store 4-byte ASCII representation of
; binary-coded-decimal number u starting at c-addr. (most significant digit to
; least significant digit, as it would be displayed)
; Leaves the address of the byte after the last byte written. (to facilitate
; multiprecision operations)
ext_opcode_bcdtoascii:
movw Z, TOS
nip ; value in TMPH/TMPL
mov r20, TMPH ; first digit (most significant)
swap r20
andi r20, 0x0F
subi r20, -'0'
st Z+, r20
andi TMPH, 0x0F ; second digit
subi TMPH, -'0'
st Z+, TMPH
mov r20, TMPL ; third digit
swap r20
andi r20, 0x0F
subi r20, -'0'
st Z+, r20
andi TMPL, 0x0F ; fourth digit (least significant)
subi TMPL, -'0'
st Z+, TMPL
movw TOS, Z
rnext
dispatch_stubs .ext_opcode_, 256
throw FE_UNSUPPORTED_OPERATION
; decimal adjust after addition
; adapted from http://imrannazar.com/Binary-Coded-Decimal-Addition-on-Atmel-AVR
; and modified to require only one temporary register (and T flag)
; input: number in r30, H and C flags set
; output: adjusted number in r30
; carry-out in C flag
; clobbers: r31 and T flag
decimal_adj_add:
; move H flag to T flag so it's not clobbered by arithmetic
in r31, _SFR_IO_ADDR(SREG)
bst r31, SREG_H
; if old carry was set, or >= 0x99, add 0x60 and set carry-out
brcs .daa_carry_out
cpi r30, 0x9A
brcc .daa_carry_out
; if (half-carry set) or (lower nibble > 9), add 6
brts .adj_lo
mov r31, r30
andi r31, 0xF ; isolate lower nibble
cpi r31, 10
brlo .noadj_lo
.adj_lo:
subi r30, -0x06
.noadj_lo:
clc
ret
.daa_carry_out:
; if (half-carry set) or (lower nibble > 9), add 6
brts .adj_lo2
mov r31, r30
andi r31, 0xF ; isolate lower nibble
cpi r31, 10
brlo .noadj_lo2
.adj_lo2:
subi r30, -0x06
.noadj_lo2:
; add 0x60 and set carry
subi r30, -0x60
sec
ret
; decimal adjust after subtraction
; adapted from Atmel app note AVR204
; input: number in r30, H and C flags set
; output: adjusted number in r30
; carry-out in C flag
; clobbers: r31
decimal_adj_sub:
clr r31 ; clear BCD carry
brcc .sub_0 ; if carry-in not clear
ldi r31, 1 ; set BCD carry
.sub_0: brhc .sub_1 ; if half carry not clear
subi r30, 0x06 ; LSD = LSD - 6
.sub_1: sbrs r31, 0 ; if previous carry not set
rjmp .sub_2 ; return
subi r30 ,0x60 ; subtract 6 from MSD
ldi r31, 1 ; set underflow carry
brcc .sub_2 ; if carry not clear
ldi r31, 1 ; clear underflow carry
.sub_2:
lsr r31 ; copy BCD carry to C flag
ret
.catch_exception_handler:
; always unnest the exception frame, even if we got here via a BREAK
brts 1f
; get this exception frame, so we can unnest it
lds ZL, forth_exception_frame
lds ZH, forth_exception_frame+1
z_to_rsp
pop ZL
pop ZH
; pop and restore the address of the previous frame
sts forth_exception_frame, ZL
sts forth_exception_frame+1, ZH
; pop exception handler (we're already here!)
pop ZL
pop ZH
; pop return address
1: popr
; pop previous input source
pop ZH ; forth_inputpos
pop ZL ; forth_inputlen
pop r19 ; forth_inputsrc+1
pop r18 ; forth_inputsrc
; pop data stack pointer
pop TMPL
pop TMPH
; if there's an error code, restore previous input source and stack ptr
brtc 1f
movw DSP, TMP
sbiw DSP, 2
ld TOSL, DSP
ldd TOSH, DSP+1
sts forth_inputsrc, r18
sts forth_inputsrc+1, r19
sts forth_inputlen, ZL
sts forth_inputpos, ZH
; transfer error code to stack and resume
movw TOS, r20
rnext
; if no exception, push 0 on stack and resume
1: pushd
movw TOS, ZERO
rnext
|
74hc595/Amethyst
| 122,846
|
apps/forth/forth_opcodes.S
|
; Ah yes, there's nothing like a 5000 line .S file.
; The location of each routine relative to the locations of the dispatch tables
; are important. A dispatch table must be able to reach every routine via RJMP.
; The linker can't be trusted to do this correctly. And it also likes to add
; *lots* of padding, for some reason the ".align 9" directive used to align each
; dispatch table forces 512-byte alignment for the *entire* object file.
; I suppose I could break it all down into smaller .inc files...
#include "forth_opcodes.h"
#include "forth_macros.inc"
#include "forth_defs.h"
#include "videodefs.h"
; Base address used for high-page memory access instructions
; (C#+H@) (C#+H!) (C#+HC@) (C#+HC!)
.global high_page_base
.equ high_page_base, (RAMEND+1)-0x100
; Drawing operation dispatch table aligned to 256-word boundary
#include "draw_ops.inc"
; Graphics/drawing routines
; Lots of code duplication here to avoid the penalty (speed and stack usage)
; of function calls and branching.
; I could macro-ize the duplicated parts I guess
opcode_txres:
opcode_hxres:
pushd
lds TOSL, bytesperline
clr TOSH
rnext
opcode_mxres:
pushd
lds TOSL, bytesperline
lsl TOSL ; 2 pixels per byte
clr TOSH
rnext
opcode_lxres:
pushd
lds TOSL, bytesperline
lsl TOSL ; 4 pixels per byte
lsl TOSL
clr TOSH
rnext
opcode_bxres:
pushd
lds TOSL, bytesperline
lsl TOSL ; 8 pixels per byte
clr TOSH
lsl TOSL
rol TOSH
lsl TOSL
rol TOSH
rnext
opcode_tgetcolor:
pushd
lds TOSL, globalcolor
ldi TOSH, hi8(bitspreadtable) ; TODO how to do this with one subi?
sub TOSL, TOSH
clr TOSH
rnext
opcode_hgetcolor:
pushd
lds TOSL, globalcolor
clr TOSH
rnext
opcode_mgetcolor:
pushd
lds TOSL, globalcolor
andi TOSL, 0b00001111
clr TOSH
rnext
opcode_lgetcolor:
pushd
lds TOSL, globalcolor
andi TOSL, 0b00000011
clr TOSH
rnext
opcode_bgetcolor:
pushd
lds TOSL, globalcolor
andi TOSL, 0b00000001
clr TOSH
rnext
; TCOLOR! ( c -- ) set current text color to c
opcode_tsetcolor:
cpi TOSL, bitspreadtable_numpatterns
cpc TOSH, ZEROH
brlo 1f
ldi TOSL, bitspreadtable_numpatterns-1
1: ldi TOSH, hi8(bitspreadtable) ; TODO how to do this with one subi?
add TOSL, TOSH
; fall through
; HCOLOR! ( c -- ) set high-color graphics mode current color to c (0-255)
opcode_hsetcolor:
sts globalcolor, TOSL
popd
rnext ; all draw ops have to restore Z
; MCOLOR! ( c -- ) set medium-color graphics mode current color to c (0-15)
opcode_msetcolor:
ldi ZH, hi8(lowernibbledoubletable)
mov ZL, TOSL
lpm TOSL, Z
sts globalcolor, TOSL
popd
rnext
; LCOLOR! ( c -- ) set low-color graphics mode current color to c (0-3)
opcode_lsetcolor:
; expand 2 bits to 8 bits
ldi ZH, hi8(crumbquadtable)
mov ZL, TOSL
lpm TOSL, Z
sts globalcolor, TOSL
popd
rnext
; BCOLOR! ( c -- ) set mono graphics mode color to 0 (black) or 1 (white)
opcode_bsetcolor:
lsr TOSL ; lsb to carry bit
clr TOSL
sbc TOSL, TOSL ; if carry set, TOSH=0xFF, otherwise TOSH=0x00
sts globalcolor, TOSL
popd
rnext
; MCLEAR ( c -- ) fill medium-color graphics screen with color c (0-15)
opcode_mclear:
; expand 4 bits to 8 bits
ldi ZH, hi8(lowernibbledoubletable)
mov ZL, TOSL
lpm TOSL, Z
; fall through
; HCLEAR ( c -- ) fill high-color graphics screen with color c (0-255)
; TCLEAR ( c -- ) fill text screen with character c (0-255)
opcode_hclear:
opcode_tclear:
mov TMPL, TOSL
lds r0, bytesperline
lds r1, linesperscreen
mul r0, r1 ; get byte count
movw TOS, r0 ; move to r25:24 so we can use sbiw
lds ZL, screen_ptr
lds ZH, screen_ptr+1
1: st Z+, TMPL
sbiw TOS, 1
brne 1b
movw r0, TOS ; restore r1:r0 to zero
popd
rnext
; LCLEAR ( c -- ) fill low-color graphics screen with color c (0-3)
opcode_lclear:
; expand 2 bits to 8 bits
ldi ZH, hi8(crumbquadtable)
mov ZL, TOSL
lpm TOSL, Z
rjmp opcode_hclear
; BCLEAR ( c -- ) fill black & white graphics screen with black (if lsb of c
; is 0) or white (if lsb of c is 1)
opcode_bclear:
lsr TOSL
ldi TOSL, 0
sbc TOSL, ZEROL
rjmp opcode_hclear
; HPLOT ( xy -- ) set pixel in high-color graphics screen to current color
opcode_hplot_chk:
lds TMPL, bytesperline ; check x coord
cp TOSL, TMPL
brsh .nohplot
opcode_hplot:
lds TMPL, globalcolor
rjmp .xystore
opcode_hpset_chk:
opcode_tpset_chk:
lds TMPL, bytesperline ; check x coord
cp TOSL, TMPL
brsh .nohpset
; XY! ( c xy -- ) store byte at xy coordinate in screen buffer
; HPSET ( c xy -- ) set color of pixel at xy in high-color bitmap mode
; TSET ( c xy -- ) set character in text cell at xy (color is not affected)
; no bounds checking is performed
opcode_hpset:
opcode_tpset:
opcode_xystore:
nip ; get char into TMPL
.xystore:
movw r20, ZERO ; mul will clobber the zero regs
lds r0, bytesperline ; multiply y coord * bytes per line
mul r0, TOSH
add r0, TOSL ; add x coord
adc r1, r20 ; will be zero
lds ZL, screen_ptr ; add screen offset
lds ZH, screen_ptr+1
add ZL, r0
adc ZH, r1
movw ZERO, r20 ; restore zero regs
st Z, TMPL
.nohplot:
popd
rnext
.nohpset:
drop2
rnext
opcode_mpset_chk:
lds TMPL, bytesperline ; check x coord
lsl TMPL
cp TOSL, TMPL
brsh .nompset
; MPSET ( c xy -- ) set pixel in medium-color graphics screen to c
opcode_mpset:
ld ZL, DSP+ ; nip color
ld TMPL, DSP+ ; discard high byte of NOS
ldi ZH, hi8(lowernibbledoubletable)
lpm TMPL, Z
movw r20, ZERO ; mul will clobber the zero regs
lds r0, bytesperline ; multiply y coord * bytes per line
mul r0, TOSH
lsr TOSL ; divide x coord by two--odd or even?
brcs .mplot_odd
rjmp .mplot_even
.nompset:
drop2
rnext
; MPLOT ( xy -- ) set pixel in medium-color graphics screen to current color
opcode_mplot_chk:
lds TMPL, bytesperline ; check x coord
lsl TMPL
cp TOSL, TMPL
brsh .nomplot
opcode_mplot:
lds TMPL, globalcolor
movw r20, ZERO ; mul will clobber the zero regs
lds r0, bytesperline ; multiply y coord * bytes per line
mul r0, TOSH
lsr TOSL ; divide x coord by two--odd or even?
brcs .mplot_odd
; save a couple cycles by unrolling the odd/even branches
.mplot_even:
add r0, TOSL ; add x byte index
adc r1, r20 ; will be zero
lds ZL, screen_ptr ; add screen offset
lds ZH, screen_ptr+1
add ZL, r0
adc ZH, r1
movw ZERO, r20 ; restore zero regs
ld TOSL, Z ; get existing byte
andi TOSL, 0b00001111 ; apply masks to existing and incoming byte values
andi TMPL, 0b11110000
or TOSL, TMPL ; or in the new pixel value
st Z, TOSL ; store new byte
.nomplot:
popd
rnext
.mplot_odd:
add r0, TOSL ; add x byte index
adc r1, r20 ; will be zero
lds ZL, screen_ptr ; add screen offset
lds ZH, screen_ptr+1
add ZL, r0
adc ZH, r1
movw ZERO, r20 ; restore zero regs
ld TOSL, Z ; get existing byte
andi TOSL, 0b11110000 ; apply masks to existing and incoming byte values
andi TMPL, 0b00001111
or TOSL, TMPL ; or in the new pixel value
st Z, TOSL ; store new byte
popd
rnext
opcode_lpset_chk:
lds TMPL, bytesperline ; check x coord
lsl TMPL
lsl TMPL
cp TOSL, TMPL
brsh .nolpset
; LPSET ( c xy -- ) set pixel in low-color graphics screen to c
opcode_lpset:
; expand 2 bits to 8 bits
ld ZL, DSP+ ; nip color
ld TMPL, DSP+ ; discard high byte of NOS
ldi ZH, hi8(crumbquadtable)
lpm TMPL, Z
rjmp .lplot
.nolpset:
drop2
rnext
; LPLOT ( xy -- ) set pixel in low-color graphics screen to current color
opcode_lplot_chk:
lds TMPL, bytesperline ; check x coord
lsl TMPL
lsl TMPL
cp TOSL, TMPL
brsh .nolplot
opcode_lplot:
lds TMPL, globalcolor ; get color
.lplot: mov ZL, TOSL ; get bit mask for x position
ldi ZH, hi8(crumbmasktable)
lpm TMPH, Z ; select the correct byte in color for this x pos
and TMPL, TMPH
com TMPH ; invert mask
lsr TOSL ; divide x coord by 4 to get byte address
lsr TOSL
movw r20, ZERO ; mul will clobber the zero regs
lds r0, bytesperline ; multiply y coord * bytes per line
mul r0, TOSH
add r0, TOSL ; add x byte index
adc r1, r20 ; will be zero
lds ZL, screen_ptr ; add screen offset
lds ZH, screen_ptr+1
add ZL, r0
adc ZH, r1
movw ZERO, r20 ; restore zero regs
ld TOSL, Z ; get existing byte
and TOSL, TMPH ; mask existing pixel value
or TOSL, TMPL ; or in the new pixel value
st Z, TOSL ; store new byte
.nolplot:
popd
rnext
opcode_bpset_chk:
movw TMP, ZERO ; mul will clobber the zero regs
lds r0, bytesperline ; compute x width
ldi r18, 8
mul r0, r18
cp TOSL, r0 ; check x coord, zero-extended to 16 bits
cpc TMPL, r1 ; (TMPL will be zero)
movw ZERO, TMP ; restore zero regs (doesn't affect flags)
brsh .nobpset
; BPSET ( c xy -- ) set pixel at xy (for x<=255) in mono graphics screen to
; color c (lsb indicates white or black)
; No bounds checking is performed.
; Does not work for x coordinates greater than 255
opcode_bpset:
nip
bst TMPL, 0
rjmp .bplot
.nobpset:
drop2
rnext
opcode_bplot_chk:
movw TMP, ZERO ; mul will clobber the zero regs
lds r0, bytesperline ; compute x width
ldi r18, 8
mul r0, r18
cp TOSL, r0 ; check x coord, zero-extended to 16 bits
cpc TMPL, r1 ; (TMPL will be zero)
movw ZERO, TMP ; restore zero regs (doesn't affect flags)
brsh .nobplot
; BPLOT ( xy -- ) set pixel at xy (for x<=255) in mono graphics screen to
; current color (lsb indicates white or black)
; No bounds checking is performed.
; Does not work for x coordinates greater than 255
opcode_bplot:
lds TMPL, globalcolor ; move lsb of color to T flag
bst TMPL, 0
.bplot: mov ZL, TOSL ; get bit mask for current position
ldi ZH, hi8(bitmasktable)
lpm TMPH, Z
lsr TOSL ; divide x coord by 8 to get byte address
lsr TOSL
lsr TOSL
movw r20, ZERO ; mul will clobber the zero regs
lds r0, bytesperline ; multiply y coord * bytes per line
mul r0, TOSH
add r0, TOSL ; add x byte index
adc r1, r20 ; will be zero
lds ZL, screen_ptr ; add screen offset
lds ZH, screen_ptr+1
add ZL, r0
adc ZH, r1
movw ZERO, r20 ; restore zero regs
ld TOSL, Z ; get existing byte
brts .bplot_setpixel
.bplot_clearpixel:
com TMPH
and TOSL, TMPH
st Z, TOSL
.nobplot:
popd
rnext
.bplot_setpixel:
or TOSL, TMPH ; or in the new pixel value
st Z, TOSL ; store new byte
popd
rnext
; assumes: stack is ( h -- ) and xy in TMPL/TMPH
opcode_hvlin_chk:
lds TOSH, bytesperline ; check x coord
cp TMPL, TOSH
brlo 1f
.nohvlin:
popd
rnext
; HVLIN ( xy h -- ) draw vertical line starting at xy and extending h pixels
; downward in current color (high color modes)
; No bounds checking is performed, and behavior is undefined if h=0.
; The argument order follows the pattern used by ! ( what where -- )
opcode_hvlin:
nip ; get xy into TMP
lds TOSH, bytesperline
1: movw r20, ZERO ; mul will clobber the zero regs
mul TOSH, TMPH ; multiply y coord * bytes per line
add r0, TMPL ; add x coord
adc r1, r20 ; will be zero
lds ZL, screen_ptr ; add screen offset
lds ZH, screen_ptr+1
add ZL, r0
adc ZH, r1
movw ZERO, r20 ; restore zero regs
lds r20, globalcolor
1: st Z, r20
add ZL, TOSH ; advance 1 line
adc ZH, ZERO
dec TOSL ; decrement remaining height
brne 1b
popd
rnext
; assumes: stack is ( h -- ) and xy in TMPL/TMPH
opcode_mvlin_chk:
lds TOSH, bytesperline ; check x coord
mov r20, TOSH ; multiply bytesperline by 2
lsl r20
cp TMPL, r20
brlo 1f
.nomvlin:
popd
rnext
; MVLIN ( xy h -- ) draw vertical line starting at xy and extending h pixels
; downward in current color (medium color modes)
; No bounds checking is performed, and behavior is undefined if h=0.
opcode_mvlin:
nip ; get xy into TMP
lds TOSH, bytesperline
1: movw r20, ZERO ; mul will clobber the zero regs
mul TOSH, TMPH ; multiply y coord * bytes per line
bst TMPL, 0 ; odd pixel or even?
lsr TMPL ; divide x by 2 to get byte offset
add r0, TMPL ; add x byte index
adc r1, r20 ; will be zero
lds ZL, screen_ptr ; add screen offset
lds ZH, screen_ptr+1
add ZL, r0
adc ZH, r1
movw ZERO, r20 ; restore zero regs
lds r20, globalcolor
brts .mvlin_odd
.mvlin_even:
andi r20, 0b11110000 ; apply mask to existing color
1: ld TMPL, Z ; get existing byte
andi TMPL, 0b00001111 ; apply mask to existing byte value
or TMPL, r20 ; or in the new pixel value
st Z, TMPL ; store new byte
add ZL, TOSH ; advance 1 line
adc ZH, ZERO
dec TOSL ; decrement remaining height
brne 1b
popd
rnext
.mvlin_odd:
andi r20, 0b00001111 ; apply mask to existing color
1: ld TMPL, Z ; get existing byte
andi TMPL, 0b11110000 ; apply mask to existing byte value
or TMPL, r20 ; or in the new pixel value
st Z, TMPL ; store new byte
add ZL, TOSH ; advance 1 line
adc ZH, ZERO
dec TOSL ; decrement remaining height
brne 1b
popd
rnext
; assumes: stack is ( h -- ) and xy in TMPL/TMPH
opcode_lvlin_chk:
lds r18, bytesperline ; check x coord
mov r20, r18 ; multiply bytesperline by 4
lsl r20
lsl r20
cp TMPL, r20
brlo 1f
.nolvlin:
popd
rnext
; LVLIN ( xy h -- ) draw vertical line starting at xy and extending h pixels
; downward in current color (low color modes)
; No bounds checking is performed, and behavior is undefined if h=0.
opcode_lvlin:
nip ; get xy into TMP
lds r18, bytesperline ; multiply y coord * bytes per line
1: lds r19, globalcolor ; get color
mov ZL, TMPL ; get bit mask for x position
ldi ZH, hi8(crumbmasktable)
lpm r20, Z
and r19, r20 ; select the correct bits in color for this x pos
com r20 ; invert mask
lsr TMPL ; divide x coord by 4 to get byte address
lsr TMPL
movw XSAV, ZERO ; mul will clobber the zero regs
mul r18, TMPH ; multiply y coord * bytes per line
add r0, TMPL ; add x byte offset
adc r1, XSAVL ; will be zero
lds ZL, screen_ptr ; add screen offset
lds ZH, screen_ptr+1
add ZL, r0
adc ZH, r1
movw ZERO, XSAV ; restore zero regs
1: ld TOSH, Z ; get existing byte
and TOSH, r20 ; mask existing pixel value
or TOSH, r19 ; or in the new pixel value
st Z, TOSH ; store new byte
add ZL, r18 ; advance 1 line
adc ZH, ZERO
dec TOSL
brne 1b
popd
rnext
; assumes: stack is ( h -- ) and xy in TMPL/TMPH
opcode_bvlin_chk:
movw XSAV, ZERO ; mul will clobber the zero regs
lds r18, bytesperline ; compute x width
ldi r19, 8
mul r18, r19
cp TMPL, r0 ; check x coord, zero-extended to 16 bits
cpc XSAVL, r1 ; (XSAVL will be zero)
brlo 1f
.nobvlin:
movw ZERO, XSAV ; restore zero regs
popd
rnext
; BVLIN ( xy h -- ) draw vertical line starting at xy (for x<=255) and extending
; h pixels downward in current color (mono modes)
; No bounds checking is performed, and behavior is undefined if h=0.
; Does not work for x coordinates greater than 255
opcode_bvlin:
nip ; get xy into TMP
movw XSAV, ZERO ; mul will clobber the zero regs
lds r18, bytesperline
1: lds r20, globalcolor ; move lsb of color to T flag
bst r20, 0
mov ZL, TMPL ; get bit mask for x position
ldi ZH, hi8(bitmasktable)
lpm r20, Z ; bitmask is now in r20
lsr TMPL ; divide x coord by 8 to get byte address
lsr TMPL
lsr TMPL
mul r18, TMPH ; multiply y coord * bytes per line
add r0, TMPL ; add x byte index
adc r1, XSAVL ; will be zero
lds ZL, screen_ptr ; add screen offset
lds ZH, screen_ptr+1
add ZL, r0
adc ZH, r1
movw ZERO, XSAV ; restore zero regs
brts .bvlin_white
.bvlin_black:
com r20 ; invert mask
1: ld r21, Z ; get existing byte
and r21, r20
st Z, r21
add ZL, r18 ; advance 1 line
adc ZH, ZERO
dec TOSL
brne 1b
popd
rnext
.bvlin_white:
1: ld r21, Z ; get existing byte
or r21, r20 ; or in the new pixel value
st Z, r21 ; store new byte
add ZL, r18 ; advance 1 line
adc ZH, ZERO
dec TOSL
brne 1b
popd
rnext
; assumes: stack is ( w -- ) and xy in TMPL/TMPH
opcode_hhlin_chk:
lds r20, bytesperline ; check x coord
cp TMPL, r20
brsh .nohhlin
tst TOSL ; width can't be zero
breq .nohhlin
; clip width to screen bounds
mov r21, TMPL ; add width to x origin
add r21, TOSL
brcs .cliphlin ; check for wraparound
cp r20, r21 ; check if endpoint > screen width
brsh 1f ; if in bounds, draw line
.cliphlin: ; otherwise, clip
mov TOSL, r20
sub TOSL, TMPL ; set line width to (screen width - x origin)
rjmp 1f
; HHLIN ( w xy -- ) draw horizontal line starting at xy and extending w pixels
; to the right, in current color
; No bounds checking is performed, and behavior is undefined if w=0.
opcode_hhlin:
nip ; get xy into TMP
lds r20, bytesperline
1: movw r18, ZERO ; mul will clobber the zero regs
mul r20, TMPH ; multiply y coord * bytes per line
add r0, TMPL ; add x coord
adc r1, r18 ; will be zero
lds ZL, screen_ptr ; add screen offset
lds ZH, screen_ptr+1
add ZL, r0
adc ZH, r1
movw ZERO, r18 ; restore zero regs
lds r20, globalcolor ; get color
2: st Z+, r20
dec TOSL
brne 2b
.nohhlin:
popd
rnext
; assumes: stack is ( w -- ) and xy in TMPL/TMPH
opcode_mhlin_chk:
lds r20, bytesperline
mov r18, r20 ; multiply bytes per line by 2
lsl r18
cp TMPL, r18 ; check x coord
brsh .nomhlin
tst TOSL ; width can't be zero
breq .nomhlin
; clip width to screen bounds
mov r21, TMPL ; add width to x origin
add r21, TOSL
brcs .clipmhlin ; check for wraparound
cp r18, r21 ; check if endpoint > screen width
brsh 1f ; if in bounds, draw line
.clipmhlin: ; otherwise, clip
mov TOSL, r18
sub TOSL, TMPL ; set line width to (screen width - x origin)
rjmp 1f
; MHLIN
; multiply y by bytesperline
; left shift x
; if carry set, write head byte and advance to next pixel, decrement width
; subtract 2 from width
; if width=0xFF, do the residual last column
opcode_mhlin:
nip ; get xy into TMP
lds r20, bytesperline
1: lds ZL, screen_ptr ; get screen offset
lds ZH, screen_ptr+1
movw r18, ZERO ; mul will clobber the zero regs
mul r20, TMPH ; multiply y coord * bytes per line
add ZL, r0 ; add row offset
adc ZH, r1
movw ZERO, r18 ; restore zero regs
lds r20, globalcolor ; get color
lsr TMPL ; x coord not byte-aligned at start?
brcc .mhlin_aligned
.mhlin_unaligned:
add ZL, TMPL ; add x offset to pointer
adc ZH, ZERO
ld r21, Z
andi r21, 0b11110000
mov r18, r20
andi r18, 0b00001111 ; apply masks
or r21, r18
st Z+, r21
dec TOSL ; decrement width
breq .mhlin_done ; we could already be done!
rjmp 2f
.mhlin_aligned:
add ZL, TMPL ; add x offset to pointer
adc ZH, ZERO
2: subi TOSL, 2 ; subtract 2 pixels from remaining width
brcs .mhline_residual
st Z+, r20
brne 2b
.nomhlin:
.mhlin_done:
popd
rnext
; one last pixel to clean up?
.mhline_residual:
ld r21, Z
andi r21, 0b00001111
mov r18, r20
andi r18, 0b11110000
or r21, r18
st Z+, r21
popd
rnext
; assumes: stack is ( w -- ) and xy in TMPL/TMPH
opcode_lhlin_chk:
lds r20, bytesperline
mov r18, r20 ; multiply bytes per line by 4
lsl r18
lsl r18
cp TMPL, r18 ; check x coord
brsh .nolhlin
tst TOSL ; width can't be zero
breq .nomhlin
; clip width to screen bounds
mov r21, TMPL ; add width to x origin
add r21, TOSL
brcs .cliplhlin ; check for wraparound
cp r18, r21 ; check if endpoint > screen width
brsh 1f ; if in bounds, draw line
.cliplhlin: ; otherwise, clip
mov TOSL, r18
sub TOSL, TMPL ; set line width to (screen width - x origin)
rjmp 1f
.nolhlin:
popd
rnext
; LHLIN ( w xy -- )
; preconditions: w > 0, 0 <= x <= 255
opcode_lhlin:
nip ; get xy into TMP
lds r20, bytesperline ; multiply y coord * bytes per line
1: lds ZL, screen_ptr ; get screen offset
lds ZH, screen_ptr+1
movw r18, ZERO ; mul will clobber the zero regs
mul r20, TMPH
add ZL, r0 ; add row offset
adc ZH, r1
movw ZERO, r18 ; restore zero regs
lds r20, globalcolor ; get color
mov TMPH, TMPL ; add width-1 to x coord
add TMPH, TOSL
dec TMPH
; TMPL: x coordinate of first pixel
; TMPH: x coordinate of last pixel
movw r18, TMP
andi r18, 0b00000011
andi r19, 0b00000011
; r18: lower 2 bits of first pixel x coordinate
; r19: lower 2 bits of last pixel x coordinate
lsr TMPH ; divide last x by 4 to get last byte offset
lsr TMPH
add TMPH, ZL ; lower 8 bits of the address of the last pixel's byte
lsr TMPL ; divide first x by 4
lsr TMPL
add ZL, TMPL ; add byte index to pointer
adc ZH, ZERO
; ZL: lower 8 bits of first pixel's byte
; TMPH: lower 8 bits of last pixel's byte
; if ZL==TOSH, the line starts and ends within the same byte
cp ZL, TMPH
breq .lhlin_tail
; if first pixel's start bit is not 0, we need to draw a "head" fragment
tst r18
breq .lhlin_body
.lhlin_head:
movw TOS, Z ; save Z because we have to do a table lookup
ldi ZH, hi8(lhlin_fragments)
mov ZL, r18 ; lower nibble: start bit
ori ZL, 0b00110000
lpm r21, Z
; draw head fragment into underlying byte
movw Z, TOS
ld TOSL, Z ; get underlying byte
mov TOSH, r20 ; get pixel color
and TOSH, r21 ; apply mask
com r21
and TOSL, r21 ; mask off bits we don't care about
or TOSL, TOSH ; or in the bits we want to set
st Z+, TOSL
ldi r18, 0
cp ZL, TMPH
breq .lhlin_tail
; body loop: write full bytes (4-pixel strides) until we reach the last byte
.lhlin_body:
ldi r18, 0
1: st Z+, r20
cp ZL, TMPH
brne 1b
.lhlin_tail:
; look at the last 2 bits of the start and end x coordinates, and look up the
; appropriate line fragment from a table
movw TOS, Z ; save Z because we have to do a table lookup
ldi ZH, hi8(lhlin_fragments)
mov ZL, r18 ; lower nibble: start bit
swap r19
or ZL, r19 ; upper nibble: end bit
lpm r21, Z ; get mask from table
; draw tail fragment into underlying byte
movw Z, TOS
ld TOSL, Z ; get underlying byte
and r20, r21 ; apply mask
com r21
and TOSL, r21 ; mask off bits we don't care about
or TOSL, r20 ; or in the bits we want to set
st Z, TOSL
3: popd
rnext
; assumes: stack is ( w -- ) and xy in TMPL/TMPH
opcode_bhlin_chk:
movw r18, ZERO ; mul will clobber the zero regs
lds r20, bytesperline ; compute x width
ldi r21, 8
mul r20, r21
cp TMPL, r0 ; check x coord, zero-extended to 16 bits
cpc r18, r1 ; (r18 will be zero)
brsh .nobhlin
cpi TOSL, 0 ; width can't be zero
cpc TOSH, r18 ; (r18 will be zero)
breq .nobhlin
; clip width to screen bounds
mov r21, TMPL ; add width to x origin
add r21, TOSL
brcs .clipbhlin ; check for wraparound
cp r0, r21 ; check if endpoint > screen width
cpc r1, r18 ; (r18 will be zero)
brsh 1f ; if in bounds, draw line
.clipbhlin: ; otherwise, clip
mov TOSL, r0
sub TOSL, TMPL ; set line width to (screen width - x origin)
rjmp 1f
.nobhlin:
movw ZERO, r18 ; restore zero regs
popd
rnext
; BHLIN ( w xy -- )
; preconditions: w > 0, 0 <= x <= 255
; if w=0, line will be 256 pixels wide
opcode_bhlin:
nip ; get xy into TMP
lds r20, bytesperline ; multiply y coord * bytes per line
movw r18, ZERO ; mul will clobber the zero regs
1: lds ZL, screen_ptr ; get screen offset
lds ZH, screen_ptr+1
mul r20, TMPH
add ZL, r0 ; add row offset
adc ZH, r1
movw ZERO, r18 ; restore zero regs
lds r20, globalcolor ; get color
mov TMPH, TMPL ; add width-1 to x coord
add TMPH, TOSL
dec TMPH
; TMPL: x coordinate of first pixel
; TMPH: x coordinate of last pixel
movw r18, TMP
andi r18, 0b00000111
andi r19, 0b00000111
; r18: lower 3 bits of first pixel x coordinate
; r19: lower 3 bits of last pixel x coordinate
lsr TMPH ; divide last x by 8 to get last byte offset
lsr TMPH
lsr TMPH
add TMPH, ZL ; lower 8 bits of the address of the last pixel's byte
lsr TMPL ; divide first x by 8
lsr TMPL
lsr TMPL
add ZL, TMPL ; add byte index to pointer
adc ZH, ZERO
;!!! TODO: use separate branches for black and white?
; ZL: lower 8 bits of first pixel's byte
; TMPH: lower 8 bits of last pixel's byte
; if ZL==TMPH, the line starts and ends within the same byte
cp ZL, TMPH
breq .bhlin_tail
; if first pixel's start bit is not 0, we need to draw a "head" fragment
tst r18
breq .bhlin_body
.bhlin_head:
movw TOS, Z ; save Z because we have to do a table lookup
ldi ZH, hi8(bhlin_fragments)
mov ZL, r18 ; lower nibble: start bit
ori ZL, 0b01110000
lpm r21, Z
; draw head fragment into underlying byte
movw Z, TOS
ld TOSL, Z ; get underlying byte
mov TOSH, r20 ; get pixel color
and TOSH, r21 ; apply mask
com r21
and TOSL, r21 ; mask off bits we don't care about
or TOSL, TOSH ; or in the bits we want to set
st Z+, TOSL
ldi r18, 0
cp ZL, TMPH
breq .bhlin_tail
; body loop: write full bytes (8-pixel strides) until we reach the last byte
.bhlin_body:
ldi r18, 0
1: st Z+, r20
cp ZL, TMPH
brne 1b
.bhlin_tail:
; look at the last 3 bits of the start and end x coordinates, and look up the
; appropriate line fragment from a table
movw TOS, Z ; save Z because we have to do a table lookup
ldi ZH, hi8(bhlin_fragments)
mov ZL, r18 ; lower nibble: start bit
swap r19
or ZL, r19 ; upper nibble: end bit
lpm r21, Z ; get mask from table
; draw tail fragment into underlying byte
movw Z, TOS
ld TOSL, Z ; get underlying byte
and r20, r21 ; apply mask
com r21
and TOSL, r21 ; mask off bits we don't care about
or TOSL, r20 ; or in the bits we want to set
st Z, TOSL
popd
rnext
; assumes: stack is ( wh -- ) and xy in TMPL/TMPH
opcode_hrect_chk:
lds r21, bytesperline ; check x coord
cp TMPL, r21
brsh .nohrect
tst TOSL ; width can't be zero
breq .nohrect
; clip width to screen bounds
mov r20, TMPL ; add width to x origin
add r20, TOSL
brcs .cliphrecth ; check for wraparound
cp r21, r20 ; check if endpoint > screen width
brsh 1f ; if in bounds, draw rect
.cliphrecth: ; otherwise, clip
mov TOSL, r21
sub TOSL, TMPL ; set line width to (screen width - x origin)
rjmp 1f
.nohrect:
.nomrect:
popd
rnext
; HRECT ( xy wh -- )
opcode_hrect:
nip ; get xy into TMP
lds r21, bytesperline ; multiply y coord * bytes per line
1: movw r18, ZERO ; mul will clobber the zero regs
mul r21, TMPH
add r0, TMPL ; add x coord
adc r1, r18 ; will be zero
lds ZL, screen_ptr ; add screen offset
lds ZH, screen_ptr+1
add ZL, r0
adc ZH, r1
movw ZERO, r18 ; restore zero regs
lds r20, globalcolor
sub r21, TOSL ; subtract rect width from screen width, giving byteskip btwn lines
; loop
; TOSL - width
; TOSH - height (y counter)
; r21 - number of bytes to skip to get to next row
; r20 - value to fill with
; r19 - x counter
.yloop: mov r19, TOSL ; reset x counter
.xloop: st Z+, r20
dec r19
brne .xloop
; end of x loop
add ZL, r21
adc ZH, ZEROL
dec TOSH
brne .yloop
3: popd
rnext
; assumes: stack is ( wh -- ) and xy in TMPL/TMPH
opcode_mrect_chk:
lds r21, bytesperline
mov r18, r21 ; multiply bytes per line by 2
lsl r18
cp TMPL, r18 ; check x coord
brsh .nomrect
tst TOSL ; width can't be zero
breq 3b
; clip width to screen bounds
mov r20, TMPL ; add width to x origin
add r20, TOSL
brcs .clipmrecth ; check for wraparound
cp r18, r20 ; check if endpoint > screen width
brsh 1f ; if in bounds, draw line
.clipmrecth: ; otherwise, clip
mov TOSL, r18
sub TOSL, TMPL ; set rect width to (screen width - x origin)
rjmp 1f
; MRECT ( xy wh -- )
; Drawn one row at a time, in (up to) three sections: head, body, tail
; Basically adds a loop around "MHLIN"
opcode_mrect:
nip ; get xy into TMP
lds r21, bytesperline
1: lds ZL, screen_ptr ; get screen offset
lds ZH, screen_ptr+1
movw r18, ZERO ; mul will clobber the zero regs
mul r21, TMPH ; multiply y coord * bytes per line
add ZL, r0
adc ZH, r1
movw ZERO, r18 ; restore zero regs
movw TSAV, TOS ; save copies of width/height
lds r20, globalcolor ; get fill color
bst TMPL, 0 ; set T flag if not byte-aligned
lsr TMPL ; divide width by 2, giving byte offset
; TSAVL - width in pixels
; TSAVH - height in pixels
; r18 - free
; r19 - free
; r20 - color
; r21 - bytes per line
; TOSL - width in pixels (horizontal loop counter)
; TOSH - height in pixels (vertical loop counter)
; XSAVL - saves ZL
; XSAVH - saves ZH
add ZL, TMPL ; add x offset to pointer
adc ZH, ZERO ; TMPL/TMPH are now free
rjmp .mrect_body_firstlinestart
.mrect_body_linestart:
mov TOSL, TSAVL ; initialize x counter
movw Z, XSAV ; rewind to start of line
add ZL, r21 ; advance to next line
adc ZH, ZERO
.mrect_body_firstlinestart:
movw XSAV, Z ; save address of line start
brtc .mrect_no_head ; not byte-aligned?
ld r19, Z
andi r19, 0b11110000
mov r18, r20
andi r18, 0b00001111 ; apply masks
or r19, r18
st Z+, r19
dec TOSL ; decrement width
breq 1f ; we could already be done (if width=1)
.mrect_no_head:
.mrect_body_innerloop:
subi TOSL, 2
brcs .mrect_tail ; end of line (with a pixel left over)?
st Z+, r20
brne .mrect_body_innerloop
1: dec TOSH ; decrement vertical count
brne .mrect_body_linestart
.mrect_done:
popd
rnext
.mrect_tail:
ld r19, Z
andi r19, 0b00001111
mov r18, r20
andi r18, 0b11110000
or r19, r18
st Z+, r19
dec TOSH
brne .mrect_body_linestart
.nolrect:
3: popd
rnext
; assumes: stack is ( wh -- ) and xy in TMPL/TMPH
opcode_lrect_chk:
lds r21, bytesperline
mov r18, r21 ; multiply bytes per line by 4
lsl r18
lsl r18
cp TMPL, r18 ; check x coord
brsh .nolrect
tst TOSL ; width can't be zero
breq 3b
; clip width to screen bounds
mov r20, TMPL ; add width to x origin
add r20, TOSL
brcs .cliplrecth ; check for wraparound
cp r18, r20 ; check if endpoint > screen width
brsh 1f ; if in bounds, draw line
.cliplrecth: ; otherwise, clip
mov TOSL, r18
sub TOSL, TMPL ; set line width to (screen width - x origin)
rjmp 1f
; LRECT ( xy wh -- )
; preconditions: w > 0, h > 0, 0 <= x <= 255
; Drawn in (at most) three vertical strips: head (if left edge occurs in the
; middle of a byte), body (written as full bytes--4 pixels--at a time), and tail
; (if right edge occurs in the middle of a byte)
opcode_lrect:
nip ; get xy into TMP
lds r21, bytesperline ; multiply y coord * bytes per line
1: lds ZL, screen_ptr ; get screen offset
lds ZH, screen_ptr+1
movw r18, ZERO ; mul will clobber the zero regs
mul r21, TMPH
add ZL, r0
adc ZH, r1
movw ZERO, r18 ; restore zero regs
lds r20, globalcolor ; get color
movw TSAV, TOS ; save copies of width/height
mov TMPH, TMPL ; add width-1 to x coord
add TMPH, TOSL
dec TMPH
; TMPL: x coordinate of first pixel
; TMPH: x coordinate of last pixel
movw r18, TMP
andi r18, 0b00000011
andi r19, 0b00000011
; r18: lower 2 bits of first pixel x coordinate
; r19: lower 2 bits of last pixel x coordinate
lsr TMPH ; divide last x by 4 to get last byte offset
lsr TMPH
lsr TMPL ; divide first x by 4
lsr TMPL
add ZL, TMPL ; add byte index to pointer
adc ZH, ZERO
sub TMPH, TMPL ; number of full bytes in each line
breq .lrect_tail ; if 0, rect's x extent starts and ends within the same byte
; if first pixel's start bit is not 0, we need to draw a "head" strip
tst r18
breq .lrect_body
.lrect_head:
movw XSAV, Z ; save origin (the table lookup will clobber Z)
ldi ZH, hi8(lhlin_fragments)
mov ZL, r18 ; lower nibble: start bit
ori ZL, 0b00110000
lpm TSAVL, Z
movw Z, XSAV ; restore Z since it's clobbered by lpm
mov TOSH, r20 ; get pixel color
and TOSH, TSAVL ; apply mask
com TSAVL
mov r18, TSAVH ; reuse r18 as a loop count, we need to zero it anyway
1: ld TOSL, Z ; get underlying byte
and TOSL, TSAVL ; mask off bits we don't care about
or TOSL, TOSH ; or in the bits we want to set
st Z, TOSL
add ZL, r21 ; advance one line
adc ZH, ZERO
dec r18
brne 1b
movw Z, XSAV ; restore Z to origin
adiw Z, 1 ; advance to next byte
dec TMPH ; one less byte in body
breq .lrect_tail
.lrect_body:
movw TOS, Z ; save origin
mov r18, TSAVH ; reuse r18 as a loop count, we need to zero it anyway
mov TSAVL, r21 ; compute number of bytes to skip to get to next line
sub TSAVL, TMPH
1: mov TMPL, TMPH ; initalize horizontal loop count
2: st Z+, r20
dec TMPL
brne 2b
add ZL, TSAVL ; advance to next line
adc ZH, ZERO
dec r18
brne 1b
movw Z, TOS ; restore origin
add ZL, TMPH ; advance to byte after the first line
adc ZH, ZERO
.lrect_tail:
; look at the last 2 bits of the start and end x coordinates, and look up the
; appropriate line fragment from a table
movw TOS, Z ; save Z because we have to do a table lookup
ldi ZH, hi8(lhlin_fragments)
mov ZL, r18 ; lower nibble: start bit
swap r19
or ZL, r19 ; upper nibble: end bit
lpm r19, Z ; get mask from table
movw Z, TOS
and r20, r19 ; apply mask to color
com r19 ; invert mask
mov r18, TSAVH ; initialize loop counter to height
; draw tail fragment into underlying byte
1: ld TOSL, Z ; get underlying byte
and TOSL, r19 ; mask off bits we don't care about
or TOSL, r20 ; or in the bits we want to set
st Z, TOSL
add ZL, r21 ; advance one line
adc ZH, ZERO
dec r18
brne 1b
popd
rnext
; assumes: stack is ( wh -- ) and xy in TMPL/TMPH
opcode_brect_chk:
movw r18, ZERO ; mul will clobber the zero regs
lds r21, bytesperline ; compute x width
ldi r20, 8
mul r21, r20
cp TMPL, r0 ; check x coord, zero-extended to 16 bits
cpc r18, r1 ; (r18 will be zero)
brsh .nobrect
tst TOSL ; width can't be zero
breq .nobrect
; clip width to screen bounds
mov r20, TMPL ; add width to x origin
add r20, TOSL
brcs .clipbrecth ; check for wraparound
cp r0, r20 ; check if endpoint > screen width
cpc r1, r18 ; (r18 will be zero)
brsh 1f ; if in bounds, draw line
.clipbrecth: ; otherwise, clip
mov TOSL, r0
sub TOSL, TMPL ; set line width to (screen width - x origin)
rjmp 1f
.nobrect:
movw ZERO, r18 ; restore zero regs
popd
rnext
opcode_brect:
nip ; get width into TMPL and height into TMPH
lds r21, bytesperline ; multiply y coord * bytes per line
movw r18, ZERO ; mul will clobber the zero regs
1: lds ZL, screen_ptr ; get screen offset
lds ZH, screen_ptr+1
mul r21, TMPH
add ZL, r0
adc ZH, r1
movw ZERO, r18 ; restore zero regs
lds r20, globalcolor ; get color
movw TSAV, TOS ; save copies of width/height
mov TMPH, TMPL ; add width-1 to x coord
add TMPH, TOSL
dec TMPH
; TMPL: x coordinate of first pixel
; TMPH: x coordinate of last pixel
movw r18, TMP
andi r18, 0b00000111
andi r19, 0b00000111
; r18: lower 3 bits of first pixel x coordinate
; r19: lower 3 bits of last pixel x coordinate
lsr TMPH ; divide last x by 8 to get last byte offset
lsr TMPH
lsr TMPH
lsr TMPL ; divide first x by 8
lsr TMPL
lsr TMPL
add ZL, TMPL ; add byte index to pointer
adc ZH, ZERO
sub TMPH, TMPL ; number of full bytes in each line
breq .brect_tail ; if 0, rect's x extent starts and ends within the same byte
; if first pixel's start bit is not 0, we need to draw a "head" strip
tst r18
breq .brect_body
;!!! TODO: use separate branches for black and white heads/tails?
.brect_head:
movw XSAV, Z ; save origin (the table lookup will clobber Z)
ldi ZH, hi8(bhlin_fragments)
mov ZL, r18 ; lower nibble: start bit
ori ZL, 0b01110000
lpm TSAVL, Z
movw Z, XSAV ; restore Z since it's clobbered by lpm
mov TOSH, r20 ; get pixel color
and TOSH, TSAVL ; apply mask
com TSAVL
mov r18, TSAVH ; reuse r18 as a loop count, we need to zero it anyway
1: ld TOSL, Z ; get underlying byte
and TOSL, TSAVL ; mask off bits we don't care about
or TOSL, TOSH ; or in the bits we want to set
st Z, TOSL
add ZL, r21 ; advance one line
adc ZH, ZERO
dec r18
brne 1b
movw Z, XSAV ; restore Z to origin
adiw Z, 1 ; advance to next byte
dec TMPH ; one less byte in body
breq .brect_tail
.brect_body:
movw TOS, Z ; save origin
mov r18, TSAVH ; reuse r18 as a loop count, we need to zero it anyway
mov TSAVL, r21 ; compute number of bytes to skip to get to next line
sub TSAVL, TMPH
1: mov TMPL, TMPH ; initalize horizontal loop count
2: st Z+, r20
dec TMPL
brne 2b
add ZL, TSAVL ; advance to next line
adc ZH, ZERO
dec r18
brne 1b
movw Z, TOS ; restore origin
add ZL, TMPH ; advance to byte after the first line
adc ZH, ZERO
.brect_tail:
; look at the last 2 bits of the start and end x coordinates, and look up the
; appropriate line fragment from a table
movw TOS, Z ; save Z because we have to do a table lookup
ldi ZH, hi8(bhlin_fragments)
mov ZL, r18 ; lower nibble: start bit
swap r19
or ZL, r19 ; upper nibble: end bit
lpm r19, Z ; get mask from table
movw Z, TOS
and r20, r19 ; apply mask to color
com r19 ; invert mask
mov r18, TSAVH ; initialize loop counter to height
; draw tail fragment into underlying byte
1: ld TOSL, Z ; get underlying byte
and TOSL, r19 ; mask off bits we don't care about
or TOSL, r20 ; or in the bits we want to set
st Z, TOSL
add ZL, r21 ; advance one line
adc ZH, ZERO
dec r18
brne 1b
popd
rnext
; HLINE ( xy1 xy2 -- ) draw a line from point xy1 to point xy2 using Bresenham's
; line algorithm (high-color bitmap modes)
; Lines are always drawn left-to-right.
opcode_hline_chk:
opcode_hline:
nip ; get xy1 into TMP
; TMPL=x1, TMPH=y1, TOSL=x2, TOSH=y2. if x2 < x1, swap xy1 and xy2.
cp TOSL, TMPL
brsh 1f
movw r20, TMP
movw TMP, TOS
movw TOS, r20
; at this point, x1 <= x2. TMP is the starting coordinate
1: movw r18, ZERO ; mul will clobber the zero regs
clr r21 ; r21:r20 - signed number of bytes to advance each line
lds r20, bytesperline ; multiply y coord * bytes per line
mul TMPH, r20 ; get byte offset for y coord
add r0, TMPL ; add x coord
adc r1, r18 ; will be zero
lds ZL, screen_ptr ; add to screen offset
lds ZH, screen_ptr+1
add ZL, r0
adc ZH, r1
movw ZERO, r18 ; restore zero regs
lds r19, globalcolor
; Z is now the location of the first byte
; TOSL-TMPL is the line width (always nonnegative)
sub TOSL, TMPL
; compute absolute difference between y coordinates to determine line slope
sub TOSH, TMPH
brcc 1f
com r21 ;if negative dy, negate byte offset between rows
neg r20
sbci r21, -1
neg TOSH
1:
; TOSL is dx = abs(x2-x1). TOSH is dy = abs(y2-y1)
cp TOSH, TOSL
brlo .hshallow
; "steep" lines (dy > dx)
.hsteep:
; TMP holds 2*dx. (signed 16-bit)
mov TMPL, TOSL
clr TMPH
lsl TMPL
rol TMPH
; r18 is the loop counter (initialized to dy)
mov r18, TOSH
; XSAV holds 2*dy
mov XSAVL, TOSH
clr XSAVH
lsl XSAVL
rol XSAVH
; TOS is the error accumulator, initialized to 2*dx - dy
movw TOS, TMP
sub TOSL, r18
sbc TOSH, ZEROL
; Now draw the pixels. One iteration per row.
1: st Z, r19
; is D (error accumulator) > 0?
tstw TOS ; will always clear carry
breq 2f
brmi 2f
; if so, subtract 2*dy from error accumulator and advance to next column
sub TOSL, XSAVL
sbc TOSH, XSAVH
sec
; advance to next row
2: adc ZL, r20 ; explicitly add the carry flag, it indicates if we need to move right one column
adc ZH, r21
; add 2*dx to error accumulator
2: add TOSL, TMPL
adc TOSH, TMPH
; decrement loop count
subi r18, 1 ; don't use dec--it doesn't set the carry flag!
brcc 1b
3: popd
rnext
; "shallow" lines (dy <= dx)
.hshallow:
; TMP holds 2*dy. (signed 16-bit)
mov TMPL, TOSH
clr TMPH
lsl TMPL
rol TMPH
; r18 is the loop counter (initialized to dx)
mov r18, TOSL
; XSAV holds 2*dx
mov XSAVL, TOSL
clr XSAVH
lsl XSAVL
rol XSAVH
; TOS is the error accumulator, initialized to 2*dy - dx
movw TOS, TMP
sub TOSL, r18
sbc TOSH, ZEROL
; Now draw the pixels. One iteration per column.
1: st Z+, r19 ; write pixel and advance right
; is D (error accumulator) > 0?
tstw TOS
breq 2f
brmi 2f
; if so, subtract 2*dx from error accumulator and advance to next row
sub TOSL, XSAVL
sbc TOSH, XSAVH
add ZL, r20
adc ZH, r21
; add 2*dy to error accumulator
2: add TOSL, TMPL
adc TOSH, TMPH
; decrement loop count
subi r18, 1 ; don't use dec--it doesn't set the carry flag!
brcc 1b
3: popd
rnext
opcode_mline_chk:
opcode_mline:
nip ; get xy1 into TMP
; TMPL=x1, TMPH=y1, TOSL=x2, TOSH=y2. if x2 < x1, swap xy1 and xy2.
cp TOSL, TMPL
brsh 1f
movw r20, TMP
movw TMP, TOS
movw TOS, r20
; at this point, x1 <= x2. TMP is the starting coordinate
1: movw r18, ZERO ; mul will clobber the zero regs
clr r21 ; r21:r20 - signed number of bytes to advance each line
lds r20, bytesperline ; multiply y coord * bytes per line
mul TMPH, r20 ; get byte offset for y coord
bst TMPL, 0 ; starting on an odd or even pixel?
mov ZL, TMPL ; divide x coord by 2 to get x byte offset
lsr ZL
add r0, ZL ; add x byte offset
adc r1, r18 ; r18 will be zero
lds ZL, screen_ptr ; add to screen offset
lds ZH, screen_ptr+1
add ZL, r0
adc ZH, r1
movw ZERO, r18 ; restore zero regs
; Z is now the location of the first byte
; TOSL-TMPL is the line width (always nonnegative)
sub TOSL, TMPL
; compute absolute difference between y coordinates to determine line slope
sub TOSH, TMPH
brcc 1f
; r21:r20 - signed number of bytes to advance each line
com r21 ;if negative dy, negate byte offset between rows
neg r20
sbci r21, -1
neg TOSH
1:
; TOSL is dx = abs(x2-x1). TOSH is dy = abs(y2-y1)
cp TOSH, TOSL
brlo .mshallow
; "steep" lines (dy > dx)
.msteep:
; r18 holds the mask to apply to the existing byte
; r19 holds the pattern to be or-ed into the existing byte
lds r19, globalcolor
brtc 2f ; starting on an odd or even column?
ldi r18, 0b11110000
andi r19, 0b00001111
rjmp 3f
2: ldi r18, 0b00001111
andi r19, 0b11110000
; TMP holds 2*dx. (signed 16-bit)
3: mov TMPL, TOSL
clr TMPH
lsl TMPL
rol TMPH
; r16 is the loop counter (initialized to dy)
mov r16, TOSH
; XSAV holds 2*dy
mov XSAVL, TOSH
clr XSAVH
lsl XSAVL
rol XSAVH
; TOS is the error accumulator, initialized to 2*dx - dy
movw TOS, TMP
sub TOSL, r16
sbc TOSH, ZEROL
; This is the simpler case. Since the line is one pixel wide, and only one
; byte per row is modified, we will only need to modify one nibble per row.
; Thus, we use the same read-modify-write process for each byte.
4: ld TSAVL, Z ; read existing pixel, use TSAVL as a temporary
and TSAVL, r18 ; apply mask
or TSAVL, r19 ; or in the new pixels
st Z, TSAVL
; is D (error accumulator) > 0?
tstw TOS ; will always clear carry
breq 5f
brmi 5f
; if so, subtract 2*dy from error accumulator and advance to next column
sub TOSL, XSAVL
sbc TOSH, XSAVH
swap r18 ; swap nibbles of pixel masks
swap r19
cpi r18, 0b11110000 ; set carry flag if we need to advance one byte to the right
; advance to next row
5: adc ZL, r20 ; explicitly add the carry flag, it indicates if we need to move right one column
adc ZH, r21
; add 2*dx to error accumulator
add TOSL, TMPL
adc TOSH, TMPH
; decrement loop count
subi r16, 1 ; don't use dec--it doesn't set the carry flag!
brcc 4b
popd
rnext
; "shallow" lines (dy <= dx)
.mshallow:
; TSAV holds 2*dy. (signed 16-bit)
mov TSAVL, TOSH
clr TSAVH
lsl TSAVL
rol TSAVH
; r16 is the loop counter (initialized to dx)
mov r16, TOSL
; XSAV holds 2*dx
mov XSAVL, TOSL
clr XSAVH
lsl XSAVL
rol XSAVH
; TOS is the error accumulator, initialized to 2*dy - dx
movw TOS, TSAV
sub TOSL, r16
sbc TOSH, ZEROL
; This is more complicated. For a given byte, we may need to set either the left
; pixel, the right pixel, or both. In the case where both pixels need to be set
; (i.e. we are drawing a run of 2 or more pixels) we'd like to avoid doing two
; read-modify-writes, because all we really need to do is a single write, setting
; both nibbles to the new color value.
ser r19 ; initialize mask indicating which nibbles of the current byte will be written
lds LINKL, globalcolor
mov TMPL, LINKL
andi TMPL, 0b11110000 ; cache current color in left/right nibbles
mov TMPH, LINKL
andi TMPH, 0b00001111
brts 3f ; starting on an even or odd column?
; Left pixel.
1: ldi r19, 0b00001111 ; initialize mask
; is D (error accumulator) > 0?
tstw TOS
breq 2f
brmi 2f
; if so, update left pixel of current byte only, reset mask
ld r18, Z
and r18, r19 ; apply mask to existing byte
or r18, TMPL ; or in the current color
st Z, r18 ; update byte
ser r19
; subtract 2*dx from error accumulator and advance to next row
sub TOSL, XSAVL
sbc TOSH, XSAVH
add ZL, r20
adc ZH, r21
; add 2*dy to error accumulator
2: add TOSL, TSAVL
adc TOSH, TSAVH
; decrement loop count
subi r16, 1 ; don't use dec--it doesn't set the carry flag!
brcs 5f
; Right pixel.
3: andi r19, 0b11110000 ; mask
mov r18, LINKL ; byte to be written (initially filled with current color)
breq 9f ; avoid read-modify-write if we are updating the entire byte
ld r18, Z
and r18, r19
or r18, TMPH
9: st Z+, r18
; is D (error accumulator) > 0?
tstw TOS
breq 4f
brmi 4f
; if so, update right pixel,
; subtract 2*dx from error accumulator and advance to next row
sub TOSL, XSAVL
sbc TOSH, XSAVH
add ZL, r20
adc ZH, r21
; add 2*dy to error accumulator
4: add TOSL, TSAVL
adc TOSH, TSAVH
; decrement loop count
subi r16, 1 ; don't use dec--it doesn't set the carry flag!
brcc 1b
popd
rnext
; finish up last byte (if line ends on an even column and that byte hasn't been written to)
5: cpi r19, 0xFF ; end right away if mask indicates neither pixel should be touched
breq 6f
ld r18, Z
andi r18, 0b00001111
or r18, TMPL
st Z, r18
6: popd
rnext
opcode_lline_chk:
; LLINE ( xy1 xy2 -- ) draw a line from point xy1 to point xy2 (low-color bitmap
; modes)
opcode_lline:
nip ; get xy1 into TMP
; TMPL=x1, TMPH=y1, TOSL=x2, TOSH=y2. if x2 < x1, swap xy1 and xy2.
cp TOSL, TMPL
brsh 1f
movw r20, TMP
movw TMP, TOS
movw TOS, r20
; at this point, x1 <= x2. TMP is the starting coordinate
1: mov ZL, TMPL ; get bit mask for x position
ldi ZH, hi8(crumbmasktable)
lpm TSAVH, Z ; select the correct bit mask for this x pos (before we need to use Z)
movw XSAV, ZERO ; mul will clobber the zero regs
clr r21 ; r21:r20 - signed number of bytes to advance each line
lds r20, bytesperline ; multiply y coord * bytes per line
mul TMPH, r20 ; get byte offset for y coord
mov ZL, TMPL ; divide x coord by 4 to get x byte offset
lsr ZL
lsr ZL
add r0, ZL ; add x byte offset
adc r1, XSAVL ; XSAVL will be zero
lds ZL, screen_ptr ; add to screen offset
lds ZH, screen_ptr+1
add ZL, r0
adc ZH, r1
movw ZERO, XSAV ; restore zero regs
; Z is now the location of the first byte
; TOSL-TMPL is the line width (always nonnegative)
sub TOSL, TMPL
; compute absolute difference between y coordinates to determine line slope
sub TOSH, TMPH
brcc 1f
; r21:r20 - signed number of bytes to advance each line
com r21 ;if negative dy, negate byte offset between rows
neg r20
sbci r21, -1
neg TOSH
1:
; TOSL is dx = abs(x2-x1). TOSH is dy = abs(y2-y1)
cp TOSH, TOSL
brlo .lshallow
; "steep" lines (dy > dx)
.lsteep:
; initialize bitmasks
lds r19, globalcolor ; initialize color
mov r18, r19
andi r18, 0b11000000 ; r18 holds a copy of the color for every 4th column
and r19, TSAVH ; r19 is the color or'd in
com TSAVH ; TSAVH is the mask applied to existing bytes
; TMP holds 2*dx. (signed 16-bit)
mov TMPL, TOSL
clr TMPH
lsl TMPL
rol TMPH
; r16 is the loop counter (initialized to dy)
mov r16, TOSH
; XSAV holds 2*dy
mov XSAVL, TOSH
clr XSAVH
lsl XSAVL
rol XSAVH
; TOS is the error accumulator, initialized to 2*dx - dy
movw TOS, TMP
sub TOSL, r16
sbc TOSH, ZEROL
; This is the simpler case. Since the line is one pixel wide, and only one
; byte per row is modified, we will only need to modify one crumb per row.
; Thus, we use the same read-modify-write process for each byte.
1: ld TSAVL, Z ; read existing pixel, use TSAVL as a temporary
and TSAVL, TSAVH ; apply mask
or TSAVL, r19 ; or in the new pixels
st Z, TSAVL
; is D (error accumulator) > 0?
tstw TOS ; will always clear carry
breq 2f
brmi 2f
; if so, subtract 2*dy from error accumulator and advance to next column
sub TOSL, XSAVL
sbc TOSH, XSAVH
; shift color to the right
lsr r19
lsr r19
; rotate mask to the right
bst TSAVH, 0
lsr TSAVH
bld TSAVH, 7
asr TSAVH ; duplicate msb
brcs 2f
; if carry was cleared, mask is 0b00111111. color needs to be reset and Z needs to advance 1 byte
mov r19, r18
adiw Z, 1
; advance to next row
2: add ZL, r20
adc ZH, r21
; add 2*dx to error accumulator
add TOSL, TMPL
adc TOSH, TMPH
; decrement loop count
subi r16, 1 ; don't use dec--it doesn't set the carry flag!
brcc 1b
popd
rnext
; "shallow" lines (dy <= dx)
.lshallow:
; TMP holds 2*dy. (signed 16-bit)
mov TMPL, TOSH
clr TMPH
lsl TMPL
rol TMPH
; r16 is the loop counter (initialized to dx)
mov r16, TOSL
; XSAV holds 2*dx
mov XSAVL, TOSL
clr XSAVH
lsl XSAVL
rol XSAVH
; TOS is the error accumulator, initialized to 2*dy - dx
movw TOS, TMP
sub TOSL, r16
sbc TOSH, ZEROL
; initialize masks
lds r18, globalcolor
com TSAVH ; mask to apply for this pixel (2 bits always zero)
ser r19 ; mask to apply for this byte
; This is more complicated. For a given byte, we may need to set between one and
; four crumbs. We'd like to avoid redundant read-modify-writes as much as possible,
; ideally using a single read-modify-write in cases where one, two, or three
; crumbs need to be set, and ideally use a single write in the case where all
; four crumbs need to be set to the new color value.
1: bst TSAVH, 0 ; save lsb of pixel mask
mov TSAVL, r18 ; get color
and r19, TSAVH ; update byte mask
breq 2f ; if byte mask is all zeros, don't need read-modify-write
com TSAVH ; invert mask
and TSAVL, TSAVH ; isolate pixels we want to write
com TSAVH ; put mask back
ld LINKL, Z ; read existing pixel
and LINKL, TSAVH ; mask out pixels we don't want to write
or TSAVL, LINKL ; combine
2: st Z, TSAVL ; store
brts 3f ; add 1 to Z and reset byte mask if we crossed a byte boundary
ser r19
adiw Z, 1
3: lsr TSAVH ; rotate pixel mask
bld TSAVH, 7
asr TSAVH ; duplicate msb. if T is clear, we crossed a byte boundary
; is D (error accumulator) > 0?
tstw TOS
breq 4f
brmi 4f
; if so, subtract 2*dx from error accumulator and advance to next row
sub TOSL, XSAVL
sbc TOSH, XSAVH
add ZL, r20
adc ZH, r21
ser r19 ; reset byte mask if we advance down a row
; add 2*dy to error accumulator
4: add TOSL, TMPL
adc TOSH, TMPH
; decrement loop count
subi r16, 1 ; don't use dec--it doesn't set the carry flag!
brcc 1b
popd
rnext
opcode_bline_chk:
; BLINE ( xy1 xy2 -- ) draw a line from point xy1 to point xy2 (monochrome bitmap
; modes <= 256 pixels wide)
opcode_bline:
nip ; get xy1 into TMP
; TMPL=x1, TMPH=y1, TOSL=x2, TOSH=y2. if x2 < x1, swap xy1 and xy2.
cp TOSL, TMPL
brsh 1f
movw r20, TMP
movw TMP, TOS
movw TOS, r20
; at this point, x1 <= x2. TMP is the starting coordinate
1: mov ZL, TMPL ; get bit mask for x position
ldi ZH, hi8(bitmasktable)
lpm r19, Z ; select the correct bit mask for this x pos (before we need to use Z)
movw XSAV, ZERO ; mul will clobber the zero regs
clr r21 ; r21:r20 - signed number of bytes to advance each line
lds r20, bytesperline ; multiply y coord * bytes per line
mul TMPH, r20 ; get byte offset for y coord
mov ZL, TMPL ; divide x coord by 8 to get x byte offset
lsr ZL
lsr ZL
lsr ZL
add r0, ZL ; add x byte offset
adc r1, XSAVL ; XSAVL will be zero
lds ZL, screen_ptr ; add to screen offset
lds ZH, screen_ptr+1
add ZL, r0
adc ZH, r1
movw ZERO, XSAV ; restore zero regs
; Z is now the location of the first byte
; TOSL-TMPL is the line width (always nonnegative)
sub TOSL, TMPL
; compute absolute difference between y coordinates to determine line slope
sub TOSH, TMPH
brcc 1f
; r21:r20 - signed number of bytes to advance each line
com r21 ;if negative dy, negate byte offset between rows
neg r20
sbci r21, -1
neg TOSH
1:
; TOSL is dx = abs(x2-x1). TOSH is dy = abs(y2-y1)
cp TOSH, TOSL
brlo .bshallow
; "steep" lines (dy > dx)
.bsteep:
; TMP holds 2*dx. (signed 16-bit)
mov TMPL, TOSL
clr TMPH
lsl TMPL
rol TMPH
; r16 is the loop counter (initialized to dy)
mov r16, TOSH
; XSAV holds 2*dy
mov XSAVL, TOSH
clr XSAVH
lsl XSAVL
rol XSAVH
; TOS is the error accumulator, initialized to 2*dx - dy
movw TOS, TMP
sub TOSL, r16
sbc TOSH, ZEROL
; check lsb of color--white or black?
lds r18, globalcolor
sbrs r18, 0
rjmp .bsteep_black
.bsteep_white:
1: ld r18, Z ; read existing pixel
or r18, r19 ; or in the new pixel
st Z, r18
; is D (error accumulator) > 0?
tstw TOS ; will always clear carry
breq 2f
brmi 2f
; if so, subtract 2*dy from error accumulator and advance to next column
sub TOSL, XSAVL
sbc TOSH, XSAVH
; rotate mask to the right
; sets carry flag when when the pattern repeats (i.e. a 1 is shifted out)
bst r19, 0
lsr r19
bld r19, 7
; advance to next row
2: adc ZL, r20 ; if carry flag is set, also advance 1 column to the right
adc ZH, r21
; add 2*dx to error accumulator
add TOSL, TMPL
adc TOSH, TMPH
; decrement loop count
subi r16, 1 ; don't use dec--it doesn't set the carry flag!
brcc 1b
popd
rnext
; "shallow" lines (dy <= dx)
.bshallow:
; TMP holds 2*dy. (signed 16-bit)
mov TMPL, TOSH
clr TMPH
lsl TMPL
rol TMPH
; r16 is the loop counter (initialized to dx)
mov r16, TOSL
; XSAV holds 2*dx
mov XSAVL, TOSL
clr XSAVH
lsl XSAVL
rol XSAVH
; TOS is the error accumulator, initialized to 2*dy - dx
movw TOS, TMP
sub TOSL, r16
sbc TOSH, ZEROL
; check lsb of color--white or black?
lds r18, globalcolor
sbrs r18, 0
rjmp .bshallow_black
.bshallow_white:
; initialize bitmasks
clr r18 ; bits to or in for this byte
; draw pixels
; Unlike with other color depths, it's faster to always read-modify-write than
; check if r18=0xFF and branch
1: bst r19, 0 ; save lsb of pixel mask
or r18, r19 ; update byte mask
ld TSAVL, Z ; read existing byte
or TSAVL, r18 ; set pixels
st Z, TSAVL ; store
brtc 2f ; add 1 to Z and reset byte mask if we crossed a byte boundary
clr r18
adiw Z, 1
2: lsr r19 ; rotate pixel mask
bld r19, 7
; is D (error accumulator) > 0?
tstw TOS
breq 3f
brmi 3f
; if so, subtract 2*dx from error accumulator and advance to next row
sub TOSL, XSAVL
sbc TOSH, XSAVH
add ZL, r20
adc ZH, r21
clr r18 ; reset byte mask if we advance down a row
; add 2*dy to error accumulator
3: add TOSL, TMPL
adc TOSH, TMPH
; decrement loop count
subi r16, 1 ; don't use dec--it doesn't set the carry flag!
brcc 1b
popd
rnext
.bsteep_black:
com r19 ; invert pixel mask
1: ld r18, Z ; read existing pixel
and r18, r19 ; turn off the new pixel
st Z, r18
; is D (error accumulator) > 0?
tstw TOS ; will always clear carry
breq 2f
brmi 2f
; if so, subtract 2*dy from error accumulator and advance to next column
sub TOSL, XSAVL
sbc TOSH, XSAVH
; rotate mask to the right
; clears carry flag when when the pattern repeats (i.e. a 0 is shifted out)
bst r19, 0
lsr r19
bld r19, 7
cpi r19, 0b10000000 ; set carry flag if msb of r19 is 0 (i.e. a 0 was just shifted out)
; advance to next row
2: adc ZL, r20 ; if carry flag is set, also advance 1 column to the right
adc ZH, r21
; add 2*dx to error accumulator
add TOSL, TMPL
adc TOSH, TMPH
; decrement loop count
subi r16, 1 ; don't use dec--it doesn't set the carry flag!
brcc 1b
popd
rnext
.bshallow_black:
; initialize bitmasks
com r19 ; invert pixel mask
ser r18 ; initialize byte mask
; draw pixels
; Unlike with other color depths, it's faster to always read-modify-write than
; check if r18=0xFF and branch
1: bst r19, 0 ; save lsb of pixel mask
and r18, r19 ; update byte mask
ld TSAVL, Z ; read existing byte
and TSAVL, r18 ; clear pixels
st Z, TSAVL ; store
brts 2f ; add 1 to Z and reset byte mask if we crossed a byte boundary (a 0 was shifted out)
ser r18
adiw Z, 1
2: lsr r19 ; rotate pixel mask
bld r19, 7
; is D (error accumulator) > 0?
tstw TOS
breq 3f
brmi 3f
; if so, subtract 2*dx from error accumulator and advance to next row
sub TOSL, XSAVL
sbc TOSH, XSAVH
add ZL, r20
adc ZH, r21
ser r18 ; reset byte mask if we advance down a row
; add 2*dy to error accumulator
3: add TOSL, TMPL
adc TOSH, TMPH
; decrement loop count
subi r16, 1 ; don't use dec--it doesn't set the carry flag!
brcc 1b
popd
rnext
; Interpreter dispatch table aligned to a 256-word (512-byte) boundary.
.align 9
.global vm_dispatch_table
vm_dispatch_table:
create_dispatch_table .opcode_, 255
.align 0
; 0xFF: (EXT) extended instruction
opcode_ext:
ldi DTH, pm_hi8(vm_ext_dispatch_table)
next
; (CALL) ( R: -- a ) push IP onto return stack and jump to address
opcode_call:
ld TMPL, IP+ ; get lower byte of new IP
pushr ; push return address
mov IPL, TMPL ; set new IP lower byte
mov IPH, IR ; set new IP upper byte
next
; callable from C (error code in r24)
.global forth_throw_if
forth_throw_if:
tstw r24
brne forth_throw
ret
; callable from C (error code in r24)
.global forth_throw
forth_throw:
; move error code into r21:r20
movw r20, r24
; restore the constant registers. the exception may have been thrown from within
; a C function that clobbered them.
clr ZEROL
clr ZEROH
movw TRUE, ZERO
com TRUEL
com TRUEH
ldi CDTH, pm_hi8(vm_dispatch_table)
lds ZL, forth_flags
sbrc ZL, FF_TRACE_BIT
ldi CDTH, pm_hi8(vm_debug_dispatch_table)
; exception number in r21:r20
.global do_throw
do_throw:
; set T flag, indicating an exception code is present
set
; get current exception frame
lds ZL, forth_exception_frame
lds ZH, forth_exception_frame+1
; invoke the global exception handler if no current frame
sbrc ZH, 7
jmp forth_global_exception_handler
; roll the return stack back to the top of the exception frame
z_to_rsp
; pop and restore the address of the previous frame
pop ZL
pop ZH
sts forth_exception_frame, ZL
sts forth_exception_frame+1, ZH
; pop and jump to the exception handler
pop ZL
pop ZH
ijmp
; BREAK ( -- ) jump to the current exception handler, without popping the
; exception frame or pushing an error code
opcode_break:
; clear T flag, indicating there is no exception code
clt
; get current exception frame
lds ZL, forth_exception_frame
lds ZH, forth_exception_frame+1
; invoke the global exception handler if no current frame
sbrc ZH, 7
jmp forth_global_exception_handler
; otherwise, read the exception handler address out of the current context
ldd TMPL, Z+3
ldd TMPH, Z+4
movw Z, TMP
ijmp
; 0 ( -- 0 ) push zero on stack
opcode_zero:
pushd
movw TOS, ZERO
next
; -1 ( -- 0xFFFF ) push -1 on stack
opcode_minus1:
pushd
movw TOS, TRUE
next
; (C#) ( -- c ) push 8-bit (unsigned) literal from instruction stream
opcode_lit8:
pushd
ld TOSL, IP+
ldi TOSH, 0
next
; (#) ( -- n ) push 16-bit (little-endian) literal from instruction stream
opcode_lit16:
pushd
ld TOSL, IP+
ld TOSH, IP+
next
; (S") ( -- addr len ) literal string in instruction stream (0-255 bytes); push address and length, then skip over string
opcode_litstr:
ld TMPL, IP+ ; get string length from instruction stream
clr TMPH
pushd
movw TOS, IP ; push address of string
pushd
movw TOS, TMP ; push length
add IPL, TOSL ; skip over string
adc IPH, TOSH
next
; DUP ( n -- n n ) duplicate TOS
opcode_dup:
pushd
next
; DROP ( n -- ) remove from data stack
opcode_drop:
popd
next
; NIP ( n1 n2 -- n2 ) delete item below top of stack
opcode_nip:
adiw DSP, 2
rnext
; SWAP ( n1 n2 -- n2 n1 ) exchange top of stack with item below
opcode_swap:
ld TMPL, DSP ; get second item on stack
ldd TMPH, DSP+1
st DSP, TOSL ; put top item into second item
std DSP+1, TOSH ; put top item into second item
movw TOS, TMP ; put previous second item into top item
next
; OVER ( n1 n2 -- n1 n2 n1 ) copy second item on stack to top of stack
opcode_over:
pushd
ldd TOSL, DSP+2
ldd TOSH, DSP+3
next
; ROT ( n1 n2 n3 -- n2 n3 n1 ) rotate 3rd element to top of stack
; n1 = TOSH:TOSL
; n2 = [DSP+1]:[DSP+0]
; n3 = [DSP+2]:[DSP+3]
opcode_rot:
movw TMP, TOS
ldd TOSL, DSP+2
ldd TOSH, DSP+3
ld IR, DSP
std DSP+2, IR
ldd IR, DSP+1
std DSP+3, IR
st DSP, TMPL
std DSP+1, TMPH
next
; 2DUP ( n1 n2 -- n1 n2 n1 n2 ) copy top two items on stack
opcode_twodup:
movw TMP, TOS ; save n2
pushd
ldd TOSL, DSP+2 ; get n1
ldd TOSH, DSP+3
pushd ; push n2
movw TOS, TMP
next
; 2DROP ( n1 n2 -- ) drop top two items on stack
opcode_twodrop:
drop2
next
; R@ ( -- n R: -- ) push top of return stack onto data stack
; also can be used as "I"
opcode_rfetch:
pushd
rsp_to_z
ldd TOSL, Z+1
ldd TOSH, Z+2
rnext
; (C#+R@) ( -- n ) fetch word from top of return stack plus literal 8-bit unsigned displacement
; RSP points to the next *free* location in the return stack,
; so (C#+R@) 0x01 is equivalent to R@, (C#+R@) 0x03 gets second item on return stack, etc.
opcode_rfetchlitoffset:
rsp_to_z
ld TMPL, IP+ ; get displacement from instruction stream
add ZL, TMPL ; add displacement
adc ZH, ZERO
pushd
ld TOSL, Z ; get word
ldd TOSH, Z+1
rnext
; >R ( n -- R: -- n ) pop from data stack and push onto return stack
opcode_tor:
push TOSH
push TOSL
popd
next
; R> ( -- n R: n -- ) pop from return stack and push onto data stack
opcode_rfrom:
pushd
pop TOSL
pop TOSH
next
; RDROP ( R: n -- ) drop item from return stack
opcode_rdrop:
pop TMPL ; ignore the value
pop TMPH
next
; 2RDROP ( R: n1 n2 -- ) drop top two items from return stack (aka UNLOOP)
opcode_twordrop:
; 4 pops is 8 cycles, but incrementing RSP is only 6
rsp_to_z
adiw Z, 4
z_to_rsp
rnext
; 2R@ ( -- x1 x2 ) ( R: x1 x2 -- x1 x2 ) copy cell pair from TOR to TOS
opcode_tworfetch:
rsp_to_z
pushd
ldd TOSL, Z+3
ldd TOSH, Z+4
pushd
ldd TOSL, Z+1
ldd TOSH, Z+2
rnext
; 2>R ( limit index -- R: -- limit index ) runtime of DO
; pop index from stack
; pop limit from stack
; push limit onto return stack
; push index onto return stack
opcode_twotor:
nip ; get limit in TMP
push TMPH ; push limit on return stack
push TMPL
push TOSH ; push index on return stack
push TOSL
popd
next
; 2R> ( R: n1 n2 -- ) ( -- n1 n2 ) drop top two items from return stack (aka UNLOOP)
opcode_tworfrom:
pushd
pop TMPL ; get n2
pop TMPH
pop TOSL ; get n1
pop TOSH
pushd
movw TOS, TMP
next
; (R>LINK) ( R: n -- ) ( -- ) move top of return stack to the temporary link register
; Can be used to preserve the return address in words that modify or inspect the
; return stack.
opcode_link:
pop LINKL
pop LINKH
next
; (LINK>IP) ( R: n1 -- ) ( -- ) jump to the address in the temporary link register
; Can be used to exit properly from a word that has modified the return stack.
opcode_unlink:
movw IP, LINKL
next
; 0= ( n -- flag ) is TOS equal to 0?
opcode_eq0:
tstw TOS
breq .flag_true
movw TOS, ZERO
next
.flag_true:
movw TOS, TRUE
next
; 0< ( n -- flag ) is TOS less than 0? (sign bit set)
opcode_lt0:
sbrc TOSH, 7
rjmp .flag_true
movw TOS, ZERO
next
; 0> ( n -- flag ) is TOS greater than 0? (signed comparison)
opcode_gt0:
cp ZERO, TOSL
cpc ZERO, TOSH
brlt .flag_true
movw TOS, ZERO
next
; = ( n1 n2 -- flag ) compare top two stack items for equality
opcode_eq:
nip
cp TOSL, TMPL
cpc TOSH, TMPH
breq .flag_true
movw TOS, ZERO
next
; < ( n1 n2 -- flag ) is n1 less than n2? (signed)
opcode_lt:
nip
cp TMPL, TOSL
cpc TMPH, TOSH
brlt .flag_true
movw TOS, ZERO
next
; > ( n1 n2 -- flag ) is n1 greater than n2? (signed)
opcode_gt:
nip
cp TOSL, TMPL
cpc TOSH, TMPH
brlt .flag_true
movw TOS, ZERO
next
; U< ( n1 n2 -- flag ) is n1 less than n2? (unsigned)
opcode_ult:
nip
cp TMPL, TOSL
cpc TMPH, TOSH
brlo .flag_true
movw TOS, ZERO
next
; U> ( n1 n2 -- flag ) is n1 greater than n2? (unsigned)
opcode_ugt:
nip
cp TOSL, TMPL
cpc TOSH, TMPH
brlo .flag_true
movw TOS, ZERO
next
; 1+ ( n -- n ) add 1 to TOS
opcode_oneplus:
adiw TOS, 1
next
; 1- ( n -- n ) subtract 1 from TOS
opcode_oneminus:
sbiw TOS, 1
next
; 2+ ( n -- n ) add 2 (the size of a cell) to TOS
opcode_twoplus:
adiw TOS, 2
next
; 2* ( n -- n ) logical left shift TOS
opcode_twostar:
lsl TOSL
rol TOSH
next
; 2/ ( n -- n ) arithmetic right shift TOS
opcode_twoslash:
asr TOSH
ror TOSL
next
; U2/ ( n -- n ) logical right shift TOS
opcode_utwoslash:
lsr TOSH
ror TOSL
next
; ABS ( n -- u ) absolute value of TOS
opcode_abs:
tst TOSH
brpl 1f ; don't negate if positive
; NEGATE ( n -- n ) two's complement of TOS
opcode_negate:
com TOSH
neg TOSL
sbci TOSH, -1
1: next
; + ( n1 n2 -- n1+n2 ) add top two stack items
opcode_plus:
nip
add TOSL, TMPL
adc TOSH, TMPH
next
; - ( n1 n2 -- n1-n2 ) subtract top two stack items
opcode_minus:
nip
sub TMPL, TOSL
sbc TMPH, TOSH
movw TOS, TMP
next
; INVERT ( n -- n ) ones' complement of TOS
opcode_invert:
com TOSL
com TOSH
next
; AND ( n1 n2 -- n1&n2 ) bitwise AND of top two stack items
opcode_and:
nip
and TOSL, TMPL
and TOSH, TMPH
next
; (C#AND) ( n -- c ) read byte from bytecode stream and bitwise AND with top of stack
opcode_candlit:
ld TMPL, X+
and TOSL, TMPL
clr TOSH
next
; OR ( n1 n2 -- n1|n2 ) bitwise OR of top two stack items
opcode_or:
nip
or TOSL, TMPL
or TOSH, TMPH
next
; XOR ( n1 n2 -- n1^n2 ) bitwise XOR of top two stack items
opcode_xor:
nip
eor TOSL, TMPL
eor TOSH, TMPH
next
; C@ ( c-addr -- c ) read byte from address and push onto stack
opcode_cfetch:
movw Z, TOS
ld TOSL, Z
clr TOSH
rnext
; C! ( c c-addr -- ) store value to byte address
opcode_cstore:
movw Z, TOS
popd
st Z, TOSL
popd
rnext
; (C#@) ( -- c ) fetch and push byte from literal address
opcode_cfetchlit:
ld ZL, IP+ ; get literal address from instruction stream
ld ZH, IP+
pushd
ld TOSL, Z+ ; get byte
clr TOSH
rnext
; (C#!) ( c -- ) store byte to literal address
opcode_cstorelit:
ld ZL, IP+ ; get address from instruction stream
ld ZH, IP+
st Z+, TOSL ; store byte
popd
rnext
; (C#+HC@) ( -- c ) fetch byte from 0x4000 plus literal 8-bit unsigned displacement (in bytes)
opcode_cfetchlithi:
pushd
ld ZL, IP+ ; get displacement from instruction stream
ldi ZH, hi8(high_page_base)
ld TOSL, Z ; get byte
clr TOSH
rnext
; (C#+HC!) ( c -- ) store byte to 0x4000 plus literal 8-bit unsigned displacement (in bytes)
opcode_cstorelithi:
ld ZL, IP+ ; get displacement from instruction stream
ldi ZH, hi8(high_page_base)
st Z, TOSL ; store byte
popd
rnext
; C@+ ( addr -- addr+1 c ) read character at addr and postincrement addr
opcode_cfetchplus:
movw Z, TOS
ld TMPL, Z+
movw TOS, Z
pushd
mov TOSL, TMPL
clr TOSH
rnext
; C!+ ( addr c -- addr+1 ) store character to addr and postincrement addr
; note reversed argument order!
opcode_cstoreplus:
ld ZL, DSP+ ; nip address
ld ZH, DSP+
st Z+, TOSL
movw TOS, Z
rnext
; (C#+HCBITS@) ( -- c ) fetch bits from 0x4000 plus literal 8-bit unsigned displacement
opcode_cfetchbitshi:
pushd
ld TMPL, IP+ ; get mask from instruction stream
ld ZL, IP+ ; get displacement from instruction stream
ldi ZH, hi8(high_page_base)
ld TOSL, Z ; get byte
and TOSL, TMPL ; apply mask
clr TOSH
rnext
; (C#+HCBITS!) ( c -- ) store bits to 0x4000 plus literal 8-bit unsigned displacement
opcode_cstorebitshi:
ld TMPL, IP+ ; get mask from instruction stream
and TOSL, TMPL ; apply mask to incoming value
com TMPL ; complement mask
ld ZL, IP+ ; get displacement from instruction stream
ldi ZH, hi8(high_page_base)
ld TMPH, Z ; get byte
and TMPH, TMPL ; apply mask
or TMPH, TOSL ; set bits
st Z, TMPH ; store byte
popd
rnext
; @ ( addr -- n ) read word from address and push onto stack
opcode_fetch:
movw Z, TOS
ld TOSL, Z
ldd TOSH, Z+1
rnext
; ! ( n addr -- ) store value to address
opcode_store:
movw Z, TOS
popd
st Z, TOSL
std Z+1, TOSH
popd
rnext
; +! ( n addr -- ) add n to word at address
opcode_plusstore:
movw Z, TOS
ld TMPL, Z
ldd TMPH, Z+1
popd
add TMPL, TOSL
adc TMPH, TOSH
st Z, TMPL
std Z+1, TMPH
popd
rnext
; (#@) ( -- n ) fetch and push word from literal address
opcode_fetchlit:
ld ZL, IP+ ; get address from instruction stream
ld ZH, IP+
pushd
ld TOSL, Z+ ; get word
ld TOSH, Z+
rnext
; (#!) ( n -- ) store value to literal address
opcode_storelit:
ld ZL, IP+ ; get address from instruction stream
ld ZH, IP+
st Z+, TOSL ; store word
st Z+, TOSH
popd
rnext
; (C#+H@) ( -- n ) fetch word from 0x4000 plus literal 8-bit unsigned displacement (in bytes)
opcode_fetchlithi:
pushd
ld ZL, IP+ ; get displacement from instruction stream
ldi ZH, hi8(high_page_base)
ld TOSL, Z ; get word
ldd TOSH, Z+1
rnext
; (C#+!) ( n -- ) store word to 0x4000 plus literal 8-bit unsigned displacement (in bytes)
opcode_storelithi:
movw Z, TOS ; get address from stack
ld ZL, IP+ ; get displacement from instruction stream
ldi ZH, hi8(high_page_base)
st Z, TOSL ; store word
std Z+1, TOSH
popd
rnext
; 2@ ( addr -- x1 x2 ) fetch two cells from address in TOS
; x2 is the word at addr, x1 is the word at addr+2.
opcode_twofetch:
movw Z, TOS ; need an index register
ldd TOSL, Z+2 ; push value of high cell
ldd TOSH, Z+3
pushd
ld TOSL, Z ; then value of low cell
ldd TOSH, Z+1
rnext
; 2! ( x1 x2 addr -- ) store two cells to address in TOS
; x2 is stored at addr and x1 at addr+2.
opcode_twostore:
movw Z, TOS ; need an index register
popd
st Z, TOSL
std Z+1, TOSH
popd
std Z+2, TOSL
std Z+3, TOSH
popd
rnext
; SELECT ( true-n false-n flag -- n ) IF DROP ELSE NIP THEN
; pop flag from stack, if zero, discard second stack item leaving false-n,
; if nonzero, drop top of stack, leaving true-n
; like the ternary operator in other languages, but does not short-circuit
opcode_select:
tstw TOS
popd
brne 1f
adiw DSP, 2
next
1: popd
next
; (?DO) ( limit index -- ) ( R: -- ) if limit==index
; ( limit index -- ) ( R: -- limit index ) if limit!=index
opcode_qdo:
nip ; get limit in TMP
cp TOSL, TMPL ; limit equal to index?
cpc TOSH, TMPH
breq .qdo_noloop
push TMPH ; push limit on return stack
push TMPL
push TOSH ; push index on return stack
push TOSL
adiw IP, 1 ; skip branch offset
popd
next
.qdo_noloop:
ld TMPL, X+ ; get branch offset
add IPL, TMPL
adc IPH, ZERO
popd ; drop index
next
; (LOOP) ( -- R: -- limit index | -- ) runtime of LOOP
; add 1 to index on return stack
; compare index with limit, push flag on stack
; if index == limit, drop index and limit from return stack
opcode_loop:
rsp_to_z
ldd TMPL, Z+3 ; get limit
ldd TMPH, Z+4
pop ZL ; get index
pop ZH
adiw Z, 1 ; increment index
.loop_compare:
cp ZL, TMPL ; compare with limit
cpc ZH, TMPH
breq .loop_terminate
.loop_continue:
; continue--put new index back on rstack
push ZH
push ZL
; read branch offset and jump back
ld TMPL, IP ; compensate for 2 bytes of instruction
sec
sbc IPL, TMPL
sbc IPH, ZERO
rnext
.loop_terminate:
; discard remainder of loop context
pop TMPL
pop TMPL
; skip branch offset, we don't need it
adiw IP, 1
rnext
; (+LOOP) ( n -- R: -- limit index | -- ) runtime of +LOOP
; pop from TOS and add to index on return stack
; If the loop index did not cross the boundary between the loop limit minus one
; and the loop limit, continue execution at the beginning of the loop.
; Otherwise, discard the current loop control parameters and continue execution
; immediately following the loop.
opcode_plusloop:
rsp_to_z
; in ZL, RSPL
; in ZH, RSPH
ldd TMPL, Z+3 ; get limit
ldd TMPH, Z+4
pop ZL ; get index
pop ZH
movw r20, Z ; save index
add ZL, TOSL ; add increment
adc ZH, TOSH ; Z contains new index value
; Anton Ertl says:
; "Note that the loop control parameters can be either signed or unsigned, and
; +LOOP has to work for both. For systems with 2s-complement representation for
; signed numbers, the way to go is to use circular arithmetic:
; compute x=(index-limit)+minint, and observe if the addition x+n crosses the
; boundary between minint and maxint. Many architectures report this through the
; overflow flag."
sub r20, TMPL
sbc r21, TMPH
; this can be optimized out by adding 0x8000 to the loop index and limit only
; once during (DO) (this is what amforth does) but that no longer means I is
; equivalent to R@ and I'd have to add another opcode
subi r20, lo8(-0x8000)
sbci r21, hi8(-0x8000)
; add increment
add r20, TOSL
adc r21, TOSH
popd ; pop increment
; test for overflow
brvs .loop_terminate
rjmp .loop_continue
; (XY-LOOP) ( -- R: -- xy-limit xy-index | -- ) runtime of XY-LOOP
; add 1 to LSB of index on return stack
; compare index LSB with limit LSB. if equal, set index LSB to 0 and
; add 1 to index MSB.
; compare index MSB with limit MSB. push flag on stack
; if index MSB == limit MSB, drop index and limit from return stack
;!!! NOTE: will only work correctly if initial x-index value is 0. So it's NOT
; identical to two nested DO loops.
opcode_xyloop:
rsp_to_z
ldd TMPL, Z+1 ; get X index
ldd TMPH, Z+3 ; get X limit
inc TMPL ; increment X index
cp TMPL, TMPH ; compare with X limit
breq .xyloop_inc_y
; continue--put X back on rstack
std Z+1, TMPL
; read branch offset and jump back
ld TMPL, IP ; compensate for 2 bytes of instruction
sec
sbc IPL, TMPL
sbc IPH, ZERO
rnext
.xyloop_inc_y:
ldd TMPL, Z+2 ; get Y index
ldd TMPH, Z+4 ; get Y limit
inc TMPL ; increment Y index
cp TMPL, TMPH ; compare with Y limit
breq .xyloop_terminate
; continue--reset X to 0 and write new X and Y to rstack
std Z+1, ZERO ; reset X index
std Z+2, TMPL ; store new Y index
; read branch offset and jump back
ld TMPL, IP ; compensate for 2 bytes of instruction
sec
sbc IPL, TMPL
sbc IPH, ZERO
rnext
.xyloop_terminate:
; discard loop context
adiw Z, 4
z_to_rsp
; skip branch offset, we don't need it
adiw IP, 1
rnext
; (OF) ( x1 x2 -- | x1 ) runtime of OF
; If x1 and x2 are not equal, discard x2, read forward displacement value from
; bytecode stream, and jump forward.
; If x1 and x2 are equal, discard both and continue execution.
opcode_of:
nip ; nip x1 into TMP
cp TMPL, TOSL
cpc TMPH, TOSH
brne .of_notequal
; two cells equal? skip branch offset, drop TOS, and continue
ld TMPL, IP+ ; ignore
popd
next
; not equal? keep x1 and branch
.of_notequal:
movw TOS, TMP
rjmp opcode_branchfwd
; (0BRANCH<) pop and branch backward (0-255 bytes) if zero
opcode_zbranchback:
tstw TOS
popd
brne .nobranch
; (BRANCH<) backward branch (0-255 bytes)
opcode_branchback:
ld TMPL, IP ; compensate for 2 bytes of instruction
sec
sbc IPL, TMPL
sbc IPH, ZERO
next
.nobranch:
ld TMPL, IP+ ; discard branch offset
next
; (0BRANCH>) pop and branch forward (0-255 bytes) if zero
opcode_zbranchfwd:
tstw TOS
popd
brne .nobranch
; (BRANCH<) forward branch (0-255 bytes)
opcode_branchfwd:
ld TMPL, IP+
add IPL, TMPL
adc IPH, ZERO
next
; (NP0+CALL) add value to np0 and call
opcode_np0relcall:
ld TMPL, IP+ ; get lower byte of offset
ld TMPH, IP+ ; get upper byte of offset
pushr ; push return address
lds IPL, forth_np0
lds IPH, forth_np0+1
add IPL, TMPL ; add offset to current IP
adc IPH, TMPH
next
; (CCALL) ( i*x -- j*x ) call C or assembler function in flash
; Assumes the function takes from one to four cell-sized arguments.
; TOS is overwritten with return value, no other stack elements are affected.
; First argument is TOS
; Second argument is [DSP+1:DSP]
; Third argument is [DSP+3:DSP+2]
; Fourth argument is [DSP+5:DSP+4]
; Should only be used in ROM words!
opcode_ccall:
ld ZL, IP+
ld ZH, IP+
ld TMPL, DSP
ldd TMPH, DSP+1
ldd r20, DSP+2
ldd r21, DSP+3
ldd r18, DSP+4
ldd r19, DSP+5
callc_prologue
icall
callc_epilogue
rnext
; (JUMP) set IP to absolute address
opcode_jump:
ld TMPL, IP+
ld TMPH, IP+
movw IP, TMP
next
; (NP0JUMP) set IP to NP0-relative address
opcode_np0reljump:
ld TMPL, IP+
ld TMPH, IP+
lds IPL, forth_np0
lds IPH, forth_np0+1
add IPL, TMPL
adc IPH, TMPH
next
.global .throw_forth_err_code
.throw_forth_err_code:
; THROW ( n -- ) pop n and abort if nonzero
opcode_throw:
tstw TOS
movw r20, TOS
popd
breq 1f
rthrow_r21r20
1: rnext
; EMIT ( c -- ) write character at TOS to output device
opcode_emit:
callc_prologue
lds ZL, mio_putc
lds ZH, mio_putc+1
icall
popd
callc_epilogue
; (C#EMIT) read byte from instruction stream and write to output device
opcode_emitlit:
movw TSAV, TOS ; need to save TOS
ld r24, IP+ ; then read char from bytecode stream
movw XSAV, IP ; *now* save IP
lds ZL, mio_putc
lds ZH, mio_putc+1
icall
callc_0arg_epilogue
; H. ( u -- ) write single-cell number to output device as four hex digits
; (with leading zeros). Does not use the pictured numeric output buffer and does
; NOT print a trailing space. Thus, multiple consecutive invocations can be used
; to print larger numbers. (e.g. H. H. will print a double-cell as 8 hex digits)
opcode_hdot:
callc_prologue
call mio_x16
popd
callc_epilogue
; HOLD ( c -- ) add character to the pictured numeric output buffer
opcode_hold:
callc_prologue
call forth_hold
popd
callc_epilogue
; # ( ud1 -- ud2 ) extract digit to the pictured numeric output buffer
opcode_num:
callc_prologue
ld TMPL, DSP
ldd TMPH, DSP+1
call forth_extract_digit
st DSP, TMPL
std DSP+1, TMPH
callc_epilogue
; TYPE ( c-addr len -- ) write len characters from c-addr to output
opcode_type:
; print_fstr() takes args in this order:
; r25:r24 - len (and RAM/ROM flag in msb)
; r23:r22 - ptr (RAM or ROM)
callc_prologue
nip ; nip address into r23:r22
call print_fstr
popd ; drop remaining item on stack
callc_epilogue
; KEY ( -- c ) receive a character from the input source
opcode_key:
pushd
callc_prologue
clr TOSL ; block until char is received
lds ZL, mio_getc
lds ZH, mio_getc+1
icall
callc_epilogue
; ALLOT ( n -- ) allocate n bytes in the body of the current definition.
; (If LATEST is defined as a compiler word, this advances the name space pointer
; by n. Otherwise, advances the code space pointer by n.)
; throws an exception if insufficient space
opcode_allot:
callc_prologue
call allot
callc_restore
rjmp .throw_forth_err_code
; HERE ( -- addr ) return the next free address in the current definition
opcode_here:
pushd
callc_prologue
call here
callc_epilogue
; C, ( c -- ) store low byte of TOS in the body of the current definition
opcode_ccomma:
callc_prologue
call ccomma
popd
callc_epilogue
; , ( n -- ) store TOS in the body of the current definition
opcode_comma:
callc_prologue
call comma
popd
callc_epilogue
; X, ( n -- ) store TOS into code space
opcode_xcomma:
callc_prologue
call codespace_comma
popd
callc_epilogue
; XALLOT ( n -- ) allocate n bytes in code space.
opcode_xallot:
callc_prologue
call codespace_allot
callc_restore
rjmp .throw_forth_err_code
; (C#,) ( -- ) read byte from bytecode stream and store to body of current definition
opcode_litccomma:
ld TMPL, X+
callc_0arg_prologue
mov TOSL, TMPL
call ccomma
callc_0arg_epilogue
; ; (#,) ( -- ) read word from bytecode stream and store to body of current definition
; opcode_litcomma:
; ld TMPL, X+
; ld TMPH, X+
; callc_0arg_prologue
; movw TOS, TMP
; call comma
; callc_0arg_epilogue
; (HEADER) ( -- ) read a name from the input stream and create a header for it.
; Read the flags from the next byte in the bytecode stream. Creates a data field
; based on the type specified in the flags.
opcode_header:
callc_0arg_prologue
call forth_parse_name
movw IP, XSAV
ld r20, IP+
sbrc r20, 1 /* check for FL_SAVE_STACK_PTRS */
rjmp .save_stack_ptrs
3: movw XSAV, IP
call namespace_create
callc_0arg_epilogue
.save_stack_ptrs:
sts forth_saved_dsp, DSPL
sts forth_saved_dsp+1, DSPH
rsp_to_z
sts forth_saved_rsp, ZL
sts forth_saved_rsp+1, ZH
rjmp 3b
; (C::DOES>) ( -- ) creates a new compiler-child word and sets its runtime
; behavior to the literal xt in the bytecode stream
opcode_makechild:
callc_0arg_prologue
call forth_parse_name
ldi r20, FL_COMPILER_CHILD
call namespace_create
callc_0arg_restore
; fall through to (DOES>)
; (DOES>) ( -- ) change the latest word's runtime behavior to that of the
; literal nt in the bytecode stream
opcode_does:
ld TMPL, IP+ ; read nt
ld TMPH, IP+
callc_0arg_prologue
movw TOS, TMP
call interpret_does
callc_0arg_epilogue
; PARSE-NAME ( -- c-addr len ) obtain the next word from the TIB, skipping any
; leading spaces, and stopping after the next space.
opcode_parsename:
pushd
callc_prologue
call forth_parse_name
; upon return: addr in r23:r22, len in r25:r24
st -DSP, TMPH
st -DSP, TMPL
callc_epilogue
; PARSE ( delim -- c-addr len ) obtain the next word from the TIB, stopping
; after the next occurrence of delim.
.global opcode_parse
opcode_parse:
callc_prologue
call forth_parse
; upon return: addr in r23:r22, len in r25:r24
st -DSP, TMPH
st -DSP, TMPL
callc_epilogue
; ' ( -- xt ) read a name from the input stream and push its execution token
opcode_tick:
pushd
callc_prologue
call forth_parse_name
tstw TOS
breq 1f
call find_xt
; 0 indicates no xt
tstw TOS
breq 2f
callc_epilogue
1: rthrow FE_ZERO_LENGTH_NAME
2: rthrow FE_UNDEFINED_WORD
; (DODOES) ( -- addr ) runtime of DOES> words. Push body address on stack,
; then read inline xt from bytecode stream and execute it.
opcode_dodoes:
; get inline xt
ld TMPL, IP+
ld TMPH, IP+
; push current IP value (the body address) on stack
pushd
movw TOS, IP
; invoke the xt in TMP
rjmp .execute_tmp
; EXECUTE ( i*x xt -- j*x ) get execution token from top of stack and perform its
; execution semantics
.global opcode_execute
opcode_execute:
movw TMP, TOS ; drop xt from stack
popd
.execute_tmp:
clr r18 ; tell forth_execute_xt to push a return addr
jmp forth_execute_xt
; COMPILE, ( i*x ct -- j*x ) get execution token from top of stack and perform
; its compilation semantics
opcode_compile:
; pop compilation token
movw TMP, TOS
popd
jmp forth_compile_xt
; (MARK) ( -- addr ) compile dummy branch instruction and push address of offset on stack
opcode_mark:
ld TMPL, X+ ; get branch instruction to compile
pushd
callc_prologue
movw TOSL, TMPL
clr TOSH ; dummy offset
call comma
call here ; get address where we compiled the branch offset
sbiw TOS, 1 ; (need to subtract 1)
callc_epilogue
; FILL ( c-addr u c -- ) store c in u bytes starting at c-addr
opcode_fill:
mov TMPL, TOSL ; get character
ld TOSL, DSP+ ; get count in a register we can use sbiw on
ld TOSH, DSP+
tstw TOS
breq .nofill
ld ZL, DSP+ ; get address
ld ZH, DSP+
; fill loop
1: st Z+, TMPL
sbiw TOS, 1
brne 1b
; drop last arg and return
popd
rnext
.nofill:
; drop remainder of args and return
drop2
next
; (EXIT) ( R: a -- ) pop IP from return stack, also a special end-of-word marker
.global opcode_endword
opcode_endword:
popr
; don't return into the temporary rom buffer!
; (this check is only for debugging)
ldi ZH, hi8(forth_rom_word_buf)
cpi IPL, lo8(forth_rom_word_buf)
cpc IPH, ZH
brlo 1f
; save a few cycles by assuming the rom word buf doesn't span a 256-byte boundary
cpi IPL, lo8(forth_rom_word_buf+MAX_ROMDICT_ENTRY_SIZE+1)
cpc IPH, ZH
brsh 1f
throw -29
1: rnext
; PUTC ( c -- ) write character at current cursor location without interpreting
; escape sequences and newlines
opcode_putc:
movw TMP, TOS ; get character into r22
ldi r24, lo8(fcon)
ldi r25, hi8(fcon)
callc_prologue
call console_addch_raw
callc_restore
popd
rnext
; >< ( hl -- lh ) swap bytes of TOS
opcode_byteswap:
mov TMPL, TOSH
mov TOSH, TOSL
mov TOSL, TMPL
next
; LH> ( u -- cl ch ) split cell into bytes
opcode_splitbytes:
mov TMPL, TOSH
clr TOSH
pushd
mov TOSL, TMPL
next
; >LH ( cl ch -- u ) combine bytes into cell
opcode_mergebytes:
mov TOSH, TOSL ; move low byte of TOS to high byte
ld TOSL, DSP+ ; nip low byte
ld TMPH, DSP+ ; discard
next
; >H ( u1 c -- u2 ) replace high byte of u1 with c
opcode_tohighbyte:
mov TOSH, TOSL ; low byte is new high byte
ld TOSL, DSP+ ; old high byte stays the same
ld TMPL, DSP+ ; discard
next
; >L ( u1 c -- u2 ) replace low byte of u1 with c
opcode_tolowbyte:
ld TOSH, DSP+ ; old high byte stays the same
ld TMPL, DSP+ ; discard
next
; HI ( u -- c ) logical AND with 0xFF00 and shift right 8 bits
opcode_highbyte:
mov TOSL, TOSH
; fall through
; LO ( u -- c ) logical AND with 0x00FF
opcode_lowbyte:
clr TOSH
next
; LH+ ( u1 u2 -- u ) bytewise sum of u1 and u2 without interbyte carry
opcode_bytepairplus:
nip
add TOSL, TMPL
add TOSH, TMPH
next
; LH- ( u1 u2 -- u ) bytewise difference of u1 and u2 without interbyte carry
opcode_bytepairminus:
nip
sub TMPL, TOSL
sub TMPH, TOSH
movw TOS, TMP
next
; L+ ( u1 c -- u2 ) add c to low byte of u1 without affecting high byte
opcode_lplus:
mov TMPL, TOSL
popd
add TOSL, TMPL
next
; H+ ( u1 c -- u2 ) add c to high byte of u1 without affecting low byte
opcode_hplus:
mov TMPL, TOSL
popd
add TOSH, TMPL
next
; LNEGATE ( lh -- lh ) negate lower byte of TOS leaving upper byte alone
opcode_lnegate:
neg TOSL
next
; HNEGATE ( lh -- lh ) negate upper byte of TOS leaving lower byte alone
opcode_hnegate:
neg TOSH
next
; LH*/ ( lh1 lh2 -- lh3 )
opcode_lhscale:
nip ; get lh1
muls TMPL, TOSL ; product of lsbs
mov TOSL, r1 ; take msb of result
muls TMPH, TOSH ; product of msbs
mov TOSH, r1
clr ZEROL
clr ZEROH
next
; L+H ( lh -- n ) sum of low and high bytes of TOS
opcode_bytesum:
add TOSL, TOSH
ldi TOSH, 0
adc TOSH, ZERO
next
; L-H ( lh -- n ) low byte of TOS minus high byte of TOS
opcode_bytediff:
sub TOSL, TOSH
ldi TOSH, 0
sbc TOSH, ZERO
next
; 256* ( u1 -- u2 ) multiply u1 by 256 (left shift 8 bits)
; i.e. move low byte of TOS into high byte and clear low byte
opcode_twofivesixstar:
mov TOSH, TOSL
clr TOSL
next
; RANDOM ( -- u ) push a pseudorandom cell-sized integer
opcode_random:
; random number generator from Starting Forth
; seed = (seed * 31421) + 6927
pushd
lds r20, seed
lds r21, seed+1
ldi TMPL, lo8(31421)
ldi TMPH, hi8(31421)
mul r20, TMPL
movw TOS, r0
mul r20, TMPH
add TOSH, r0
mul r21, TMPL
add TOSH, r0
subi TOSL, lo8(-6927)
sbci TOSH, hi8(-6927)
clr ZEROL
clr ZEROH
sts seed, TOSL
sts seed+1, TOSH
next
; ; 16-bit xorshift random number generator:
; ; http://www.retroprogramming.com/2017/07/xorshift-pseudorandom-numbers-in-z80.html
; pushd
; lds TOSL, seed
; lds TOSH, seed+1
; ; xs ^= xs << 7
; movw TMPL, TOSL
; lsr TMPH
; mov TMPH, TMPL
; eor TMPL, TMPL
; ror TMPH
; ror TMPL
; eor TMPL, TOSL
; eor TMPH, TOSH
; ; xs ^= xs >> 9
; movw TOSL, TMPL
; mov TOSL, TOSH
; eor TOSH, TOSH
; lsr TOSL
; eor TMPL, TOSL
; eor TMPH, TOSH
; ; xs ^= xs << 8
; mov TOSH, TMPL
; eor TOSL, TOSL
; eor TOSL, TMPL
; eor TOSH, TMPH
; sts seed, TOSL
; sts seed+1, TOSH
; next
; XRES ( -- n ) screen width, in pixels (for bitmap modes) or cells (for
; text/tiled modes)
opcode_xres:
invoke_drawop xres
; GLYPH! ( d1 d2 c -- ) set glyph c in current font to 8 bytes in d1 d2
; raises an exception if current font is in ROM
opcode_setglyph:
lds TOSH, tilemap_hh
sbrs TOSH, TILEMAP_IS_RAM_BIT
rjmp .setglyph_readonly
mov ZL, TOSL
lds ZH, tilemap_hi
subi ZH, -7 ; start with last row first
.rept 4
popd ; pop 8 bytes off stack and store into font
st Z, TOSH
dec ZH
st Z, TOSL
dec ZH
.endr
rnext
.setglyph_readonly:
throw FE_READ_ONLY
; CGS ( -- ) clear graphics screen to black and set current color to white
opcode_cgs:
movw TSAV, TOS ; free up r25:r24 so we can use sbiw
clr TMPL
lds r0, bytesperline
lds r1, linesperscreen
mul r0, r1 ; get byte count
movw TOS, r0
lds ZL, screen_ptr
lds ZH, screen_ptr+1
1: st Z+, TMPL
sbiw TOS, 1
brne 1b
movw ZERO, TOS ; restore r1:r0 to zero
movw TOS, TSAV ; restore TOS
sts globalcolor, TRUEL
rnext
; CLEAR ( c -- ) fill graphics screen with color c (any bitmap or text mode)
opcode_clear:
invoke_drawop clear
; COLOR ( -- c ) get current color (any bitmap or text mode)
opcode_getcolor:
invoke_drawop getcolor
; COLOR! ( c -- ) set current color (any bitmap or text mode)
opcode_setcolor:
invoke_drawop setcolor
; PLOT ( xy -- ) set pixel in graphics screen to current color (any bitmap mode)
opcode_plot:
lds r20, linesperscreen ; check y coordinate
cp TOSH, r20
brsh .noplot
invoke_drawop plot
.noplot:
popd
next
; PSET ( c xy -- ) set color of pixel in graphics screen (any bitmap mode)
; TSET ( c xy -- ) set character at location in text screen (text modes)
opcode_pset:
lds r20, linesperscreen ; check y coordinate
cp TOSH, r20
brsh .nopset
invoke_drawop pset
.nopset:
drop2
next
; VLIN ( xy h -- ) draw vertical line at xy extending down h pixels (any bitmap mode)
; ("VLIN" is the command used by Applesoft Basic)
opcode_vlin:
nip ; get xy into TMPL/TMPH
; check y origin
lds r20, linesperscreen ; check y coordinate
cp TMPH, r20
brsh .novlin
; height must be nonzero
mov r21, TOSL
tst r21
breq .novlin
; clip height to screen bounds
add r21, TMPH ; compute ending y coordinate
brcs .clipvlin ; check for wraparound
cp r20, r21 ; check if endpoint > screen height
brlo .clipvlin
invoke_drawop vlin
.clipvlin:
sub r20, TMPH ; set line height to (screen height - y origin)
mov TOSL, r20
invoke_drawop vlin
.novlin:
.nohlin:
popd
next
; HLIN ( xy w -- ) draw horizontal line at xy extending right w pixels (any bitmap mode)
; ("HLIN" is the command used by Applesoft Basic)
opcode_hlin:
nip ; get xy into TMPL/XMPH
; check y origin
lds r20, linesperscreen ; check y coordinate
cp TMPH, r20
brsh .nohlin
invoke_drawop hlin
; RECT ( xy wh -- ) draw filled rectangle its upper left corner positioned at xy
; and extending w pixels to the right and h pixels down.
opcode_rect:
nip ; get xy into TMPL/XMPH
; check y origin
lds r20, linesperscreen ; check y coordinate
cp TMPH, r20
brsh .norect
; height must be nonzero
tst TOSH
breq .norect
; clip height to screen bounds
mov r21, TOSH
add r21, TMPH ; compute ending y coordinate
brcs .cliprectv ; check for wraparound
cp r20, r21 ; check if bottom edge > screen height
brlo .cliprectv
invoke_drawop rect
.cliprectv:
sub r20, TMPH ; set rect height to (screen height - y origin)
mov TOSH, r20
invoke_drawop rect
.norect:
popd
next
;!!! TODO: clipping
opcode_line:
invoke_drawop line
; COS ( c -- fx ) cosine of angle c (in binary radians) as a signed 1.15
; fixed-point value
opcode_cos:
ldi ZH, hi8(cosinetable)
mov ZL, TOSL
lpm TOSL, Z ; get lsb
inc ZH
lpm TOSH, Z ; get msb
rnext
; SIN ( c -- n ) sine of angle c (in binary radians) as a signed 1.15
; fixed-point value
opcode_sin:
ldi ZH, hi8(cosinetable)
ldi ZL, 0x40
sub ZL, TOSL
lpm TOSL, Z ; get lsb
inc ZH
lpm TOSH, Z ; get msb
rnext
; CCOS ( c -- c ) cosine of angle c (in binary radians) as a signed 1.7
; fixed-point value
opcode_ccos:
ldi ZH, hi8(cosinetable_msb)
mov ZL, TOSL
lpm TOSL, Z
clr TOSH ; sign-extend
sbrc TOSL, 7
ser TOSH
rnext
; CSIN ( c -- c ) sine of angle c (in binary radians) as a signed 1.7
; fixed-point value
opcode_csin:
ldi ZH, hi8(cosinetable_msb)
ldi ZL, 0x40
sub ZL, TOSL
lpm TOSL, Z
clr TOSH ; sign-extend
sbrc TOSL, 7
ser TOSH
rnext
; LH-COS/SIN ( lh1 -- lh2 )
opcode_lhcossin:
ldi ZH, hi8(cosinetable_msb)
movw TMP, TOS
mov ZL, TMPL
lpm TOSL, Z
ldi ZL, 0x40
sub ZL, TMPH
lpm TOSH, Z
rnext
; HSV ( c1 -- c2 ) convert HSV color value 0bVVSSHHHH (2 bit value, 2 bit
; saturation, 4 bit hue) to nearest color index (high-color bitmap modes)
opcode_hsv:
ldi ZH, hi8(hsvtable)
mov ZL, TOSL
lpm TOSL, Z
clr TOSH
rnext
; VSYNC ( -- ) wait until the start of the next frame of video
; this will hang the system if interrupts are disabled
opcode_vsync:
1: sbis new_frame, new_frame_bit
rjmp 1b
cbi new_frame, new_frame_bit
next
opcode_.unimplemented:
opcode_invalid:
throw FE_UNSUPPORTED_OPERATION
|
74hc595/Amethyst
| 1,284
|
apps/forth/forth_opcodes_3.S
|
#include "forth_opcodes.h"
#include "forth_macros.inc"
#include "forth_defs.h"
; Debug dispatch table aligned to a 256-word (512-byte) boundary.
; (All opcodes point to a single debugger entry point)
.align 9
.global vm_debug_dispatch_table
vm_debug_dispatch_table:
create_dispatch_table .debug_opcode_, 255
.align 0
dispatch_stubs .debug_opcode_, 256
; back up IP
ld IR, -IP
; breakpoint() takes these args:
; r25:r24 - TOS
; r23:r22 - DSP
; r21:r20 - IP
; r19:r18 - RSP
movw TMP, DSP
movw r20, IP
rsp_to_r19r18
callc_0arg_prologue
call breakpoint
tst r24
breq 1f
; reload the dispatch table in case the debug flags changed
ldi CDTH, pm_hi8(vm_dispatch_table)
lds ZL, forth_flags
sbrc ZL, FF_TRACE_BIT
ldi CDTH, pm_hi8(vm_debug_dispatch_table)
1: callc_0arg_restore
; single-step
ldi ZH, pm_hi8(vm_debug_dispatch_table)
; execute the real instruction.
; we can't use ijmp, because we'd have to clobber ZH and then we couldn't
; single-step. so use the old push-n-return trick to do an indirect jump.
ld IR, IP+
ldi r20, pm_hi8(vm_dispatch_table)
push IR
push r20
ret
|
74hc595/Amethyst
| 9,522
|
apps/forth/forth_outer_interpreter.S
|
#include "forth_opcodes.h"
#include "forth_macros.inc"
#include "forth_defs.h"
; The REPL, historically known as "QUIT."
; This is the main function and does not return.
; Hence, it does not need to save call-saved registers.
.global forth_outer_interpreter
.global forth_quit
forth_outer_interpreter:
; make sure constant registers are initialized
clr ZEROL
clr ZEROH
movw TRUE, ZERO
com TRUEL
com TRUEH
ldi CDTH, pm_hi8(vm_dispatch_table)
lds ZL, forth_flags
sbrc ZL, FF_TRACE_BIT
ldi CDTH, pm_hi8(vm_debug_dispatch_table)
; clear the data stack
ldi DSPL, lo8(forth_sp0)
ldi DSPH, hi8(forth_sp0)
movw TOS, ZERO
forth_quit:
; clear the return stack
ldi ZL, lo8(forth_rp0)
ldi ZH, hi8(forth_rp0)
z_to_rsp
; clear all exception frames
sts forth_exception_frame, TRUEL
sts forth_exception_frame+1, TRUEL
; make the terminal (block 0) the input source
sts forth_inputsrc, r1
ldi ZH, 0x80
sts forth_inputsrc+1, ZH
sts forth_inputlen, r1
sts forth_inputpos, r1
; restore interpretation state
lds ZL, forth_flags
cbr ZL, (1<<FF_STATE_BIT)
sts forth_flags, ZL
; save TOS temporarily because it'll get clobbered by C functions
movw TSAV, TOS
; get user input
.interpreter_loop:
call forth_refill
call mio_bl
.token_loop:
; get a token
call forth_parse_name
; if it's empty, we're done
tstw r24
breq .ok
; perform the behavior associated with the word.
; returns a code address if VM code needs to be executed, or 0 if nothing else
; needs to be done. throws FE_UNDEFINED_WORD if no word with that name was found
; in the dictionary and the word is not a valid number
call forth_eval_token
; does the VM need to be run?
tstw r24
; if not, just move on to the next token
breq .token_loop
execute_word_from_text_interpreter:
; we need a return address! we want the VM to BREAK after executing this word,
; so we push the address of a byte we know will be zero (the BREAK opcode)
; we can use the address of register r1 (0x0001) which is always zero.
push r1 ; push 0x00
ldi ZL, 1
push ZL ; push 0x01
; set vm's ip to the code address just returned
movw IP, r24
; restore TOS
movw TOS, TSAV
; make sure constant registers are initialized
clr ZEROL
clr ZEROH
movw TRUE, ZERO
com TRUEL
com TRUEH
ldi CDTH, pm_hi8(vm_dispatch_table)
lds ZL, forth_flags
sbrc ZL, FF_TRACE_BIT
ldi CDTH, pm_hi8(vm_debug_dispatch_table)
rnext
.ok:
movw TOS, TSAV
; check for stack overflow/underflow
movw r24, DSP ; dsp
rsp_to_tmp
call forth_postcommand
rjmp .interpreter_loop
.global forth_global_exception_handler
forth_global_exception_handler:
; is there an error? if so, bail out
brts .bailout
; if no error, proceed to the next token
movw TSAV, TOS
rjmp .token_loop
.bailout:
; if so, print error and QUIT
; get top 2 stack items into registers in case it's ABORT" and we need to print
; a custom message
ld TMPL, DSP
ldd TMPH, DSP+1
jmp forth_bailout
; string length in r21:r20
; string address in r23:r22
.global forth_evaluate_str
forth_evaluate_str:
; fail if string is more than 255 chars
cpse r21, r1
rjmp .evaluate_str_too_long
; save current input source
ldi ZL, lo8(forth_inputsrc)
ldi ZH, hi8(forth_inputsrc)
ld r18, Z
push r18
ldd r18, Z+1
push r18
ldd r18, Z+2
push r18
ldd r18, Z+3
push r18
; set new input source
st Z, TMPL ; set input string address
std Z+1, TMPH
std Z+2, r20 ; set input length
std Z+3, r1 ; reset input pos to 0
; set exception handler that returns into this eval loop
push_exception_frame .evaluate_exception_handler
; save TOS temporarily because it'll get clobbered by C functions
movw TSAV, TOS
.eval_token_loop:
; get a token
call forth_parse_name
; if it's empty, we're done
tstw TOS
breq .evaluate_done
; perform the behavior associated with the word
call forth_eval_token
; does the VM need to be run?
tstw r24
; if not, just move on to the next token
breq .eval_token_loop
; otherwise, execute
rjmp execute_word_from_text_interpreter
.evaluate_done:
; don't need the exception handler anymore
pop_exception_frame
; restore TOS
movw TOS, TSAV
; restore input source
pop ZL
sts forth_inputpos, ZL
pop ZL
sts forth_inputlen, ZL
pop ZL
sts forth_inputsrc+1, ZL
pop ZL
sts forth_inputsrc, ZL
; restore old IP and continue
popr
rnext
.evaluate_str_too_long:
throw FE_PARSED_STR_OVERFLOW
; xt in r23:r22
.global forth_compile_xt
forth_compile_xt:
callc_0arg_prologue
movw TOS, TMP
call compile_xt_or_return_code_address
rjmp .execute_token_code
; xt in r23:r22
; if r18 != 0, assume the return address is already on the return stack
.global forth_execute_xt
forth_execute_xt:
; perform its interpretation semantics (if they're in native code) or get the
; address of its bytecode
callc_0arg_prologue
movw TOS, TMP
call execute_xt_or_return_code_address
.execute_token_code:
movw r20, TOS
; r21:r20 now has code address
callc_0arg_restore
; if nothing to do, just continue on
cp r20, ZEROL
cpc r21, ZEROH
breq 1f
; if r18 != 0, don't push a return address
tst r18
brne 2f
; push return address--unless IP is currently in the temporary rom word buffer!
; if that's the case, this word is being invoked from the text interpreter,
; so treat this as a tail-call.
rcall .was_called_from_text_interpreter
breq 2f
pushr
; set new IP
2: movw IP, r20
1: rnext
; sets Z if is IP within the temporary rom word buffer
.global .was_called_from_text_interpreter
.was_called_from_text_interpreter:
ldi ZH, hi8(forth_rom_word_buf)
cpi IPL, lo8(forth_rom_word_buf)
cpc IPH, ZH
brlo 1f
; save a few cycles by assuming the rom word buf doesn't span a 256-byte boundary
cpi IPL, lo8(forth_rom_word_buf+MAX_ROMDICT_ENTRY_SIZE+1)
cpc IPH, ZH
brsh 1f
; in temporary rom word buffer? return with Z flag set
sez
ret
; not in temporary rom word buffer? return with Z flag clear
1: clz
ret
; block number in r22 (must be valid)
.global forth_load_block
forth_load_block:
; save current input source
ldi ZL, lo8(forth_inputsrc)
ldi ZH, hi8(forth_inputsrc)
ld r18, Z
push r18
ldd r18, Z+1
push r18
ldd r18, Z+2
push r18
ldd r18, Z+3
push r18
; set new input source
ldi TMPH, 0x80 ; input source is a block, line 0
st Z, TMPL ; set block number
std Z+1, TMPH
; set exception handler that returns into this eval loop
push_exception_frame .load_block_exception_handler
; save TOS temporarily because it'll get clobbered by C functions
movw TSAV, TOS
; get line from block, exit if false is returned
.load_line_loop:
call forth_refill
tst TOSL
breq .load_done
.load_token_loop:
; get a token
call forth_parse_name
; if it's empty, get next line
tstw TOS
breq .load_line_loop
; perform the behavior associated with the word
call forth_eval_token
; does the VM need to be run?
tstw r24
; if not, just move on to the next token
breq .load_token_loop
; otherwise, execute
rjmp execute_word_from_text_interpreter
.load_done:
; don't need the exception handler anymore
pop_exception_frame
; restore TOS
movw TOS, TSAV
; restore input source
;!!! TODO handle nested loads here
pop ZL
sts forth_inputpos, ZL
pop ZL
sts forth_inputlen, ZL
pop ZL
sts forth_inputsrc+1, ZL
pop ZL
sts forth_inputsrc, ZL
; restore old IP and continue
popr
rnext
; Break/exception handlers for EVALUATE and LOAD
; if no exception, T flag clear
; if exception, T flag set and error code in r21:r20
.evaluate_exception_handler:
; if the word threw a nonzero error code, propagate it to the parent
brts .rethrow
; if no error, proceed to the next token
movw TSAV, TOS
rjmp .eval_token_loop
.rethrow:
throw_r21r20
.load_block_exception_handler:
; if the word threw a nonzero error code, propagate it to the parent
brts .rethrow
; if no error, proceed to the next token
movw TSAV, TOS
rjmp .load_token_loop
|
74hc595/Amethyst
| 6,062
|
apps/forth/forth_mem_layout.S
|
; Most Forths use a single dictionary that mixes headers (names, link pointers,
; flags, etc.) with contents (code, buffers, etc.)
;
; This implementation separates them. The "code space" is for compiled code,
; buffers, variables, etc. It contains no metadata. The "name space" contains
; word information like names, flags, and code to be executed in compile mode
; only. Basically, this allows the entire name space to be moved or erased
; without affecting the execution of the code in the code space.
;
; Code space begins at the bottom of SRAM. Name space begins after the bytecode
; area. The initial size of the code space is 1 KB. When filled, the entire
; name space is moved ahead to the next 256-byte block. Since name space entries
; use relative offsets for their links, the contents of name space are
; position-independent. The contents of the name space can be moved to any
; location in memory without having to modify them.
;
; "The dictionary" refers to the combined contents of name space and code space.
; The traditional Forth dictionary words (ALLOT HERE , C, DP etc.) operate
; within code space, since this is where the majority of a program's contents
; (in fact, the *entirety* of a program's contents; the name space contains
; only metadata and definitions relating to the compilation process; it can be
; discarded without affecting the runtime behavior of the code.
#include "forth_defs.h"
#include "console.h"
.section .bss
; Memory for general Forth use.
; (bytecode, variables, buffers, dictionary)
.global forth_mem
forth_mem:
.global forth_cp0
.global forth_pmax
forth_cp0:
.space 16078
forth_pmax:
; Data stack.
.global forth_spmax
.global forth_sp0
forth_spmax:
.space 64
forth_sp0:
; Forth system variables.
; Pointer to the next free byte in name space.
; (Also a pointer to the start of the pictured numeric output buffer.)
.global forth_np
.global forth_hld0
forth_np:
forth_hld0:
.space 2
; Boundary between code space and name space.
.global forth_np0
forth_np0:
.space 2
; Upper boundary of name space.
.global forth_npmax
forth_npmax:
.space 2
; Pointer to the start of the most recently defined word in name space.
.global forth_latest
forth_latest:
.space 2
; Pointer to the next free byte in code space.
.global forth_cp
forth_cp:
.space 2
; State saved when entering compile mode. Used to check for control structure
; imbalance and delete partial dictionary entries.
.global forth_saved_dsp
.global forth_saved_rsp
.global forth_saved_np
.global forth_saved_np0
.global forth_saved_latest
.global forth_saved_cp
forth_saved_dsp: .space 2
forth_saved_rsp: .space 2
forth_saved_np: .space 2
forth_saved_np0: .space 2
forth_saved_latest: .space 2
forth_saved_cp: .space 2
; Input source.
; Order of these fields is important.
.global forth_inputsrc
.global forth_inputlen
.global forth_inputpos
forth_inputsrc: ; input string address, or block number
.space 2
forth_inputlen: ; Total size of the current input buffer
.space 1
forth_inputpos: ; Current parsing position in the current input buffer
.space 1
.global forth_last_word_pos
forth_last_word_pos:
.space 1
; Index of the next free byte in the pictured numeric output buffer.
.global forth_hld
forth_hld:
.space 1
; Radix for number<->string conversions.
.global forth_base
forth_base:
.space 1
; Character console.
.global fcon
fcon:
.space sizeof_console
#define DEFINE_FCON_FIELD(field) .global fcon_##field $ .equ fcon_##field, fcon+offsetof_console_##field
#define DEFINE_FCON_FIELD_BITMASK(field) .global fcon_bitmask_##field $ .equ fcon_bitmask_##field, bitmask_console_##field
DEFINE_FCON_FIELD(cx)
DEFINE_FCON_FIELD_BITMASK(cx)
DEFINE_FCON_FIELD(cy)
DEFINE_FCON_FIELD_BITMASK(cy)
DEFINE_FCON_FIELD(mleft)
DEFINE_FCON_FIELD_BITMASK(mleft)
DEFINE_FCON_FIELD(mtop)
DEFINE_FCON_FIELD_BITMASK(mtop)
DEFINE_FCON_FIELD(mright)
DEFINE_FCON_FIELD_BITMASK(mright)
DEFINE_FCON_FIELD(mbottom)
DEFINE_FCON_FIELD_BITMASK(mbottom)
DEFINE_FCON_FIELD(slow)
DEFINE_FCON_FIELD_BITMASK(slow)
DEFINE_FCON_FIELD(rvs)
DEFINE_FCON_FIELD_BITMASK(rvs)
DEFINE_FCON_FIELD(color)
DEFINE_FCON_FIELD_BITMASK(color)
DEFINE_FCON_FIELD(cursorphase)
DEFINE_FCON_FIELD_BITMASK(cursorphase)
; ROM word buffer.
.global forth_rom_word_buf
forth_rom_word_buf:
.space MAX_ROMDICT_ENTRY_SIZE+1
; Core runtime variables.
; Location of the current exception frame on the return stack
; If bit 15 is 1, there is no exception frame, and the global exception handler
; will be invoked.
; The layout of an exception frame is:
; . . . . . . . . . .
; | optional context data |
; | (0+ words) |
; +--------------------------+
; | addr of handler code |
; +--------------------------+
; | previous exn frame ptr |
; +--------------------------+ <-- RSP
.global forth_exception_frame
forth_exception_frame:
.space 2
; Flags, including STATE, whether the editor is running, and debug options.
.global forth_flags
forth_flags:
.space 1
; Number of last block LISTed or EDITed
.global forth_scr
forth_scr:
.space 1
; Terminal input buffer.
.global forth_tib
forth_tib:
.space 80
; Upper 32 bytes of the TIB are used by LOAD.
.global forth_blockbuf
.equ forth_blockbuf, .-BLOCK_BYTES_PER_LINE
; -------------- A cold start zeros all RAM below this address -------------- ;
.global forth_mem_end
forth_mem_end:
; Return stack.
; The Forth VM uses the AVR hardware stack pointer as RSP, and the AVR stack is
; empty-descending, i.e. it points to the first free location on the stack.
; A push is a store and a post-decrement.
; Hence we define rp0 to point to the last byte in this block of space.
.global forth_rpmax
.global forth_rp0
forth_rpmax:
.space 72
.equ forth_rp0, .-1
.global forth_tiny_rp0
.global forth_tiny_sp0
.global forth_tiny_mem_end
.equ forth_tiny_rp0, forth_rp0
.equ forth_tiny_sp0, forth_tiny_rp0+1-16
.equ forth_tiny_mem_end, forth_tiny_sp0-16
.global forth_rstack_cells
.equ forth_rstack_cells, (forth_rp0-forth_rpmax+1)>>1
.global forth_dstack_cells
.equ forth_dstack_cells, (forth_sp0-forth_spmax)>>1
|
760ceb3b9c0ba4872cadf3ce35a7a494/fediiverse
| 1,472
|
patch/src/certs.s
|
// patch type to 1 (sdmc) instead of 5 (content:)
.org load_cave_pem + 0x14
mov r2, #0x1
// set certificate location
.org browser_cave_pem_string
.ascii "3ds/fediiverse.pem", 0
// include the rootca
.org der_cert_address
der_cert_start:
.incbin "../cert/ca_cert.der"
der_cert_end:
//sizeof max 26 instructions
//r0, r1, r4, r8
// adds root certificate
.org add_default_cert_cave
add_root_cert:
ldr r0, =0x00240082 // httpC:AddRootCA
mrc p15, 0x0, r4, c13, c0, 0x3 // TLS
ldr r1, [r5, #0xC] // load HTTPC handle
ldr r8, [r5, #0x14] // load httpC handle
str r0, [r4, #0x80]! // store cmdhdr in cmdbuf[0]
str r1, [r4, #4] // store HTTPC handle in cmdbuf[1]
mov r0, r8 // move httpC handle to r0 for SVC SendSyncRequest
ldr r8, =der_cert_end-der_cert_start
ldr r1, =der_cert_start
str r8, [r4, #8] // store cert size in cmdbuf[2]
str r1, [r4, #16] // store cert bufptr in cmdbuf[4]
mov r8, r8, lsl #4 // size <<= 4
orr r8, r8, #0xA // size |= 0xA
str r8, [r4, #12] // store translate header in cmdbuf[3]
swi 0x32 // finally do the request
nop // do whatever
b add_default_cert_cave_end // jump past the pool
.pool
nop
nop
nop
// so much nop
|
769484623/MahonyAHRSWithMPU9250
| 11,029
|
CORE/startup_stm32f0xx.s
|
;******************** (C) COPYRIGHT 2014 STMicroelectronics ********************
;* File Name : startup_stm32f0xx.s
;* Author : MCD Application Team
;* Version : V1.5.0
;* Date : 05-December-2014
;* Description : STM32F051 devices vector table for MDK-ARM toolchain.
;* This module performs:
;* - Set the initial SP
;* - Set the initial PC == Reset_Handler
;* - Set the vector table entries with the exceptions ISR address
;* - Configure the system clock
;* - Branches to __main in the C library (which eventually
;* calls main()).
;* After Reset the CortexM0 processor is in Thread mode,
;* priority is Privileged, and the Stack is set to Main.
;* <<< Use Configuration Wizard in Context Menu >>>
;*******************************************************************************
; @attention
;
; Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
; You may not use this file except in compliance with the License.
; You may obtain a copy of the License at:
;
; http://www.st.com/software_license_agreement_liberty_v2
;
; Unless required by applicable law or agreed to in writing, software
; distributed under the License is distributed on an "AS IS" BASIS,
; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
; See the License for the specific language governing permissions and
; limitations under the License.
;
;*******************************************************************************
;
; Amount of memory (in bytes) allocated for Stack
; Tailor this value to your application needs
; <h> Stack Configuration
; <o> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
; </h>
Stack_Size EQU 0x00000400
AREA STACK, NOINIT, READWRITE, ALIGN=3
Stack_Mem SPACE Stack_Size
__initial_sp
; <h> Heap Configuration
; <o> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
; </h>
Heap_Size EQU 0x00000200
AREA HEAP, NOINIT, READWRITE, ALIGN=3
__heap_base
Heap_Mem SPACE Heap_Size
__heap_limit
PRESERVE8
THUMB
; Vector Table Mapped to Address 0 at Reset
AREA RESET, DATA, READONLY
EXPORT __Vectors
EXPORT __Vectors_End
EXPORT __Vectors_Size
__Vectors DCD __initial_sp ; Top of Stack
DCD Reset_Handler ; Reset Handler
DCD NMI_Handler ; NMI Handler
DCD HardFault_Handler ; Hard Fault Handler
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD SVC_Handler ; SVCall Handler
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD PendSV_Handler ; PendSV Handler
DCD SysTick_Handler ; SysTick Handler
; External Interrupts
DCD WWDG_IRQHandler ; Window Watchdog
DCD PVD_IRQHandler ; PVD through EXTI Line detect
DCD RTC_IRQHandler ; RTC through EXTI Line
DCD FLASH_IRQHandler ; FLASH
DCD RCC_IRQHandler ; RCC
DCD EXTI0_1_IRQHandler ; EXTI Line 0 and 1
DCD EXTI2_3_IRQHandler ; EXTI Line 2 and 3
DCD EXTI4_15_IRQHandler ; EXTI Line 4 to 15
DCD TS_IRQHandler ; TS
DCD DMA1_Channel1_IRQHandler ; DMA1 Channel 1
DCD DMA1_Channel2_3_IRQHandler ; DMA1 Channel 2 and Channel 3
DCD DMA1_Channel4_5_IRQHandler ; DMA1 Channel 4 and Channel 5
DCD ADC1_COMP_IRQHandler ; ADC1, COMP1 and COMP2
DCD TIM1_BRK_UP_TRG_COM_IRQHandler ; TIM1 Break, Update, Trigger and Commutation
DCD TIM1_CC_IRQHandler ; TIM1 Capture Compare
DCD TIM2_IRQHandler ; TIM2
DCD TIM3_IRQHandler ; TIM3
DCD TIM6_DAC_IRQHandler ; TIM6 and DAC
DCD 0 ; Reserved
DCD TIM14_IRQHandler ; TIM14
DCD TIM15_IRQHandler ; TIM15
DCD TIM16_IRQHandler ; TIM16
DCD TIM17_IRQHandler ; TIM17
DCD I2C1_IRQHandler ; I2C1
DCD I2C2_IRQHandler ; I2C2
DCD SPI1_IRQHandler ; SPI1
DCD SPI2_IRQHandler ; SPI2
DCD USART1_IRQHandler ; USART1
DCD USART2_IRQHandler ; USART2
DCD 0 ; Reserved
DCD CEC_IRQHandler ; CEC
DCD 0 ; Reserved
__Vectors_End
__Vectors_Size EQU __Vectors_End - __Vectors
AREA |.text|, CODE, READONLY
; Reset handler routine
Reset_Handler PROC
EXPORT Reset_Handler [WEAK]
IMPORT __main
IMPORT SystemInit
LDR R0, =__initial_sp ; set stack pointer
MSR MSP, R0
;;Check if boot space corresponds to test memory
LDR R0,=0x00000004
LDR R1, [R0]
LSRS R1, R1, #24
LDR R2,=0x1F
CMP R1, R2
BNE ApplicationStart
;; SYSCFG clock enable
LDR R0,=0x40021018
LDR R1,=0x00000001
STR R1, [R0]
;; Set CFGR1 register with flash memory remap at address 0
LDR R0,=0x40010000
LDR R1,=0x00000000
STR R1, [R0]
ApplicationStart
LDR R0, =SystemInit
BLX R0
LDR R0, =__main
BX R0
ENDP
; Dummy Exception Handlers (infinite loops which can be modified)
NMI_Handler PROC
EXPORT NMI_Handler [WEAK]
B .
ENDP
HardFault_Handler\
PROC
EXPORT HardFault_Handler [WEAK]
B .
ENDP
SVC_Handler PROC
EXPORT SVC_Handler [WEAK]
B .
ENDP
PendSV_Handler PROC
EXPORT PendSV_Handler [WEAK]
B .
ENDP
SysTick_Handler PROC
EXPORT SysTick_Handler [WEAK]
B .
ENDP
Default_Handler PROC
EXPORT WWDG_IRQHandler [WEAK]
EXPORT PVD_IRQHandler [WEAK]
EXPORT RTC_IRQHandler [WEAK]
EXPORT FLASH_IRQHandler [WEAK]
EXPORT RCC_IRQHandler [WEAK]
EXPORT EXTI0_1_IRQHandler [WEAK]
EXPORT EXTI2_3_IRQHandler [WEAK]
EXPORT EXTI4_15_IRQHandler [WEAK]
EXPORT TS_IRQHandler [WEAK]
EXPORT DMA1_Channel1_IRQHandler [WEAK]
EXPORT DMA1_Channel2_3_IRQHandler [WEAK]
EXPORT DMA1_Channel4_5_IRQHandler [WEAK]
EXPORT ADC1_COMP_IRQHandler [WEAK]
EXPORT TIM1_BRK_UP_TRG_COM_IRQHandler [WEAK]
EXPORT TIM1_CC_IRQHandler [WEAK]
EXPORT TIM2_IRQHandler [WEAK]
EXPORT TIM3_IRQHandler [WEAK]
EXPORT TIM6_DAC_IRQHandler [WEAK]
EXPORT TIM14_IRQHandler [WEAK]
EXPORT TIM15_IRQHandler [WEAK]
EXPORT TIM16_IRQHandler [WEAK]
EXPORT TIM17_IRQHandler [WEAK]
EXPORT I2C1_IRQHandler [WEAK]
EXPORT I2C2_IRQHandler [WEAK]
EXPORT SPI1_IRQHandler [WEAK]
EXPORT SPI2_IRQHandler [WEAK]
EXPORT USART1_IRQHandler [WEAK]
EXPORT USART2_IRQHandler [WEAK]
EXPORT CEC_IRQHandler [WEAK]
WWDG_IRQHandler
PVD_IRQHandler
RTC_IRQHandler
FLASH_IRQHandler
RCC_IRQHandler
EXTI0_1_IRQHandler
EXTI2_3_IRQHandler
EXTI4_15_IRQHandler
TS_IRQHandler
DMA1_Channel1_IRQHandler
DMA1_Channel2_3_IRQHandler
DMA1_Channel4_5_IRQHandler
ADC1_COMP_IRQHandler
TIM1_BRK_UP_TRG_COM_IRQHandler
TIM1_CC_IRQHandler
TIM2_IRQHandler
TIM3_IRQHandler
TIM6_DAC_IRQHandler
TIM14_IRQHandler
TIM15_IRQHandler
TIM16_IRQHandler
TIM17_IRQHandler
I2C1_IRQHandler
I2C2_IRQHandler
SPI1_IRQHandler
SPI2_IRQHandler
USART1_IRQHandler
USART2_IRQHandler
CEC_IRQHandler
B .
ENDP
ALIGN
;*******************************************************************************
; User Stack and Heap initialization
;*******************************************************************************
IF :DEF:__MICROLIB
EXPORT __initial_sp
EXPORT __heap_base
EXPORT __heap_limit
ELSE
IMPORT __use_two_region_memory
EXPORT __user_initial_stackheap
__user_initial_stackheap
LDR R0, = Heap_Mem
LDR R1, =(Stack_Mem + Stack_Size)
LDR R2, = (Heap_Mem + Heap_Size)
LDR R3, = Stack_Mem
BX LR
ALIGN
ENDIF
END
;************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE*****
|
769484623/MahonyAHRSWithMPU9250
| 10,608
|
RTE/Device/STM32F030C8/startup_stm32f030x8.s
|
;******************** (C) COPYRIGHT 2016 STMicroelectronics ********************
;* File Name : startup_stm32f030x8.s
;* Author : MCD Application Team
;* Version : V2.2.3
;* Date : 29-January-2016
;* Description : STM32F030x8 devices vector table for MDK-ARM toolchain.
;* This module performs:
;* - Set the initial SP
;* - Set the initial PC == Reset_Handler
;* - Set the vector table entries with the exceptions ISR address
;* - Branches to __main in the C library (which eventually
;* calls main()).
;* After Reset the CortexM0 processor is in Thread mode,
;* priority is Privileged, and the Stack is set to Main.
;* <<< Use Configuration Wizard in Context Menu >>>
;*******************************************************************************
;*
;* Redistribution and use in source and binary forms, with or without modification,
;* are permitted provided that the following conditions are met:
;* 1. Redistributions of source code must retain the above copyright notice,
;* this list of conditions and the following disclaimer.
;* 2. Redistributions in binary form must reproduce the above copyright notice,
;* this list of conditions and the following disclaimer in the documentation
;* and/or other materials provided with the distribution.
;* 3. Neither the name of STMicroelectronics nor the names of its contributors
;* may be used to endorse or promote products derived from this software
;* without specific prior written permission.
;*
;* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
;* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
;* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
;* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
;* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
;* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
;* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
;* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
;* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
;* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
;
;*******************************************************************************
; Amount of memory (in bytes) allocated for Stack
; Tailor this value to your application needs
; <h> Stack Configuration
; <o> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
; </h>
Stack_Size EQU 0x00000400
AREA STACK, NOINIT, READWRITE, ALIGN=3
Stack_Mem SPACE Stack_Size
__initial_sp
; <h> Heap Configuration
; <o> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
; </h>
Heap_Size EQU 0x00000200
AREA HEAP, NOINIT, READWRITE, ALIGN=3
__heap_base
Heap_Mem SPACE Heap_Size
__heap_limit
PRESERVE8
THUMB
; Vector Table Mapped to Address 0 at Reset
AREA RESET, DATA, READONLY
EXPORT __Vectors
EXPORT __Vectors_End
EXPORT __Vectors_Size
__Vectors DCD __initial_sp ; Top of Stack
DCD Reset_Handler ; Reset Handler
DCD NMI_Handler ; NMI Handler
DCD HardFault_Handler ; Hard Fault Handler
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD SVC_Handler ; SVCall Handler
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD PendSV_Handler ; PendSV Handler
DCD SysTick_Handler ; SysTick Handler
; External Interrupts
DCD WWDG_IRQHandler ; Window Watchdog
DCD 0 ; Reserved
DCD RTC_IRQHandler ; RTC through EXTI Line
DCD FLASH_IRQHandler ; FLASH
DCD RCC_IRQHandler ; RCC
DCD EXTI0_1_IRQHandler ; EXTI Line 0 and 1
DCD EXTI2_3_IRQHandler ; EXTI Line 2 and 3
DCD EXTI4_15_IRQHandler ; EXTI Line 4 to 15
DCD 0 ; Reserved
DCD DMA1_Channel1_IRQHandler ; DMA1 Channel 1
DCD DMA1_Channel2_3_IRQHandler ; DMA1 Channel 2 and Channel 3
DCD DMA1_Channel4_5_IRQHandler ; DMA1 Channel 4 and Channel 5
DCD ADC1_IRQHandler ; ADC1
DCD TIM1_BRK_UP_TRG_COM_IRQHandler ; TIM1 Break, Update, Trigger and Commutation
DCD TIM1_CC_IRQHandler ; TIM1 Capture Compare
DCD 0 ; Reserved
DCD TIM3_IRQHandler ; TIM3
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD TIM14_IRQHandler ; TIM14
DCD TIM15_IRQHandler ; TIM15
DCD TIM16_IRQHandler ; TIM16
DCD TIM17_IRQHandler ; TIM17
DCD I2C1_IRQHandler ; I2C1
DCD I2C2_IRQHandler ; I2C2
DCD SPI1_IRQHandler ; SPI1
DCD SPI2_IRQHandler ; SPI2
DCD USART1_IRQHandler ; USART1
DCD USART2_IRQHandler ; USART2
__Vectors_End
__Vectors_Size EQU __Vectors_End - __Vectors
AREA |.text|, CODE, READONLY
; Reset handler routine
Reset_Handler PROC
EXPORT Reset_Handler [WEAK]
IMPORT __main
IMPORT SystemInit
LDR R0, =SystemInit
BLX R0
LDR R0, =__main
BX R0
ENDP
; Dummy Exception Handlers (infinite loops which can be modified)
NMI_Handler PROC
EXPORT NMI_Handler [WEAK]
B .
ENDP
HardFault_Handler\
PROC
EXPORT HardFault_Handler [WEAK]
B .
ENDP
SVC_Handler PROC
EXPORT SVC_Handler [WEAK]
B .
ENDP
PendSV_Handler PROC
EXPORT PendSV_Handler [WEAK]
B .
ENDP
SysTick_Handler PROC
EXPORT SysTick_Handler [WEAK]
B .
ENDP
Default_Handler PROC
EXPORT WWDG_IRQHandler [WEAK]
EXPORT RTC_IRQHandler [WEAK]
EXPORT FLASH_IRQHandler [WEAK]
EXPORT RCC_IRQHandler [WEAK]
EXPORT EXTI0_1_IRQHandler [WEAK]
EXPORT EXTI2_3_IRQHandler [WEAK]
EXPORT EXTI4_15_IRQHandler [WEAK]
EXPORT DMA1_Channel1_IRQHandler [WEAK]
EXPORT DMA1_Channel2_3_IRQHandler [WEAK]
EXPORT DMA1_Channel4_5_IRQHandler [WEAK]
EXPORT ADC1_IRQHandler [WEAK]
EXPORT TIM1_BRK_UP_TRG_COM_IRQHandler [WEAK]
EXPORT TIM1_CC_IRQHandler [WEAK]
EXPORT TIM3_IRQHandler [WEAK]
EXPORT TIM14_IRQHandler [WEAK]
EXPORT TIM15_IRQHandler [WEAK]
EXPORT TIM16_IRQHandler [WEAK]
EXPORT TIM17_IRQHandler [WEAK]
EXPORT I2C1_IRQHandler [WEAK]
EXPORT I2C2_IRQHandler [WEAK]
EXPORT SPI1_IRQHandler [WEAK]
EXPORT SPI2_IRQHandler [WEAK]
EXPORT USART1_IRQHandler [WEAK]
EXPORT USART2_IRQHandler [WEAK]
WWDG_IRQHandler
RTC_IRQHandler
FLASH_IRQHandler
RCC_IRQHandler
EXTI0_1_IRQHandler
EXTI2_3_IRQHandler
EXTI4_15_IRQHandler
DMA1_Channel1_IRQHandler
DMA1_Channel2_3_IRQHandler
DMA1_Channel4_5_IRQHandler
ADC1_IRQHandler
TIM1_BRK_UP_TRG_COM_IRQHandler
TIM1_CC_IRQHandler
TIM3_IRQHandler
TIM14_IRQHandler
TIM15_IRQHandler
TIM16_IRQHandler
TIM17_IRQHandler
I2C1_IRQHandler
I2C2_IRQHandler
SPI1_IRQHandler
SPI2_IRQHandler
USART1_IRQHandler
USART2_IRQHandler
B .
ENDP
ALIGN
;*******************************************************************************
; User Stack and Heap initialization
;*******************************************************************************
IF :DEF:__MICROLIB
EXPORT __initial_sp
EXPORT __heap_base
EXPORT __heap_limit
ELSE
IMPORT __use_two_region_memory
EXPORT __user_initial_stackheap
__user_initial_stackheap
LDR R0, = Heap_Mem
LDR R1, =(Stack_Mem + Stack_Size)
LDR R2, = (Heap_Mem + Heap_Size)
LDR R3, = Stack_Mem
BX LR
ALIGN
ENDIF
END
;************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE*****
|
7etsuo/Learn-Solana-BPF-Assembly
| 14,702
|
examples/token.sbpf/TOKEN.S
|
# TOKEN.SBPF version 0.99 #
# Simple token transfer program #
# #
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::#
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::#
#: o 8 .oPYo. .oPYo. ooooo :#
#: 8 8 8 `8 8 8 8 :#
#: o8P .oPYo. 8 .o .oPYo. odYo. .oPYo. o8YooP' o8YooP' o8oo :#
#: 8 8 8 8oP' 8oooo8 8' `8 Yb.. 8 `b 8 8 :#
#: 8 8 8 8 `b. 8. 8 8 /--\ 'Yb. 8 8 8 8 :#
#: 8 `YooP' 8 `o. `Yooo' 8 8 \--/ `YooP' 8oooP' 8 8 :#
#:::..::.....:..::...:.....:..::..::..:::.....::......::..::::::..:::::#
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::#
# #
# #
# token.sBPF is a CU-minimized token program for Solana. #
# It is functionally comparable to Tokenkeg (signed minting, #
# permission-less transfers), but does not support freezing. #
# #
# Notably, "express" token transfers cost only 56 CUs. #
# #
# #
#----------------------------------------------------------------------#
# #
# token.sBPF is distributed WITHOUT WARRANTIES OF ANY KIND. #
# This code has not been audited. Please assume it is broken. #
# #
# DO NOT DEPLOY THIS CODE ON MAINNET. #
# #
# For more information refer to the LICENSE file. #
# #
#----------------------------------------------------------------------#
# #
# Build: #
# #
# Set $SOLANA_SDK to a Solana platform-tools installation #
# Run `make` #
# The resulting program is at BUILD/TOKEN.SO #
# #
# This program is compatible with BPF Loader v3 (sBPFv1). #
# #
# Usage: #
# #
# This program manages two kinds of accounts: #
# A mint whose account address identifies the token. The mint is #
# a required signatory when issuing new tokens. #
# Token accounts which collectively hold the supply of a token. #
# #
# Instructions: #
# #
# Mint Tokens #
# - Account 0: Mint ; signer writable sz=0x08 #
# - Account 1: Token account ; writable sz=0x48 #
# - Data (9 bytes): #
# - u8 op_kind = 0 #
# - u64 amount #
# #
# Set Authority / Set Mint #
# - Account 0: Token account ; writable sz=0x48 #
# - Account 1: Authority ; signer #
# - Data (33 bytes): #
# - u8 op_kind = 1 #
# - 32b new_authority #
# - Data (65 bytes): #
# - u8 op_kind = 1 #
# - 32b new_authority #
# - 32b mint_address #
# #
# Transfer #
# - Account 0: Src token account ; writable sz=0x48 #
# - Account 1: Dst token account ; writable sz=0x48 #
# - Account 2: Authority of src ; signer #
# - Data (8 bytes): #
# - u64 amount #
# - Uses 56 CUs if all addresses are unique, token accounts are #
# initialized and same mint, authority is correct, and no #
# balance underflow or overflow. #
# #
# State: #
# #
# Mint (8 bytes) #
# - u64 total_minted #
# #
# Token Account (72 bytes) #
# - 32b mint address #
# - 32b token account address #
# - u64 balance #
# #
#----------------------------------------------------------------------#
# Imports
.extern sol_log_
.extern entrypoint_ex
# Code
.section .text
#define TOKEN_ACCT_SZ 0x48
/* Various offsets derived using offsets.py */
#define INOFF_ACCT_CNT 0x0000
#define INOFF_ACCT0_HDR 0x0008
#define INOFF_ACCT0_SZ 0x0058
#define INOFF_ACCT0_MINT_Q0 0x0060
#define INOFF_ACCT0_MINT_Q1 0x0068
#define INOFF_ACCT0_MINT_Q2 0x0070
#define INOFF_ACCT0_MINT_Q3 0x0078
#define INOFF_ACCT0_AUTH_Q0 0x0080
#define INOFF_ACCT0_AUTH_Q1 0x0088
#define INOFF_ACCT0_AUTH_Q2 0x0090
#define INOFF_ACCT0_AUTH_Q3 0x0098
#define INOFF_ACCT0_BALANCE 0x00a0
#define INOFF_ACCT1_HDR 0x28b0
#define INOFF_ACCT1_SZ 0x2900
#define INOFF_ACCT1_MINT_Q0 0x2908
#define INOFF_ACCT1_MINT_Q1 0x2910
#define INOFF_ACCT1_MINT_Q2 0x2918
#define INOFF_ACCT1_MINT_Q3 0x2920
#define INOFF_ACCT1_AUTH_Q0 0x2928
#define INOFF_ACCT1_AUTH_Q1 0x2930
#define INOFF_ACCT1_AUTH_Q2 0x2938
#define INOFF_ACCT1_AUTH_Q3 0x2940
#define INOFF_ACCT1_BALANCE 0x2948
#define INOFF_ACCT2_HDR 0x5158
#define INOFF_ACCT2_ADDR_Q0 0x5160
#define INOFF_ACCT2_ADDR_Q1 0x5168
#define INOFF_ACCT2_ADDR_Q2 0x5170
#define INOFF_ACCT2_ADDR_Q3 0x5178
#define MIN_INSTR_DATA_OFF 0x79b8
.globl entrypoint
entrypoint:
# check: account_cnt == 3
r3 = *(u64 *)(r1 + INOFF_ACCT_CNT) # 1 CU
if r3 != 3 goto beach # 2 CU
# check: account[0].duplicate_index == 0xFF &&
# account[0].is_signer == 0x01 &&
# account[0].is_writable == 0x01 &&
# account[0].is_executable == 0x00
r3 = *(u32 *)(r1 + INOFF_ACCT0_HDR) # 3 CU
r3 &= 0xFF00FF # 4 CU
if r3 != 0x0100FF goto beach # 5 CU
# check: account[0].size == TOKEN_ACCT_SZ
r3 = *(u64 *)(r1 + INOFF_ACCT0_SZ) # 6 CU
if r3 != TOKEN_ACCT_SZ goto beach # 7 CU
# check: account[1].duplicate_index == 0xFF &&
# account[1].is_writable == 0x01 &&
# account[1].is_executable == 0x00
#
# Since the account is writable omit the owner check (dangerous!)
r3 = *(u32 *)(r1 + INOFF_ACCT1_HDR) # 8 CU
r3 &= 0xFF00FF # 9 CU
if r3 != 0x0100FF goto beach # 10 CU
# check: account[1].size == TOKEN_ACCT_SZ
r3 = *(u64 *)(r1 + INOFF_ACCT1_SZ) # 11 CU
if r3 != TOKEN_ACCT_SZ goto beach # 12 CU
# check: account[2].duplicate_index == 0xFF &&
# account[2].is_signer == 0x01
r3 = *(u16 *)(r1 + INOFF_ACCT2_HDR) # 13 CU
if r3 != 0x01FF goto beach # 14 CU
# check: account[0].data.mint == account[1].data.mint
r4 = *(u64 *)(r1 + INOFF_ACCT0_MINT_Q0) # 15 CU
r5 = *(u64 *)(r1 + INOFF_ACCT0_MINT_Q1) # 16 CU
r6 = *(u64 *)(r1 + INOFF_ACCT1_MINT_Q0) # 17 CU
r7 = *(u64 *)(r1 + INOFF_ACCT1_MINT_Q1) # 18 CU
if r4 != r6 goto beach # 19 CU
if r5 != r7 goto beach # 20 CU
r4 = *(u64 *)(r1 + INOFF_ACCT0_MINT_Q2) # 21 CU
r5 = *(u64 *)(r1 + INOFF_ACCT0_MINT_Q3) # 22 CU
r6 = *(u64 *)(r1 + INOFF_ACCT1_MINT_Q2) # 23 CU
r7 = *(u64 *)(r1 + INOFF_ACCT1_MINT_Q3) # 24 CU
if r4 != r6 goto beach # 25 CU
if r5 != r7 goto beach # 26 CU
# check: account[0].data.authority == account[2].pubkey
r4 = *(u64 *)(r1 + INOFF_ACCT0_AUTH_Q0) # 27 CU
r5 = *(u64 *)(r1 + INOFF_ACCT0_AUTH_Q1) # 28 CU
r6 = *(u64 *)(r1 + INOFF_ACCT2_ADDR_Q0) # 29 CU
r7 = *(u64 *)(r1 + INOFF_ACCT2_ADDR_Q1) # 30 CU
if r4 != r6 goto beach # 31 CU
if r5 != r7 goto beach # 32 CU
r4 = *(u64 *)(r1 + INOFF_ACCT0_AUTH_Q2) # 33 CU
r5 = *(u64 *)(r1 + INOFF_ACCT0_AUTH_Q3) # 34 CU
r6 = *(u64 *)(r1 + INOFF_ACCT2_ADDR_Q2) # 35 CU
r7 = *(u64 *)(r1 + INOFF_ACCT2_ADDR_Q3) # 36 CU
if r4 != r6 goto beach # 37 CU
if r5 != r7 goto beach # 38 CU
# r3 <- align_up( account[2].size, 8 )
r3 = *(u64 *)(r1 + 0x5198) # 39 CU
r3 += 7 # 40 CU
r3 &= -8 # 41 CU
# r3 <- &instr.data
r3 += r1 # 42 CU
r3 += MIN_INSTR_DATA_OFF # 43 CU
# check: instr.data_sz == 0x08
r2 = *(u64 *)(r3 + 0x00) # 44 CU
if r2 != 0x08 goto beach # 45 CU
# r2 <- instr.data.amount
# r3 <- account[0].data.balance
# r4 <- account[1].data.balance
r2 = *(u64 *)(r3 + 0x08) # 46 CU
r3 = *(u64 *)(r1 + INOFF_ACCT0_BALANCE) # 47 CU
r4 = *(u64 *)(r1 + INOFF_ACCT1_BALANCE) # 48 CU
# check: instr.data.amount <= account[0].data.balance
if r2 > r3 goto insufficient_balance # 49 CU
# account[0].data.balance -= instr.data.amount
r3 -= r2 # 50 CU
*(u64 *)(r1 + INOFF_ACCT0_BALANCE) = r3 # 51 CU
# check: account[1].data.balance + instr.data.amount < 2^64
# account[1].data.balance += instr.data.amount
r5 = r4 # 52 CU
r5 += r2 # 53 CU
if r5 < r4 goto overflow # 54 CU
*(u64 *)(r1 + INOFF_ACCT1_BALANCE) = r5 # 55 CU
# Token transfer complete
exit # 56 CU
insufficient_balance:
r1 = str_insufficient_balance ll
r2 = 20
call sol_log_
r0 = 2
exit
overflow:
r1 = str_overflow ll
r2 = 9
call sol_log
r0 = 3
exit
# Trampoline to slow path
beach:
r1 = 0x400000000 ll
call entrypoint_ex
exit
#----------------------------------------------------------------------#
# Note on known issues: #
# #
# - The mint ID is 32 bytes but could be shortened to 8 bytes by #
# using PDAs for mint addresses. This would save approx 11 CU #
# for transfers. #
# #
# - The program does not check whether provided accounts are owned #
# by itself. Instead it checks whether an account is writable. #
# This may be safe for now but could be exploitable (infinite #
# mint bug) if network allows programs to write to accounts other #
# than itself in the future. #
# #
# - No support for closing accounts yet. #
# #
# - Incomplete tests. #
# #
#----------------------------------------------------------------------#
|
8bitbubsy/pt23f
| 502,568
|
PT2.3F.s
|
; ProTracker v2.3F source code
; ============================
; 9th of October, 2025
;
; (tab width = 8 spaces)
;
; If you find any bugs, please email me at the email/Discord found on
; the website 16-bits.org.
;
; Original PT2.3D by Peter "CRAYON" Hanning, Detron and Lars "ZAP" Hamre
;
; PT2.3D raw disassemble by Per "Super-Hans" Johansson
; Re-source job and PT2.3E/PT2.3F version by Olav "8bitbubsy" Sorensen (me)
;
ERR_WAIT_TIME EQU 40
MOUSE_SPEED EQU 11 ; 1..16
SONG_SIZE_100PAT EQU 1084+(1024*100)
SONG_SIZE_64PAT EQU 1084+(1024*64)
PaulaDMAWaitScanlines_000 EQU 5-1
PaulaDMAWaitScanlines_020 EQU 7-1
GUIDelayScanlines_000 EQU 0 ; no delay needed on 68k
GUIDelayScanlines_020 EQU 40-1
; FileFormat
sd_sampleinfo EQU 20
sd_numofpatt EQU 950
sd_pattpos EQU 952
sd_magicid EQU 1080
sd_patterndata EQU 1084
; audXtemp offsets
n_note EQU 0 ; W (MUST be first!)
n_cmd EQU 2 ; W (MUST be second!)
n_cmdlo EQU 3 ; B (lower byte of cmd)
n_start EQU 4 ; L (aligned)
n_wavestart EQU 8 ; L
n_loopstart EQU 12 ; L
n_oldstart EQU 16 ; L
n_peroffset EQU 20 ; L (offset to finetuned period-LUT section)
n_dmabit EQU 24 ; W (aligned)
n_length EQU 26 ; W
n_replen EQU 28 ; W
n_period EQU 30 ; W
n_wantedperiod EQU 32 ; W
n_oldlength EQU 34 ; W
n_periodout EQU 36 ; W
n_repeat EQU 38 ; W
n_finetune EQU 40 ; B
n_volume EQU 41 ; B
n_toneportdirec EQU 42 ; B
n_toneportspeed EQU 43 ; B
n_vibratocmd EQU 44 ; B
n_vibratopos EQU 45 ; B
n_tremolocmd EQU 46 ; B
n_tremolopos EQU 47 ; B
n_wavecontrol EQU 48 ; B
n_glissfunk EQU 49 ; B
n_sampleoffset EQU 50 ; B
n_pattpos EQU 51 ; B
n_loopcount EQU 52 ; B
n_funkoffset EQU 53 ; B
n_trigger EQU 54 ; B
n_samplenum EQU 55 ; B
n_volumeout EQU 56 ; B
n_sampleoffset2 EQU 57 ; B
n_muted EQU 58 ; B
ChanStructSize EQU 60 ; (must be a multiple of 4!)
; Exec Library Offsets
_LVOFindTask EQU -294
_LVOFindName EQU -276
_LVOForbid EQU -132
_LVOPermit EQU -138
_LVOAddPort EQU -354
_LVORemPort EQU -360
_LVOWaitPort EQU -384
_LVOOpenLibrary EQU -552
_LVOCloseLibrary EQU -414
_LVOOpenDevice EQU -444
_LVOCloseDevice EQU -450
_LVODoIO EQU -456
_LVOSendIO EQU -462
_LVOGetMsg EQU -372
_LVOReplyMsg EQU -378
_LVOAllocMem EQU -198
_LVOFreeMem EQU -210
_LVOAvailMem EQU -216
_LVOAddIntServer EQU -168
_LVORemIntServer EQU -174
_LVOOpenResource EQU -498
_LVOSetIntVector EQU -162
_LVORemDevice EQU -438
_LVOOldOpenLibrary EQU -408
_LVOSetSignal EQU -306
_LVOWait EQU -318
_LVOSignal EQU -324
; CIA Resource Offsets
_AddICRVector EQU -6
_RemICRVector EQU -12
; DOS Library Offsets
_LVOOpen EQU -30
_LVOClose EQU -36
_LVORead EQU -42
_LVOWrite EQU -48
_LVODeleteFile EQU -72
_LVORename EQU -78
_LVOLock EQU -84
_LVOUnLock EQU -90
_LVOExamine EQU -102
_LVOExNext EQU -108
_LVOInfo EQU -114
_LVOSeek EQU -66
_LVOCreateDir EQU -120
_LVOCurrentDir EQU -126
_LVODateStamp EQU -192
_LVODelay EQU -198
_LVOExecute EQU -222
_LVOUnLoadSeg EQU -156
_LVOParentDir EQU -210
_LVODupLock EQU -96
_LVOCreateProc EQU -138
; Intuition Library Offsets
_LVOCloseScreen EQU -66
_LVOOpenScreen EQU -198
_LVOOpenWorkbench EQU -210
_LVOScreenToBack EQU -246
_LVOScreenToFront EQU -252
_LVOWBenchToFront EQU -342
; Graphics Library Offsets
_LVOWaitBlit EQU -228
_LVOOwnBlitter EQU -456
_LVODisownBlitter EQU -462
; Power Packer Library Offsets
_LVOppLoadData EQU -30
_LVOppAllocCrunchInfo EQU -96
_LVOppFreeCrunchInfo EQU -102
_LVOppCrunchBuffer EQU -108
_LVOppWriteDataHeader EQU -114
; DateStamp
ofib_DateStamp EQU $84
ds_Days EQU $00
ds_Minute EQU $04
ds_Tick EQU $08
; Memory Alloc Flags
MEMF_PUBLIC EQU $0001
MEMF_CHIP EQU $0002
MEMF_FAST EQU $0004
MEMF_CLEAR EQU $10000
MEMF_TOTAL EQU $80000
; IO Block Offsets
IO_COMMAND EQU $1C
IO_FLAGS EQU $1E
IO_ACTUAL EQU $20
IO_LENGTH EQU $24
IO_DATA EQU $28
IO_OFFSET EQU $2C
; Device Commands
CMD_READ EQU $2
CMD_WRITE EQU $3
CMD_UPDATE EQU $4
TD_MOTOR EQU $9
TD_FORMAT EQU $B
TD_CHANGESTATE EQU $E
TD_PROTSTATUS EQU $F
DirNameLength EQU 30
ConfigFileSize EQU 1024
KeyBufSize EQU 20
ThisTask EQU $114
pr_CLI EQU $AC
pr_MsgPort EQU $5C
sm_ArgList EQU $24
cli_CommandName EQU $10
SHARED_LOCK EQU -2
; -----------------------------------------------------------------------------
; RUNBACK HUNK (modified by ross)
; -----------------------------------------------------------------------------
SECTION ptrunback,CODE
rb_HunkStart
MOVE.L 4.W,A6
LEA DOSname,A1
JSR _LVOOldOpenLibrary(A6)
MOVE.L D0,A5 ; dosbase
MOVE.L ThisTask(A6),A3
MOVE.L pr_CLI(A3),D6 ; d6 = CLI or WB (NULL)
BNE.B .fromCLI
; Get startup message if we started from Workbench
LEA pr_MsgPort(A3),A0
JSR _LVOWaitPort(A6) ; wait for a message
LEA pr_MsgPort(A3),A0
JSR _LVOGetMsg(A6) ; then get it
MOVE.L D0,A3 ; a3 = WBStartup message
MOVE.L sm_ArgList(A3),A0
MOVE.L (A0),D5 ; (wa_Lock) FileLock on program dir
EXG A5,A6 ; _dos
BSR.B .common
; Reply to the startup message
JSR _LVOForbid(A6) ; it prohibits WB to unloadseg me
LEA (A3),A1
JMP _LVOReplyMsg(A6) ; reply to WB message and exit
.fromCLI
; Get FileLock via command name if we started from CLI
LINK A3,#-256
; Copy BCPL string to C-style string
LEA (SP),A1
LSL.L #2,D6
MOVE.L D6,A0
MOVE.L cli_CommandName(A0),A0
ADD.L A0,A0
ADD.L A0,A0
MOVE.B (A0)+,D0
.loop MOVE.B (A0)+,(A1)+
SUBQ.B #1,D0
BNE.B .loop
CLR.B (A1)
; Get a lock on the program and its parent
EXG A5,A6 ; _dos
MOVE.L SP,D1 ; d1 = STRPTR name (command string)
MOVEQ #SHARED_LOCK,D2 ; d2 = accessMode
JSR _LVOLock(A6)
MOVE.L D0,D7
MOVE.L D0,D1
JSR _LVOParentDir(A6)
MOVE.L D7,D1
MOVE.L D0,D6 ; d6 = Lock on CLI program dir
MOVE.L D0,D5 ; d5 = common Lock
JSR _LVOUnLock(A6)
UNLK A3
.common
MOVE.L D5,D1
JSR _LVODupLock(A6)
MOVE.L D0,rb_CurrentDir
MOVE.L #rb_Progname,D1
MOVEQ #0,D2
MOVE.B 9(A3),D2 ; priority
LEA rb_HunkStart-4(PC),A0
MOVE.L (A0),D3 ; ptr to next segment
CLR.L (A0) ; unlink next segment
MOVE.L #2048,D4 ; stack=2kB (big enough for this program)
JSR _LVOCreateProc(A6)
MOVE.L D6,D1 ; UnLock program dir or zero (from WB)
JSR _LVOUnLock(A6)
LEA (A6),A1
LEA (A5),A6
JSR _LVOCloseLibrary(A6)
MOVEQ #0,D0
RTS
; -----------------------------------------------------------------------------
; MAIN CODE
; -----------------------------------------------------------------------------
SECTION ptcode,CODE
PTStart
MOVEQ #0,D0
MOVE.L 4.W,A6
SUB.L A1,A1
JSR _LVOFindTask(A6)
MOVE.L D0,PTProcess
MOVE.L D0,A0
MOVE.L $B8(A0),PTProcessTmp
BSR.W Main
MOVE.L PTProcess(PC),A0
MOVE.L PTProcessTmp(PC),$B8(A0)
MOVE.L 4.W,A6
JSR _LVOForbid(A6)
MOVE.L DOSBase,A6
MOVE.L rb_CurrentDir(PC),D1
JSR _LVOUnLock(A6)
LEA PTStart-4(PC),A0
MOVE.L A0,D1
LSR.L #2,D1
JSR _LVOUnLoadSeg(A6)
MOVEQ #0,D0
RTS
; ------------------------------------------------------------------------------
; Scanline-wait routines. Used for Paula DMA latch waiting, and GUI interaction
;
; Note:
; "InitDelayRoutines" has to be called on program init to use these.
; ------------------------------------------------------------------------------
WaitForPaulaLatch
MOVEM.L D0/D7/A0,-(SP)
LEA $DFF006,A0
MOVE.W PaulaDMAWaitScanlines,D7
.loop1 MOVE.B (A0),D0
.loop2 CMP.B (A0),D0
BEQ.B .loop2
DBRA D7,.loop1
MOVEM.L (SP)+,D0/D7/A0
RTS
GUIDelay
TST.W GUIDelayScanlines ; delay needed at all (68k)?
BEQ.B .end ; nope!
MOVEM.L D0/D7/A0,-(SP)
LEA $DFF006,A0
MOVE.W GUIDelayScanlines,D7
.loop1 MOVE.B (A0),D0
.loop2 CMP.B (A0),D0
BEQ.B .loop2
DBRA D7,.loop1
MOVEM.L (SP)+,D0/D7/A0
.end RTS
InitDelayRoutines
MOVE.L A6,-(SP)
MOVE.L D0,-(SP)
MOVE.L 4.W,A6
MOVE.W 296(A6),D0
BTST #1,D0
BNE.B .not68000
MOVE.W #PaulaDMAWaitScanlines_000,PaulaDMAWaitScanlines
MOVE.W #GUIDelayScanlines_000,GUIDelayScanlines
BRA.B .end
.not68000
MOVE.W #PaulaDMAWaitScanlines_020,PaulaDMAWaitScanlines
MOVE.W #GUIDelayScanlines_020,GUIDelayScanlines
.end MOVE.L (SP)+,D0
MOVE.L (SP)+,A6
RTS
; ------------------------------------------------------------------------------
; 32-bit unsigned div/mul routines. Software-based if CPU is 68000.
;
; Note:
; "InitMulDivRoutines" has to be called on program init to use these.
; ------------------------------------------------------------------------------
; 32x32 -> 32 unsigned multiplication
;
; Input:
; D0.L - Multiplicand
; D1.L - Multiplier
;
; Output:
; D0.L - 32-bit unsigned result
MULU32
TST.B _CPUIs68000
BNE.B SoftMULU32
MULU.L D1,D0
RTS
SoftMULU32
MOVE.L D2,-(SP)
MOVE.L D3,-(SP)
MOVE.L D0,D2
MOVE.L D1,D3
SWAP D2
SWAP D3
MULU.W D1,D2
MULU.W D0,D3
MULU.W D1,D0
ADD.W D3,D2
SWAP D2
CLR.W D2
ADD.L D2,D0
MOVE.L (SP)+,D3
MOVE.L (SP)+,D2
RTS
; 32/32 -> 32 unsigned division (without remainder)
;
; Input:
; D0.L - Dividend
; D1.L - Divisor
;
; Output:
; D0.L - 32-bit unsigned quotient
DIVU32
TST.B _CPUIs68000
BNE.B SoftDIVU32
DIVU.L D1,D0
RTS
SoftDIVU32
MOVEM.L D1/D2/D3,-(SP)
SWAP D1
TST.W D1
BNE.B .L1
SWAP D1
MOVE.L D1,D3
SWAP D0
MOVE.W D0,D3
BEQ.B .L0
DIVU.W D1,D3
MOVE.W D3,D0
.L0 SWAP D0
MOVE.W D0,D3
DIVU.W D1,D3
MOVE.W D3,D0
BRA.B .end
.L1 SWAP D1
MOVE.L D1,D2
MOVE.L D0,D1
CLR.W D1
SWAP D1
SWAP D0
CLR.W D0
MOVEQ #16-1,D3
.loop ADD.L D0,D0
ADDX.L D1,D1
CMP.L D1,D2
BHI.B .L2
SUB.L D2,D1
ADDQ.L #1,D0
.L2 DBRA D3,.loop
.end MOVEM.L (SP)+,D1/D2/D3
RTS
InitMulDivRoutines
MOVE.L A6,-(SP)
MOVE.L D0,-(SP)
MOVE.L 4.W,A6
MOVE.W 296(A6),D0
BTST #1,D0
SEQ _CPUIs68000
MOVE.L (SP)+,D0
MOVE.L (SP)+,A6
RTS
_CPUIs68000 dc.b 1
EVEN
; ------------------------------------------------------------------------------
; ------------------------------------------------------------------------------
Main
MOVE.L SP,StackSave ; important! (leaking memory without it, for some reason)
; ---------------------
BSR.W InitDelayRoutines
BSR.W InitMulDivRoutines
BSR.W OpenLotsOfThings
BSR.W SetVBInt
BSR.W SetMusicInt
JSR SetPatternPos
BSR.W SetNormalPtrCol
BSR.W StorePtrCol
BSR.W RedrawToggles
BSR.W DoShowFreeMem
BSR.W SetTempo
BSR.W SetInputHandler
BSR.W PTScreenToFront
BSR.W CheckInitError
BSR.W DirBrowseGadg2
MOVEQ #0,D3
MOVE.W DirPathNum(PC),D3
LEA dpnum(PC),A0
ADD.L D3,A0
MOVE.B #$FF,(A0)
BSR.W DirBrowseGadg2
LEA VersionText(PC),A0
JSR ShowStatusText
MOVE.L SongDataPtr,A0
MOVE.B #1,sd_numofpatt(A0)
BSR.W DisplayMainScreen
; fall-through
MainLoop
JSR CheckMIDIin
BSR.W DoKeyBuffer
BSR.W CheckToggleRasterbarKeys
BSR.W CheckSamplerScreenKeys
BSR.W CheckPatternInvertKeys
BSR.W CheckTransKeys
BSR.W CheckCtrlKeys
BSR.W CheckAltKeys
BSR.W CheckListQuickJump
BSR.W CheckKeyboard
BSR.W CheckF1_F2
BSR.W CheckF3_F5
BSR.W CheckF6_F10
BSR.W CheckPlayKeys
BSR.W CheckHelpKey
BSR.W ArrowKeys2
BSR.W ShowFreeMem
BSR.W CheckBlockPos
JSR CheckSampleLength ; test if we need to alloc more mem
BSR.W CheckPatternRedraw
TST.B SetSignalFlag
BNE.B .skip
MOVE.L 4.W,A6
MOVEQ #0,D0
MOVE.L #$30000000,D1
JSR _LVOSetSignal(A6)
MOVE.L #$70000000,D0
JSR _LVOWait(A6)
AND.L #$10000000,D0
BNE.B .skip2
.skip SF SetSignalFlag
BTST #6,$BFE001 ; left mouse button
BNE.W StopInputLoop
.skip2 BSR.W ArrowKeys
BRA.W CheckGadgets
BRA.W MainLoop
CheckToggleRasterbarKeys
TST.W LeftAmigaStatus
BEQ.W Return1
TST.W CtrlKeyStatus
BEQ.W Return1
MOVE.B RawKeyCode,D0
CMP.B #48,D0 ; '<'
BNE.W Return1
EOR.B #1,ShowRasterbar
RTS
; used stop further key/mouse input for a while
StopInputLoop
TST.B StopInputFlag
BNE.W MainLoop
MOVEQ #8*2,D1
BSR.W WaitD1
BRA.B StopInputLoop
;---- Sample data range/mark special keys (sampler screen) ----
; SHIFT + ALT/CTRL + z:
; Play Range
;
; SHIFT + ALT/CTRL + up/down/left/right:
; Extends/shrinks sample range
CheckSamplerScreenKeys
TST.W SamScrEnable
BEQ.B SKeysCheckEnd
TST.W ShiftKeyStatus
BEQ.B SKeysCheckEnd
TST.W AltKeyStatus
BNE.B .doit
TST.W CtrlKeyStatus
BEQ.B SKeysCheckEnd
.doit ; ----------------------------
MOVE.B RawKeyCode,D0
CMP.B #49,D0 ; z
BEQ.B PlayRange2
CMP.B #79,D0 ; left
BEQ.W ExtendLeftMarkSide
CMP.B #78,D0 ; right
BEQ.W ShrinkLeftMarkSide
CMP.B #76,D0 ; up
BEQ.W ExtendRightMarkSide
CMP.B #77,D0 ; down
BEQ.W ShrinkRightMarkSide
SKeysCheckEnd
RTS
PlayRange2
CLR.B RawKeyCode
MOVE.L MarkStartOfs,D1
BMI.B SKeysCheckEnd
MOVE.L MarkEndOfs,D0
CMP.L D0,D1
BEQ.B SKeysCheckEnd
LEA SampleInfo,A0
MOVE.L D1,StartOfs
SUB.L D1,D0
LSR.L #1,D0
MOVE.W D0,(A0)
CLR.W 4(A0)
MOVE.W #1,6(A0)
MOVE.W PlayInsNum,D0
MOVE.W D0,-(SP)
MOVE.B D0,PlayInsNum2
CLR.W PlayInsNum
JSR PlayNote
MOVE.W (SP)+,PlayInsNum
RTS
ExtendLeftMarkSide
CLR.B RawKeyCode
TST.W MarkStart
BEQ.B SKeysCheckEnd
CMP.W #3,MarkStart
BLS.B SKeysCheckEnd
JSR InvertRange
SUBQ.W #1,MarkStart
BRA.B UpdateNewMark
ShrinkLeftMarkSide
CLR.B RawKeyCode
TST.W MarkStart
BEQ.W SKeysCheckEnd
CMP.W #316,MarkStart
BGE.W SKeysCheckEnd
JSR InvertRange
ADDQ.W #1,MarkStart
BRA.B UpdateNewMark
ExtendRightMarkSide
CLR.B RawKeyCode
TST.W MarkStart
BEQ.W SKeysCheckEnd
CMP.W #316,MarkEnd
BGE.W SKeysCheckEnd
JSR InvertRange
ADDQ.W #1,MarkEnd
BRA.B UpdateNewMark
ShrinkRightMarkSide
CLR.B RawKeyCode
TST.W MarkStart
BEQ.W SKeysCheckEnd
CMP.W #3,MarkEnd
BLS.W SKeysCheckEnd
JSR InvertRange
SUBQ.W #1,MarkEnd
; -- fall-through --
UpdateNewMark
MOVE.W MarkStart,D0
MOVE.W MarkEnd,D1
CMP.W D0,D1
BHS.B .ok
MOVE.W D0,MarkEnd
MOVE.W D1,MarkStart
.ok JSR InvertRange
JMP MarkToOffset
CNOP 0,4
PTProcess dc.l 0
PTProcessTmp dc.l 0
rb_CurrentDir dc.l 0
rb_PtDir dc.l 0
rb_Progname dc.b 'PT2.3F',0
VersionText dc.b 'ProTracker v2.3F',0
InitError dc.b 0
EVEN
CheckInitError
MOVE.B InitError(PC),D0
BEQ.W Return1
BTST #0,D0
BEQ.B cieskp1
JSR PLSTMemErr
cieskp1
MOVE.B InitError(PC),D0
BTST #1,D0
BEQ.B cieskp2
JSR PLSTOpenErr
JSR FreePLST
cieskp2
MOVE.B InitError(PC),D0
BTST #2,D0
BEQ.B cieskp3
JSR ConfigErr
cieskp3
MOVE.B InitError(PC),D0
BTST #3,D0
BEQ.W Return1
JSR ConfigErr2
BSR.W SetNormalPtrCol
BRA.W StorePtrCol
CheckPatternRedraw
TST.B UpdateTempo
BEQ.B chkredr
CLR.B UpdateTempo
BSR.W SetTempo
chkredr CMP.L #'patp',RunMode
BNE.W Return1
JSR ShowPosition
JSR RefreshPosEd
TST.B PattRfsh
BEQ.W Return1
MOVE.L PattRfshNum,PatternNumber
JMP RedrawPattern
; ----------------------------------------------------------------------------
; Allocates a block of memory
;
; Input:
; D0 - byteSize
; D1 - attributes
;
; Output:
; D0 - memoryBlock (0 if alloc failed)
; ----------------------------------------------------------------------------
PTAllocMem
MOVEM.L D1/A1/A6,-(SP)
MOVE.L 4.W,A6
JSR _LVOAllocMem(A6)
MOVEM.L (SP)+,D1/A1/A6
RTS
; ----------------------------------------------------------------------------
; Frees a block of memory
;
; Input:
; A1 - memoryBlock
; D0 - byteSize
; ----------------------------------------------------------------------------
PTFreeMem
MOVEM.L D0/D1/A1/A6,-(SP)
MOVE.L 4.W,A6
JSR _LVOFreeMem(A6)
MOVEM.L (SP)+,D0/D1/A1/A6
RTS
;---- Cleanup upon exit from PT ----
ExitCleanup
JSR StopIt
SF EdEnable
BSR.W EscPressed
BSR.W EscPressed
BSR.W ResetVBInt
BSR.W ResetMusicInt
BSR.W ResetInputHandler
BSR.W SetOldCopList
JSR CloseMIDI
JSR FreeCopyBuf
errorexit1
BSR.W PTScreenToBack
BSR.W ClosePTScreen
MOVE.L 4.W,A6
MOVE.L GfxBase,A1
JSR _LVOCloseLibrary(A6)
MOVE.L IntuitionBase,A1
JSR _LVOCloseLibrary(A6)
MOVE.L DOSBase,A1
JSR _LVOCloseLibrary(A6)
TST.L PPLibBase ; did we open powerpacker.library?
BEQ.B exex1 ; no, don't attempt to close it
MOVE.L PPLibBase,A1
JSR _LVOCloseLibrary(A6)
exex1 MOVE.L SongDataPtr,D1
BEQ.B exex2
MOVE.L D1,A1
MOVE.L SongAllocSize,D0
JSR PTFreeMem
exex2 BSR.W FreeDirMem
BSR.W GiveBackInstrMem
JSR FreePLST
JSR TurnOffVoices
BCLR #1,$BFE001
MOVE.B LEDStatus,D0
AND.B #2,D0
OR.B D0,$BFE001 ; Restore LED Status
MOVEQ #0,D0
MOVE.W D0,$DFF0A8 ; clear voice #1 volume
MOVE.W D0,$DFF0B8 ; clear voice #2 volume
MOVE.W D0,$DFF0C8 ; clear voice #3 volume
MOVE.W D0,$DFF0D8 ; clear voice #4 volume
MOVE.L StackSave,SP ; important! (leaking memory without it, for some reason)
Return1 RTS
;---- Open Lots Of Things ----
SetDefaultSampleReplens
MOVE.L SongDataPtr,A0
LEA sd_sampleinfo(A0),A0
MOVEQ #31-1,D0
.loop MOVE.W #1,28(A0)
LEA 30(A0),A0
DBRA D0,.loop
RTS
OpenLotsOfThings
MOVE.B $BFE001,LEDStatus
BSET #1,$BFE001
JSR TurnOffVoices
MOVEQ #0,D0
MOVE.W D0,$DFF0A8 ; clear voice #1 volume
MOVE.W D0,$DFF0B8 ; clear voice #2 volume
MOVE.W D0,$DFF0C8 ; clear voice #3 volume
MOVE.W D0,$DFF0D8 ; clear voice #4 volume
MOVE.L 4.W,A6
; -------------------------------
; set song playback counter delta
; -------------------------------
CMP.B #60,$0212(A6) ; 50=PAL, 60=NTSC
BEQ.B .NTSC
MOVE.L #PDELTA_PAL,PlaybackSecsDelta
BRA.B .L1
.NTSC MOVE.W $DFF004,D0
LSR.W #8,D0
AND.B #$3F,D0
CMP.B #20,D0 ; Agnus is ECS or AGA?
BLO.B .L0 ; nope
MOVE.L #PDELTA_PAL_ON_NTSC,PlaybackSecsDelta
BRA.B .L1
.L0 MOVE.L #PDELTA_NTSC,PlaybackSecsDelta
.L1 ; -------------------------------
LEA DOSname(PC),A1 ; Open DOS library
MOVEQ #0,D0
JSR _LVOOpenLibrary(A6)
MOVE.L D0,DOSBase
LEA GraphicsName(PC),A1 ; Open graphics library
MOVEQ #0,D0
JSR _LVOOpenLibrary(A6)
MOVE.L D0,GfxBase
LEA IntuitionName(PC),A1 ; Open Intuition library
MOVEQ #0,D0
JSR _LVOOpenLibrary(A6)
MOVE.L D0,IntuitionBase
BSR.W OpenPTScreen
BEQ.W errorexit1
MOVE.L DOSBase,A6
MOVE.L rb_CurrentDir(PC),D1
JSR _LVOCurrentDir(A6)
MOVE.L #TextBitplane,D0
MOVE.W D0,NoteBplptrLow ; set low word
SWAP D0
MOVE.W D0,NoteBplptrHigh ; set high word
MOVE.L SongAllocSize,D0
MOVE.L #MEMF_PUBLIC!MEMF_CLEAR,D1
JSR PTAllocMem
MOVE.L D0,SongDataPtr
BEQ.W errorexit1
BSR.W SetDefaultSampleReplens
MOVE.L SongDataPtr,A0
MOVE.W #$017F,sd_numofpatt(A0)
MOVE.L #'M.K.',sd_magicid(A0) ; M.K. again...
MOVEQ #6,D0
MOVE.L D0,CurrSpeed
CLR.W PEDpos
MOVE.L #ModulesPath2,PathPtr
MOVE.L #CopCol1,CopListColorPtr
MOVE.L #CopListBpl4,CopListBpl4Ptr
MOVE.L #KbdTransTable2,KeyTransTabPtr
MOVE.L #NoteNames1,NoteNamesPtr
MOVE.L #VUmeterColors,TheRightColors
MOVE.L #BitplaneData,D0 ; Set pointers to bitplane data
LEA CopListBitplanes,A1
MOVE.W D0,6(A1)
SWAP D0
MOVE.W D0,2(A1)
SWAP D0
ADD.L #10240,D0
MOVE.W D0,14(A1)
SWAP D0
MOVE.W D0,10(A1)
BSR.W SetDefSpritePtrs
BSR.W UpdateCursorPos
JSR RedrawPattern
JSR ShowPosition
JSR ShowSongLength
MOVE.W #1,InsNum
JSR ShowSampleInfo
LEA TopMenusPos,A0
LEA TopMenusBuffer,A1
MOVEQ #44-1,D0
stmloop MOVEQ #25-1,D1
stmloop2
MOVE.B (A0)+,(A1)+
MOVE.B $27FF(A0),$044B(A1)
DBRA D1,stmloop2
LEA 15(A0),A0
DBRA D0,stmloop
JSR DoResetAll
JSR cfgupda
JSR LoadConfigOnStartup ; --PT2.3D bug fix: make sure cwd is correct at this point
MOVE.L #NoteNames1,NoteNamesPtr
TST.B Accidental
BEQ.B alotskip
MOVE.L #NoteNames2,NoteNamesPtr
alotskip
TST.B OneHundredPattFlag
BEQ.B alotskip3
MOVE.L SongDataPtr,D1
BEQ.B alotskip2
MOVE.L D1,A1
MOVE.L SongAllocSize,D0
JSR PTFreeMem
alotskip2
MOVE.L #SONG_SIZE_100PAT,SongAllocSize
MOVE.L #100-1,MaxPattern
MOVE.L SongAllocSize,D0
MOVE.L #MEMF_CLEAR!MEMF_PUBLIC,D1
JSR PTAllocMem
MOVE.L D0,SongDataPtr
BEQ.W errorexit1
BSR.W SetDefaultSampleReplens
alotskip3
TST.B LoadPLSTFlag
BEQ.B ChangeCopList
JSR DoLoadPLST
ChangeCopList
TST.W SamScrEnable
BNE.W Return1
BSR.W SetupAnaCols
SetupVUCols
TST.W SamScrEnable
BNE.W Return1
LEA CopListMark2,A0 ; VUmeter coloring
MOVE.W #$B907,D5 ; Start position
LEA VUmeterColors,A5
MOVEQ #48-1,D7 ; Change 48 lines
alotlp4 MOVE.W D5,(A0)+
MOVE.W #$FFFE,(A0)+
LEA VUmeterColRegs(PC),A1
MOVEQ #2-1,D6
alotlp5 MOVE.W (A5),D4
MOVE.W (A1)+,(A0)+
MOVE.W #3,FadeX
MOVE.W D4,D0
JSR FadeCol
MOVE.W D0,(A0)+
MOVE.W (A1)+,(A0)+
MOVE.W D4,(A0)+
MOVE.W (A1)+,(A0)+
MOVE.W #$FFFD,FadeX
MOVE.W D4,D0
JSR FadeCol
MOVE.W D0,(A0)+
DBRA D6,alotlp5
ADDQ #2,A5
ADD.W #$0100,D5 ; Next line...
DBRA D7,alotlp4
RTS
VUmeterColRegs
dc.w $01AA,$01AC,$01AE,$01B2,$01B4,$01B6
CNOP 0,4
CopListBpl4Ptr dc.l 0
CopListColorPtr dc.l 0
DOSname dc.b 'dos.library',0
IntuitionName dc.b 'intuition.library',0
GraphicsName dc.b 'graphics.library',0
EVEN
SetupAnaCols
LEA CopListAnalyzer,A5
MOVE.W ColorTable+12,D2
MOVEQ #40-1,D0 ; Change col 40 lines
MOVE.W #$687D,D1 ; Start pos
TST.B ScreenAdjustFlag
BEQ.B sacloop
SUBQ.W #8,D1
sacloop MOVE.W D1,(A5)+ ; Set wait
MOVE.W #$FFFE,(A5)+
MOVE.W #$018C,(A5)+ ; Set analyzer color
ADDQ #2,A5
ADD.W #$0060,D1 ; Move x-pos
MOVE.W D1,(A5)+ ; Wait
MOVE.W #$FFFE,(A5)+
MOVE.W #$018C,(A5)+ ; Set text color
MOVE.W D2,(A5)+
ADD.W #$A0,D1 ; Next line...
DBRA D0,sacloop
TST.B DisableAnalyzer
BNE.B ClearAnalyzerColors
SetAnalyzerColors
LEA CopListAnalyzer+6,A1
LEA AnalyzerColors,A0
MOVEQ #40-1,D0 ; 40 lines
sanclop MOVE.W (A0)+,(A1)
LEA 16(A1),A1
DBRA D0,sanclop
RTS
ClearAnalyzerColors
LEA CopListAnalyzer+6,A0
MOVE.W ColorTable+12,D1
MOVEQ #40-1,D0 ; 40 lines.
cacloop MOVE.W D1,(A0)
LEA 16(A0),A0
DBRA D0,cacloop
RTS
SetSamSpritePtrs
MOVE.L #LoopSpriteData1,Ch1SpritePtr
MOVE.L #LoopSpriteData2,Ch2SpritePtr
MOVE.L #PlayPosSpriteData,Ch3SpritePtr
MOVE.L #NoSpriteData,Ch4SpritePtr
BRA.B sdsp2
SetDefSpritePtrs
MOVE.L #VUSpriteData1,Ch1SpritePtr
MOVE.L #VUSpriteData2,Ch2SpritePtr
MOVE.L #VUSpriteData3,Ch3SpritePtr
MOVE.L #VUSpriteData4,Ch4SpritePtr
sdsp2
MOVE.L #CursorSpriteData,CursorPosPtr
MOVE.L #PointerSpriteData,PointerSpritePtr
MOVE.L #LineCurSpriteData,LineCurPosPtr
MOVE.L #NoSpriteData,NoSpritePtr
MOVE.L PointerSpritePtr(PC),SpritePtrsPtr
LEA SpritePtrsPtr,A0 ; Set pointers to spritedata
LEA CopperSpriteList,A1
MOVEQ #16-1,D2
alotloop2
MOVE.W (A0)+,2(A1)
ADDQ #4,A1
DBRA D2,alotloop2
RTS
CNOP 0,4
PointerSpritePtr dc.l 0
;---- Vertical Blank Interrupt ----
SetVBInt
MOVEQ #5,D0
LEA VBIntServer(PC),A1
MOVE.L 4.W,A6
JSR _LVOAddIntServer(A6)
RTS
ResetVBInt
MOVEQ #5,D0
LEA VBIntServer(PC),A1
MOVE.L 4.W,A6
JSR _LVORemIntServer(A6)
RTS
vbint
TST.B ShowRasterbar
BEQ.B .skip1
MOVE.W #$125,$DFF180 ; rasterbars to measure frame time left
.skip1
MOVEM.L D0-D7/A0-A6,-(SP)
; ------------------------------
BSR.W TickPlaybackCounter
BSR.W CheckIfProgramIsActive
BEQ.W vbiend
BSR.W UpdatePointerPos
BSR.W Scope ; draw scopes early to lower chance of flickering
TST.B RealVUMetersFlag
BEQ.B .skip2
BSR.W RealVUMeters
BRA.B vbint2
.skip2 BSR.W VUMeters
vbint2 BSR.W SpecAnaInt
BSR.W ArrowKeys
BSR.W CheckKeyRepeat
MOVE.L SongPosition,CurrPos
MOVE.L SongDataPtr,A0
LEA sd_pattpos(A0),A0
ADD.L CurrPos,A0
MOVE.B (A0),D1
MOVE.B D1,PattRfshNum+3
CMP.B LongFFFF+3,D1
BEQ.B vbiskip
ST PattRfsh
vbiskip
MOVE.B D1,LongFFFF+3
TST.B PattRfsh
BNE.B vbiskip2
TST.W BlockMarkFlag
BNE.B vbiskip2
TST.B UpdateTempo
BNE.B vbiskip2
TST.W KeyBufPos
BEQ.B vbiskip3
vbiskip2
MOVE.L 4.W,A6
MOVE.L PTProcess(PC),A1
MOVE.L #$20000000,D0
JSR _LVOSignal(A6)
vbiskip3
BTST #6,$BFE001 ; left mouse button
BNE.B vbiskip4
MOVE.L 4.W,A6
MOVE.L PTProcess(PC),A1
MOVE.L #$10000000,D0
JSR _LVOSignal(A6)
vbiskip4
; bit of a kludge to get scope muting working
TST.B RightMouseButtonHeld
BEQ.B rmbnotheld
rmbheld
BTST.B #10-8,$DFF016
BEQ.B rmbreleased
BRA.B vbiend
rmbnotheld
BTST.B #10-8,$DFF016
BEQ.B vbiend
ST RightMouseButtonHeld
BRA.B vbiend
rmbreleased
CLR.B RightMouseButtonHeld
BSR.W CheckScopeMuting
vbiend ; ------------------------------
MOVEM.L (SP)+,D0-D7/A0-A6
TST.B ShowRasterbar
BEQ.B .skip2
MOVE.W #0,$DFF180 ; rasterbars to measure frame time left
.skip2
RTS
CNOP 0,4
VBIntServer
dc.l 0,0
dc.b 2,0 ; type, priority
dc.l vbintname
dc.l 0,vbint
vbintname dc.b 'ProTracker VBlank',0
EVEN
CheckPatternRedraw2
MOVEM.L D0-D7/A0-A6,-(SP)
MOVE.W WordNumber,-(SP)
MOVE.W TextOffset,-(SP)
MOVE.L LongFFFF,-(SP)
MOVE.W TextLength,-(SP)
MOVE.L ShowTextPtr,-(SP)
BSR.W CheckPatternRedraw
MOVE.L (SP)+,ShowTextPtr
MOVE.W (SP)+,TextLength
MOVE.L (SP)+,LongFFFF
MOVE.W (SP)+,TextOffset
MOVE.W (SP)+,WordNumber
MOVEM.L (SP)+,D0-D7/A0-A6
RTS
CheckIfProgramIsActive
MOVE.L IntuitionBase,A6
MOVE.L 60(A6),D0
CMP.L PTScreenHandle(PC),D0
BNE.B cipiaskip2
CMP.L WBScreenHandle(PC),D0
BEQ.B cipiaskip
MOVE.L D0,WBScreenHandle
BSR.B SetCopList
CLR.W LeftAmigaStatus
ST StopInputFlag
cipiaskip
MOVEQ #1,D0
RTS
cipiaskip2
CMP.L WBScreenHandle(PC),D0
BEQ.B cipiaskip3
MOVE.L D0,WBScreenHandle
BSR.B SetOldCopList
SF StopInputFlag
cipiaskip3
MOVEQ #0,D0
RTS
;---- Copper List ----
SetCopList
MOVE.L #CopperList1,$DFF080
RTS
SetOldCopList
MOVE.L GfxBase,A0
MOVE.L 38(A0),$DFF080
RTS
;---- Intuition Routines ----
OpenPTScreen
MOVE.L IntuitionBase,A6
LEA PTScreenStruct(PC),A0
JSR _LVOOpenScreen(A6)
MOVE.L D0,PTScreenHandle
RTS
ClosePTScreen
MOVE.L IntuitionBase,A6
MOVE.L PTScreenHandle(PC),D0
BEQ.B cptsskip
MOVE.L D0,A0
JSR _LVOCloseScreen(A6)
CLR.L PTScreenHandle
cptsskip
RTS
PTScreenToBack
MOVEM.L D1/A0-A1/A6,-(SP)
MOVE.L IntuitionBase,A6
MOVE.L PTScreenHandle(PC),D0
BEQ.B ptstbskip
MOVE.L D0,A0
JSR _LVOScreenToBack(A6)
ptstbskip
MOVE.L 4.W,A0
CMP.W #32,20(A0)
BLS.B ptstbskip2
MOVE.L GfxBase,A0
MOVEQ #28,D0
AND.B 236(A0),D0
CMP.B #28,D0
BNE.B ptstbskip2
MOVE.W BeamCONTemp,$DFF1DC
ptstbskip2
MOVEM.L (SP)+,D1/A0-A1/A6
RTS
PTScreenToFront
MOVEM.L D1/A0-A1/A6,-(SP)
MOVE.L 4.W,A0
CMP.W #32,20(A0)
BLS.B ptstfskip
MOVE.L GfxBase,A0
MOVEQ #28,D0
AND.B 236(A0),D0
CMP.B #28,D0
BNE.B ptstfskip
MOVE.L 380(A0),A0
MOVE.W 40(A0),BeamCONTemp
ptstfskip
MOVE.L IntuitionBase,A6
MOVE.L PTScreenHandle(PC),A0
JSR _LVOScreenToFront(A6)
MOVEM.L (SP)+,D1/A0-A1/A6
RTS
WorkbenchToFront
MOVEM.L D1/A0-A1/A6,-(SP)
MOVE.L IntuitionBase,A6
JSR _LVOWBenchToFront(A6)
MOVEM.L (SP)+,D1/A0-A1/A6
RTS
CNOP 0,4
PTScreenHandle dc.l 0
WBScreenHandle dc.l 0
PTScreenStruct
dc.w 0 ; LeftEdge
dc.w 0 ; TopEdge
dc.w 320 ; Width
dc.w 12 ; Height (lower than 12 = crash. Found out the hard way!)
dc.w 1 ; Depth (only one bitplane. We don't render in the screen)
dc.b 0 ; DetailPen
dc.b 1 ; BlockPen
dc.w 0 ; ViewModes
dc.w $008F ; Types ($008F = CUSTOMSCREEN | SCREENBEHIND)
dc.l 0 ; TextAttr struct pointer
dc.l VersionText ; DefaultTitle
dc.l 0 ; Gadget struct pointer
dc.l 0 ; BitMap struct pointer
;---- Music Interrupt ----
SetMusicInt
TST.B IntMode
BNE.B SetCIAInt
MOVEQ #5,D0
LEA MusicIntServer(PC),A1
MOVE.L 4.W,A6
JSR _LVOAddIntServer(A6)
RTS
ResetMusicInt
TST.B IntMode
BNE.W ResetCIAInt
MOVEQ #5,D0
LEA MusicIntServer(PC),A1
MOVE.L 4.W,A6
JSR _LVORemIntServer(A6)
RTS
CNOP 0,4
MusicIntServer
dc.l 0,0
dc.b 2,1 ; type, priority
dc.l musintname
dc.l 0,IntMusic
musintname dc.b "ProTracker MusicInt",0
EVEN
;---- CIA Interrupt ----
ciatalo = $400
ciatahi = $500
ciatblo = $600
ciatbhi = $700
ciacra = $E00
ciacrb = $F00
SetCIAInt
MOVEQ #2,D6
LEA $BFD000,A5
MOVE.B #'b',CIAAname+3
SetCIALoop
MOVEQ #0,D0
LEA CIAAname(PC),A1
MOVE.L 4.W,A6
JSR _LVOOpenResource(A6)
MOVE.L D0,CIAAbase
BEQ.W Return1
MOVE.L D0,A6
MOVE.L GfxBase,A0
MOVE.W 206(A0),D0 ; DisplayFlags
BTST #2,D0 ; PAL?
BEQ.B WasNTSC
MOVE.L #1773447,D7 ; PAL (= round[709379.0 * (125/50)])
BRA.B sciask
WasNTSC MOVE.L #1789773,D7 ; NTSC (= round[715909.09090 * (125/50)])
sciask MOVE.L D7,TimerValue
DIVU.W #125,D7 ; Default to normal 50 Hz timer
TryTimerB
LEA MusicIntServer(PC),A1
MOVEQ #1,D0 ; Bit 1: Timer B
JSR _AddICRVector(A6)
MOVE.L #1,TimerFlag
TST.L D0
BNE.B TryTimerA
MOVE.L A5,CIAAaddr
MOVE.B D7,ciatblo(A5)
LSR.W #8,D7
MOVE.B D7,ciatbhi(A5)
BSET #0,ciacrb(A5)
BRA.W SetTempo
TryTimerA
LEA MusicIntServer(PC),A1
MOVEQ #0,D0 ; Bit 0: Timer A
JSR _AddICRVector(A6)
CLR.L TimerFlag
TST.L D0
BNE.B CIAError
MOVE.L A5,CIAAaddr
MOVE.B D7,ciatalo(A5)
LSR.W #8,D7
MOVE.B D7,ciatahi(A5)
BSET #0,ciacra(A5)
BRA.W SetTempo
CIAError
MOVE.B #'a',CIAAname+3
LEA $BFE001,A5
SUBQ.W #1,D6
BNE.W SetCIALoop
CLR.L CIAAbase
RTS
ResetCIAInt
MOVE.L CIAAbase(PC),D0
BEQ.W Return1
CLR.L CIAAbase
MOVE.L D0,A6
MOVE.L CIAAaddr(PC),A5
TST.L TimerFlag
BEQ.B ResTimerA
BCLR #0,ciacrb(A5)
MOVEQ #1,D0
BRA.B RemInt
ResTimerA
BCLR #0,ciacra(A5)
MOVEQ #0,D0
RemInt LEA MusicIntServer(PC),A1
JSR _RemICRVector(A6)
RTS
CNOP 0,4
CIAAbase dc.l 0
TimerFlag dc.l 0
TimerValue dc.l 0
CIAAname dc.b 'ciaa.resource',0
EVEN
;---- Tempo ----
TempoGadg
CMP.W #60,D0
BHS Return1
CMP.W #44,D0
BHS.B TemDown
TemUp MOVE.W RealTempo(PC),D0
ADDQ.W #1,D0
BTST #2,$DFF016 ; right mouse button
BNE.B teupsk
ADDQ.W #8,D0
ADDQ.W #1,D0
teupsk CMP.W #255,D0
BLS.B teposk
MOVE.W #255,D0
teposk MOVE.W D0,RealTempo
BSR SetTempo
JMP Wait_4000
TemDown MOVE.W RealTempo(PC),D0
SUBQ.W #1,D0
BTST #2,$DFF016 ; right mouse button
BNE.B tednsk
SUBQ.W #8,D0
SUBQ.W #1,D0
tednsk CMP.W #32,D0
BHS.B teposk
MOVE.W #32,D0
BRA.B teposk
ChangeTempo
CMP.W #97,D0
BHS.B TempoDown
CMP.W #86,D0
BHS.B TempoUp
RTS
TempoUp MOVE.W Tempo,D0
ADDQ.W #1,D0
BTST #2,$DFF016 ; right mouse button
BNE.B temupsk
ADDQ.W #8,D0
ADDQ.W #1,D0
temupsk CMP.W #255,D0
BLS.B temposk
MOVE.W #255,D0
temposk MOVE.W D0,Tempo
MOVE.W D0,RealTempo
BSR.B ShowTempo
BSR.B SetTempo
JMP Wait_4000
TempoDown
MOVE.W Tempo,D0
SUBQ.W #1,D0
BTST #2,$DFF016 ; right mouse button
BNE.B temdnsk
SUBQ.W #8,D0
SUBQ.W #1,D0
temdnsk CMP.W #32,D0
BHS.B temposk
MOVE.W #32,D0
BRA.B temposk
ShowTempo
MOVE.W #607,TextOffset
MOVE.W RealTempo(PC),WordNumber
JMP Print3DecDigits
SetTempo
MOVEQ #125,D0
MOVE.L CIAAbase(PC),D1
BEQ.B setesk3
MOVE.W RealTempo(PC),D0
CMP.W #32,D0
BHS.B setemsk
MOVEQ #32,D0
setemsk MOVE.W D0,RealTempo
setesk3 TST.W SamScrEnable
BNE.B setesk2
MOVE.W #4964,TextOffset
MOVE.W D0,WordNumber
JSR Print3DecDigits
setesk2 MOVE.L CIAAbase(PC),D0
BEQ.W Return1
MOVE.W RealTempo(PC),D0
MOVE.L TimerValue(PC),D1
DIVU.W D0,D1
MOVE.L CIAAaddr(PC),A5
MOVE.L TimerFlag(PC),D0
BEQ.B SetTemA
MOVE.B D1,ciatblo(A5) ;and set the CIA timer
LSR.W #8,D1
MOVE.B D1,ciatbhi(A5)
RTS
SetTemA MOVE.B D1,ciatalo(A5)
LSR.W #8,D1
MOVE.B D1,ciatahi(A5)
RTS
CNOP 0,4
CIAAaddr dc.l 0
RealTempo dc.w 125
;---- Input Event Handler ----
SetInputHandler
LEA InpEvPort,A0
MOVE.B #4,8(A0)
MOVE.B #0,14(A0)
MOVE.B #$1F,15(A0)
MOVE.L PTProcess(PC),16(A0)
LEA 20(A0),A1
MOVE.L A1,(A1)
ADDQ #4,(A1)
CLR.L 4(A1)
MOVE.L A1,8(A1)
MOVE.L 4.L,A6
LEA InputDevName,A0
MOVEQ #0,D0
LEA InpEvIOReq,A1
MOVEQ #0,D1
MOVE.L #InpEvPort,14(A1)
JSR _LVOOpenDevice(A6)
LEA InpEvIOReq,A1
MOVE.W #9,IO_COMMAND(A1) ; IND_ADDHANDLER
MOVE.L #InpEvStuff,IO_DATA(A1)
JSR _LVODoIO(A6)
RTS
ResetInputHandler
MOVE.L 4.W,A6
LEA InpEvIOReq,A1
MOVE.W #10,IO_COMMAND(A1) ; IND_REMHANDLER
MOVE.L #InpEvStuff,IO_DATA(A1)
JSR _LVODoIO(A6)
LEA InpEvIOReq,A1
JSR _LVOCloseDevice(A6)
RTS
CNOP 0,4
InpEvStuff
dc.l 0,0
dc.b 2,52 ; type, priority
dc.l inpevname
dc.l 0,InputHandler
inpevname
dc.b "ProTracker InputHandler",0
EVEN
InputHandler ; A0-InputEvent, A1-Data Area
MOVEM.L D1/A0-A3,-(SP)
TST.B StopInputFlag
BEQ.B inphend
SUB.L A2,A2
MOVE.L A0,A1
MOVE.B 4(A1),D0 ; ie_Class
CMP.B #1,D0 ; RAWKEY
BEQ.B InpRawkey
CMP.B #2,D0 ; RAWMOUSE
BEQ.W xInpRawMouse
MOVE.L A1,A2
InpNext MOVE.L (A1),A1
MOVE.L A1,D0
BNE.B InputHandler
inphend MOVE.L A0,D0
MOVEM.L (SP)+,D1/A0-A3
RTS
; InpRawmouse is way further down in the source code
xInpRawMouse JMP InpRawmouse
InpRawkey
JSR InpUnchain
MOVE.W 6(A1),D0
BSR.W ProcessRawkey
BRA.B InpNext
;---- Process rawkey code from the keyboard ----
ProcessRawkey
CMP.B LastRawkey(PC),D0
BEQ.W Return1
MOVE.B D0,LastRawkey
; -------------------------
CMP.B #96,D0
BEQ.W ShiftOn
CMP.B #97,D0
BEQ.W ShiftOn2
CMP.B #100,D0
BEQ.W AltOn
CMP.B #101,D0
BEQ.W AltOn2
CMP.B #99,D0
BEQ.W CtrlOn
CMP.B #102,D0
BEQ.W LeftAmigaOn
CMP.B #99+128,D0
BEQ.W CtrlOff
CMP.B #100+128,D0
BEQ.W AltOff
CMP.B #101+128,D0
BEQ.W AltOff
CMP.B #96+128,D0
BEQ.W ShiftOff2
CMP.B #97+128,D0
BEQ.W ShiftOff
CMP.B #102+128,D0
BEQ.W LeftAmigaOff
CMP.B #98,D0
BEQ.W KeyRepOn
CMP.B #98+128,D0
BEQ.W KeyRepOff
MOVE.W 8(A1),D1
AND.W #64,D1
BEQ.B kbintSetKey
CMP.B #54,D0
BEQ.W WorkbenchToFront
CMP.B #55,D0
BEQ.W PTScreenToBack
kbintSetKey
TST.B D0
BNE.B kbintDoSet
MOVE.B #127,LastRawkey
BRA.W PTScreenToBack
kbintDoSet
MOVE.W KeyBufPos(PC),D1
CMP.W #KeyBufSize,D1
BHS.W Return1
LEA KeyBuffer(PC),A3
MOVE.B D0,(A3,D1.W)
ADDQ.W #1,KeyBufPos
RTS
ShiftOff2
CLR.W ShiftKeyStatus
BRA.W kbintSetKey
KeyRepOn
ST KeyRepeat
RTS
KeyRepOff
SF KeyRepeat
RTS
ShiftOn2
MOVE.W #1,ShiftKeyStatus
BRA.W kbintSetKey
ShiftOff
CLR.W ShiftKeyStatus
RTS
AltOn
MOVE.W #1,AltKeyStatus
RTS
AltOn2
MOVE.W #1,AltKeyStatus
BRA.W kbintSetKey
AltOff
CLR.W AltKeyStatus
RTS
CtrlOn
MOVE.W #1,CtrlKeyStatus
RTS
CtrlOff
CLR.W CtrlKeyStatus
RTS
LeftAmigaOn
MOVE.W #1,LeftAmigaStatus
RTS
LeftAmigaOff
CLR.W LeftAmigaStatus
RTS
DoKeyBuffer
MOVE.W KeyBufPos(PC),D0
BEQ.W Return1
SUBQ.W #1,D0
LEA KeyBuffer(PC),A0
MOVE.B (A0,D0.W),D1
MOVE.W D0,KeyBufPos
MOVE.B D1,RawKeyCode
MOVE.B D1,SaveKey
MOVE.W KeyRepDelay,KeyRepCounter
BTST #7,D1
BEQ.B dkbend
CLR.W KeyRepCounter
dkbend RTS
KeyBufPos dc.w 0
ShiftKeyStatus dc.w 0
AltKeyStatus dc.w 0
CtrlKeyStatus dc.w 0
LeftAmigaStatus dc.w 0
KeyRepCounter dc.w 0
KeyBuffer dcb.b KeyBufSize,0
KeyRepeat dc.b 0
LastRawkey dc.b 255,0
SaveKey dc.b 0
EVEN
;---- Key repeat ----
CheckKeyRepeat
TST.B KeyRepeat
BEQ.W Return1
MOVE.W KeyRepCounter(PC),D0
BEQ.W Return1
SUBQ.W #1,D0
BEQ.B RepDown
MOVE.W D0,KeyRepCounter
RTS
RepDown
MOVE.B SaveKey(PC),RawKeyCode
MOVE.W KeyRepSpeed,KeyRepCounter
MOVE.L 4.W,A6
MOVE.L PTProcess(PC),A1
MOVE.L #$20000000,D0
JSR _LVOSignal(A6)
RTS
;---- Song Playback Counter ----
; 8bitbubsy: less code overhead and improved tick accuracy (less drifting)
; ------------ PAL Amiga video -------------
; Horizontal clock: 15625.088105727Hz (3546895.0 / 227.0)
; Lines: 313
; Frame rate = 49.9204092835Hz (HorizontalClock / Lines)
PDELTA_PAL EQU 86036300 ; round[2^32 / FrameRate]
; ------------------------------------------
; ------------ NTSC Amiga video ------------
; Horizontal clock: 15734.265734266Hz (3579545.4545454 (recurring) / 227.5)
; Lines: 263
; Frame rate = 59.8261054535Hz (HorizontalClock / Lines)
PDELTA_NTSC EQU 71790856 ; round[2^32 / FrameRate]
; ------------------------------------------
; --- PAL-on-NTSC Amiga video (ECS/AGA) ----
; Horizontal clock: 15768.922707249Hz (3579545.4545454 (recurring) / 227.0)
; Lines: 313
; Frame rate = 50.3799447516Hz (HorizontalClock / Lines)
PDELTA_PAL_ON_NTSC EQU 85251529 ; round[2^32 / FrameRate]
; ------------------------------------------
DrawPlaybackCounter
MOVE.L PlaybackSecs(PC),D0
BRA.B DoDrawPlaybackCounter
DPCEnd RTS
TickPlaybackCounter
CMP.L #'patp',RunMode ; normal song playback mode?
BNE.B DPCEnd ; nope, don't tick counter
MOVE.L PlaybackSecsDelta(PC),D1
ADD.L D1,PlaybackSecsFrac
BCC.B DPCEnd
MOVE.L PlaybackSecs(PC),D0
ADDQ.L #1,D0
MOVE.L D0,PlaybackSecs
; -- fall-through --
DoDrawPlaybackCounter
CMP.W #4,CurrScreen ; pset-ed screen shown?
BEQ.W DDPCEnd ; yep, counter is hidden (no draw)
; ---------------------
MOVEQ #0,D1
MOVE.W #(99*60)+59,D1 ; 99:59 (limit)
CMP.L D1,D0
BLS.B .OK
MOVE.L D1,D0
.OK DIVU.W #60,D0
; ---------------------
LEA FontData,A4
LEA FastTwoDecTable,A3
MOVEQ #0,D1
; ---------------------
ADD.W D0,D0 ; D0.W = minutes (*2 for LUT)
MOVE.B 0(A3,D0.W),D1
LEA (A4,D1.W),A0
MOVE.B 1(A3,D0.W),D1
LEA (A4,D1.W),A1
; ---------------------
SWAP D0
ADD.W D0,D0 ; D0.W = seconds (*2 for LUT)
MOVE.B 0(A3,D0.W),D1
LEA (A4,D1.W),A2
MOVE.B 1(A3,D0.W),D1
LEA (A4,D1.W),A3
; ---------------------
LEA TextBitplane+4154,A4
; ---------------------
MOVE.B (A0)+,(A4)+ ; draw minutes
MOVE.B (A0)+,40-1(A4)
MOVE.B (A0)+,80-1(A4)
MOVE.B (A0)+,120-1(A4)
MOVE.B (A0),160-1(A4)
MOVE.B (A1)+,(A4)+
MOVE.B (A1)+,40-1(A4)
MOVE.B (A1)+,80-1(A4)
MOVE.B (A1)+,120-1(A4)
MOVE.B (A1),160-1(A4)
; ---------------------
ADDQ #1,A4 ; draw seconds
MOVE.B (A2)+,(A4)+
MOVE.B (A2)+,40-1(A4)
MOVE.B (A2)+,80-1(A4)
MOVE.B (A2)+,120-1(A4)
MOVE.B (A2),160-1(A4)
MOVE.B (A3)+,(A4)+
MOVE.B (A3)+,40-1(A4)
MOVE.B (A3)+,80-1(A4)
MOVE.B (A3)+,120-1(A4)
MOVE.B (A3),160-1(A4)
DDPCEnd RTS
CNOP 0,4
PlaybackSecsFrac dc.l 0
PlaybackSecsDelta dc.l 0
PlaybackSecs dc.l 0
;---- Spectrum Analyzer ----
SpecAnaInt
CMP.W #1,CurrScreen
BNE.W Return1
TST.B DisableAnalyzer
BNE.W Return1
TST.B AnaDrawFlag
BNE.W Return1
ST AnaDrawFlag
MOVEQ #40,D5
MOVEQ #126,D6
LEA AnalyzerHeights,A0
LEA AnalyzerOpplegg,A1
LEA AnalyzerOffsets(PC),A2
LEA TextBitplane+1976,A3
MOVEQ #23-1,D7
spanlab1
MOVE.W (A0)+,D0
CMP.W #36,D0
BLO.B spanskip2
MOVE.W #36,D0
spanskip2
MOVE.W (A1)+,D1
CMP.W D0,D1
BEQ.B spanskip3
BLO.B span_r2
SUB.W D0,D1
SUBQ.W #1,D1
ADD.W D0,D0
MOVE.W (A2,D0.W),D0
spanloop
CLR.B (A3,D0.W)
SUB.W D5,D0
DBRA D1,spanloop
BRA.B spanskip3
span_r2 SUB.W D1,D0
SUBQ.W #1,D0
ADD.W D1,D1
MOVE.W (A2,D1.W),D1
spanloop2
MOVE.B D6,(A3,D1.W)
SUB.W D5,D1
DBRA D0,spanloop2
spanskip3
ADDQ #1,A3
DBRA D7,spanlab1
LEA AnalyzerHeights,A0
LEA AnalyzerOpplegg,A1
MOVEQ #23-1,D7
spanloop3
MOVE.W (A0),D0
MOVE.W D0,(A1)+
BEQ.B spanskip4
SUBQ.W #1,D0
spanskip4
MOVE.W D0,(A0)+
DBRA D7,spanloop3
SF AnaDrawFlag
RTS
ClearAnaHeights
LEA AnalyzerOpplegg,A0
LEA AnalyzerHeights,A1
MOVEQ #23-1,D7
MOVEQ #0,D0
cahloop MOVE.W D0,(A0)+
MOVE.W D0,(A1)+
DBRA D7,cahloop
RTS
PlayNoteAnalyze ; called by keyboard play (bugfixed in PT2.3F)
MOVEM.L D0-D4/A0,-(SP)
MOVEQ #0,D2
MOVE.B 3(A6),D2
BRA.B SpecAna2
; for (i = 0 to 64) x = round[i * (24/64)]
SpecAnaVolLUT
dc.b 0, 0, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 5, 5, 5, 6
dc.b 6, 6, 7, 7, 8, 8, 8, 9, 9, 9,10,10,11,11,11,12
dc.b 12,12,13,13,14,14,14,15,15,15,16,16,17,17,17,18
dc.b 18,18,19,19,20,20,20,21,21,21,22,22,23,23,23,24
dc.b 24
EVEN
SpectrumAnalyzer ; called by playroutine (bugfixed in PT2.3F)
TST.B n_muted(A6) ; channel muted?
BNE.W Return1 ; yes, don't do
MOVEM.L D0-D4/A0,-(SP)
;MOVEQ #0,D2
MOVE.B n_volume(A6),D2 ; Get channel volume
SpecAna2
TST.B AnaDrawFlag
BNE.W ohno
ST AnaDrawFlag
; --------------------
; Volume
; --------------------
TST.B D2 ; volume zero?
BEQ.B saend ; yes, don't do
CMP.B #64,D2 ; volume above 64?
BHI.B saend ; yes, don't do
EXT.W D2
MOVE.B (SpecAnaVolLUT,PC,D2.W),D2 ; D2.W = 0..24
MOVE.W D2,D3
LSR.B #1,D3
; --------------------
; Period (fixed for C-1 finetune < 0 and B-3 finetune > 0)
; --------------------
CMP.W #108,D0 ; period below 108 (B-3 finetune +7)?
BLO.B saend ; yes, don't do
CMP.W #907,D0 ; period above 907 (C-1 finetune -8)?
BHI.B saend ; yes, don't do
; --------------------
MOVE.W #856,D4
CMP.W D4,D0 ; lo-clamp to C-3 finetune 0
BLS.B .L0
MOVE.W D4,D0
.L0 MOVEQ #113,D4
CMP.W D4,D0 ; hi-clamp to B-3 finetune 0
BHS.B .L1
MOVE.W D4,D0
.L1 ; --------------------
SUB.W D4,D0 ; Subtract 113 (highest rate)
MOVE.W #743,D1
SUB.W D0,D1 ; Invert range 0-743
MULU.W D1,D1 ; 0 - 743^2
DIVU.W #25093,D1 ; 0 - 743^2 -> 0..22 (25093 = round[743^2 / 22])
MOVE.W D1,D0
; --------------------
; --------------------
MOVEQ #36,D1
LEA AnalyzerHeights+1,A0
ADD.W D0,D0
ADD.W D0,A0
; --------------------
MOVE.B (A0),D4 ; cache it (for safety)
ADD.B D2,D4
CMP.B D1,D4
BLO.B saskip2
MOVE.B D1,D4
saskip2 MOVE.B D4,(A0)
SUBQ.W #2,A0 ; A0 = -2(A0)
; --------------------
TST.B D0
BEQ.B saskip4
MOVE.B (A0),D4 ; cache it (for safety)
ADD.B D3,D4
CMP.B D1,D4
BLO.B saskip3
MOVE.B D1,D4
saskip3 MOVE.B D4,(A0)
saskip4 ADDQ.W #4,A0 ; A0 = 2(A0)
; --------------------
CMP.B #22*2,D0
BEQ.B saend
MOVE.B (A0),D4 ; cache it (for safety)
ADD.B D3,D4
CMP.B D1,D4
BLO.B saskip5
MOVE.B D1,D4
saskip5 MOVE.B D4,(A0)
; --------------------
saend SF AnaDrawFlag
ohno MOVEM.L (SP)+,D0-D4/A0
RTS
AnalyzerOffsets
dc.w $0730,$0708,$06E0,$06B8,$0690,$0668,$0640,$0618
dc.w $05F0,$05C8,$05A0,$0578,$0550,$0528,$0500,$04D8
dc.w $04B0,$0488,$0460,$0438,$0410,$03E8,$03C0,$0398
dc.w $0370,$0348,$0320,$02F8,$02D0,$02A8,$0280,$0258
dc.w $0230,$0208,$01E0,$01B8,$0190,$0168,$0140,$0118
dc.w $00F0
AnaDrawFlag dc.b 0
EVEN
;---- Scope (normal type) ----
ns_sampleptr = 0 ; L
ns_endptr = 4 ; L
ns_repeatptr = 8 ; L
ns_rependptr = 12 ; L
ns_period = 16 ; W
ns_volume = 18 ; B
ns_oneshotflag = 19 ; B
ns_posfrac = 20 ; W
ScopeInfoSize = 24 ; should be a multiple of 4!
Scope
LEA audchan1temp,A0
LEA ScopeSamInfo,A1
LEA ScopeInfo,A2
LEA BlankSample,A3
MOVEQ #4-1,D6 ; do 4 channels
ScoLoop
MOVE.W n_period(A0),D0
BEQ.W ScoSampleEnd ; end if no period
MOVE.W n_periodout(A0),ns_period(A2)
MOVE.B n_volumeout(A0),ns_volume(A2)
TST.B n_trigger(A0)
BEQ.B ScoContinue
ScoRetrig
SF n_trigger(A0)
TST.B n_samplenum(A0)
BEQ.W ScoNextChan
SF ns_oneshotflag(A2)
CLR.W ns_posfrac(A2)
BSR.W SetScope
MOVEQ #0,D0
MOVE.B n_samplenum(A0),D0
SUBQ.W #1,D0
LSL.W #4,D0
MOVE.L ns_sampleptr(A1,D0.W),ns_sampleptr(A2)
MOVE.L ns_endptr(A1,D0.W),ns_endptr(A2)
MOVE.L ns_repeatptr(A1,D0.W),ns_repeatptr(A2)
MOVE.L ns_rependptr(A1,D0.W),ns_rependptr(A2)
MOVE.L ns_sampleptr(A2),D0
CMP.L A3,D0 ; at end of sample...
BEQ.W ScoNextChan
BRA.B ScoChk
ScoContinue
MOVE.L ns_sampleptr(A2),D0
CMP.L A3,D0 ; at end of sample...
BEQ.B ScoNextChan
MOVE.W ns_period(A2),D1
BEQ.B ScoNextChan
; PT2.3F: better scope pitch/delta precision
FRAC_BITS EQU 6 ; max bits for period 113 w/ DIVU.W
CMP.W #113,D1 ; min. Paula period in normal video modes
BHS.B ScoOk ; (clamp also needed for DIVU.W)
MOVEQ #113,D1
ScoOk MOVE.L #71051*(1<<FRAC_BITS),D2 ; PaulaClk / VBlankHz = 71051.0 (exact)
DIVU.W D1,D2
MOVEQ #0,D1
MOVE.W D2,D1
ROR.L #FRAC_BITS,D1
SWAP D1 ; D1.L is now laid out as 16.16fp
ADD.W D1,ns_posfrac(A2) ; add delta fraction
CLR.W D1
SWAP D1
ADDX.L D1,D0 ; add integer + fraction overflow bit
ScoChk CMP.L ns_endptr(A2),D0
BLO.B ScoUpdatePtr
TST.L ns_repeatptr(A2)
BNE.B ScoHandleLoop
ScoSampleEnd
MOVE.L A3,D0
BRA.B ScoUpdatePtr
ScoHandleLoop
MOVE.L ns_endptr(A2),D1
SUB.L ns_repeatptr(A2),D1 ; D1.L = loop length
CMP.L #256,D1 ; loopLength < 256 = use MOD (DIV) instead
BHS.B ScoNoDivLoop
DIVU.W D1,D0 ; 140 cycles
CLR.W D0
SWAP D0
ADD.L ns_repeatptr(A2),D0
MOVE.L ns_rependptr(A2),ns_endptr(A2)
BRA.B ScoLoopDone
; --------------------------------
ScoNoDivLoop
SUB.L ns_endptr(A2),D0
ADD.L ns_repeatptr(A2),D0
MOVE.L ns_rependptr(A2),ns_endptr(A2)
CMP.L ns_endptr(A2),D0
BHS.B ScoNoDivLoop
; ^^
; 90-92 cycles per iteration
; --------------------------------
ScoLoopDone
SF ns_oneshotflag(A2)
ScoUpdatePtr
MOVE.L D0,ns_sampleptr(A2)
ScoNextChan
LEA ScopeInfoSize(A2),A2
LEA ChanStructSize(A0),A0
DBRA D6,ScoLoop
; now draw channels
TST.B ScopeEnable
BEQ.B clsnot
CMP.W #1,CurrScreen
BNE.B clsnot
TST.B EdEnable
BNE.B clsnot
; clear scopes (slightly optimized in PT2.3F)
LEA TextBitplane+2256,A0
MOVEQ #(33/3)-1,D0
MOVEQ #0,D1
MOVEQ #0,D2
MOVEQ #0,D3
MOVEQ #0,D4
MOVEQ #0,D5
MOVEQ #0,D6
clscop MOVEM.L D1-D6,(A0)
LEA 40(A0),A0
MOVEM.L D1-D6,(A0)
LEA 40(A0),A0
MOVEM.L D1-D6,(A0)
LEA 40(A0),A0
DBRA D0,clscop
clsnot MOVEQ #-1,D4
TST.W SamScrEnable
BEQ.B ScoNClr
MOVEQ #0,D4
ScoNClr MOVEQ #0,D7
MOVE.W $DFF002,D6 ; dmaconr
MOVEQ #0,D5
LEA TextBitplane+(72*40+16),A1
LEA xBlankSample,A2
LEA audchan1toggle(PC),A4
TST.B TToneCh1Flag
BNE.B ScoSkp1
TST.W (A4)
BEQ.B ScoSkp1
BTST #0,D6 ; voice #1 active?
BEQ.B ScoSkp1
LEA ScopeInfo+(ScopeInfoSize*0),A2
MOVE.B ns_volume(A2),D5
ScoSkp1 BSR.W ScoDraw
MOVEQ #0,D5
LEA TextBitplane+(72*40+22),A1
LEA xBlankSample,A2
LEA audchan2toggle(PC),A4
TST.B TToneCh2Flag
BNE.B ScoSkp2
TST.W (A4)
BEQ.B ScoSkp2
BTST #1,D6 ; voice #2 active?
BEQ.B ScoSkp2
LEA ScopeInfo+(ScopeInfoSize*1),A2
MOVE.B ns_volume(A2),D5
ScoSkp2 BSR.B ScoDraw
MOVEQ #0,D5
LEA TextBitplane+(72*40+28),A1
LEA xBlankSample,A2
LEA audchan3toggle(PC),A4
TST.B TToneCh3Flag
BNE.B ScoSkp3
TST.W (A4)
BEQ.B ScoSkp3
BTST #2,D6 ; voice #3 active?
BEQ.B ScoSkp3
LEA ScopeInfo+(ScopeInfoSize*2),A2
MOVE.B ns_volume(A2),D5
ScoSkp3 BSR.B ScoDraw
MOVEQ #0,D5
LEA TextBitplane+(72*40+34),A1
LEA xBlankSample,A2
LEA audchan4toggle(PC),A4
TST.B TToneCh4Flag
BNE.B ScoSkp4
TST.W (A4)
BEQ.B ScoSkp4
BTST #3,D6 ; voice #4 active?
BEQ.B ScoSkp4
LEA ScopeInfo+(ScopeInfoSize*3),A2
MOVE.B ns_volume(A2),D5
ScoSkp4 BSR.B ScoDraw
TST.L D7
BEQ.W sdloscr
ScoRTS RTS
; --- Scope drawing ---
ScoDraw
TST.B RealVUMetersFlag
BNE.W rScoDraw ; go to different scope drawing routine
TST.B ScopeEnable
BEQ.W sdlpos
CMP.W #1,CurrScreen
BNE.W sdlpos
TST.B EdEnable
BNE.W sdlpos
CMP.B #64,D5
BLS.B sdsk1
MOVEQ #64,D5
sdsk1 EXT.W D5
LSL.W #8,D5
ADD.W D5,D5 ; D5.W = 0..32768
NEG.W D5 ; D5.W = -0..32768
MOVE.L ns_sampleptr(A2),A0
MOVEQ #5-1,D2
LEA (64*2)+scopeYTab(PC),A5
; --PT2.3D bug fix: scope loop fix
MOVE.L ns_endptr(A2),A4 ; sample end
TST.L ns_repeatptr(A2) ; loop enabled?
BEQ.B sdlp1 ; no, let's use the old scope routine
TST.B ns_oneshotflag(A2) ; oneshot cycle?
BNE.B sdlp1 ; yes, let's use the original scope routine first
; ---- new scope routine for looped samples ----
MOVE.L ns_rependptr(A2),A4 ; sample loop end
MOVE.L ns_repeatptr(A2),A3 ; sample loop start
sdlp1LOOP
MOVEQ #8-1,D3 ; we do 8 pixels per bitplane byte
sdlp2LOOP
CMP.L A4,A0 ; did we reach sample loop end yet?
BHS.B sWrapLoop ; yes, wrap loop
sdlnowrap
MOVE.B (A0)+,D0 ; get byte from sample data
EXT.W D0 ; extend to word
MULS.W D5,D0 ; multiply by volume
SWAP D0 ; D0.W = -63..64
ADD.W D0,D0
MOVE.W (A5,D0.W),D0
BSET D3,(A1,D0.W) ; set the current bitplane bit
DBRA D3,sdlp2LOOP
ADDQ #1,A1 ; we have done 8 bits now, increase bitplane ptr
DBRA D2,sdlp1LOOP
BRA.B sdlpos
sWrapLoop
MOVE.L A3,A0 ; set read address to sample loop start
BRA.B sdlnowrap
; --END OF FIX--------------------
; ---- old scope routine for non-looping samples (or oneshot-cycle) ----
sdlp1
MOVEQ #8-1,D3 ; we do 8 pixels per bitplane byte
sdlp2
MOVEQ #0,D0
CMP.L A4,A0 ; did we reach sample end yet?
BHS.B .drawit ; yes, draw empty sample
; -----------------------------
MOVE.B (A0)+,D0 ; get byte from sample data
EXT.W D0 ; extend to word
MULS.W D5,D0 ; multiply by volume
SWAP D0 ; D0.W = -63..64
ADD.W D0,D0
MOVE.W (A5,D0.W),D0
.drawit BSET D3,(A1,D0.W) ; set the current bitplane bit
DBRA D3,sdlp2
ADDQ #1,A1 ; we have done 8 bits now, increase bitplane ptr
DBRA D2,sdlp1
; ----------------------------------------------------
sdlpos ; process sample play position (the blue line)
TST.B D4
BNE.W ScoRTS
TST.B VolToolBoxShown ; -PT2.3D bug fix: hide sample playline if volbox is open
BNE.B sdloscr ; ---
LEA xBlankSample(PC),A0
CMP.L A0,A2
BEQ.B sdloscr
MOVE.L ns_sampleptr(A2),D1
MOVE.L SamDrawStart(PC),D0
CMP.L D0,D1
BLS.W ScoRTS
CMP.L SamDrawEnd(PC),D1
BHS.W ScoRTS
SUB.L D0,D1
; dirty fix for new scopes on non-looping samples
CMP.L #2,D1
BLT.B sdloscr
MOVE.L #314,D0
JSR MULU32
MOVE.L SamDisplay,D1
BEQ.W ScoRTS
JSR DIVU32
ST D4
ST D7
ADDQ.W #6,D0
MOVE.W #139,D1
sdlpspr MOVEQ #64,D2
LEA PlayPosSpriteData,A0
JMP SetSpritePos
sdloscr MOVEQ #0,D0
MOVE.W #270,D1
BRA.B sdlpspr
SetScope
MOVEQ #0,D1
MOVE.B n_samplenum(A0),D1
SUBQ.B #1,D1
LSL.W #4,D1
LEA ScopeSamInfo,A4
ADD.W D1,A4
; -- PT2.3D bug fix: show 9xx properly on scopes ( doesn't include 9xx quirks :-( )
TST.L RunMode
BEQ.B ss9Done
MOVE.B n_cmd(A0),D0
AND.B #$0F,D0
CMP.B #$09,D0
BNE.B ss9Done
MOVE.B n_cmdlo(A0),D0
BEQ.B ss9Skip1
MOVE.B D0,n_sampleoffset2(A0)
ss9Skip1
MOVEQ #0,D0
MOVE.B n_sampleoffset2(A0),D0
LSL.W #7,D0
CMP.W n_oldlength(A0),D0
BHS.B ss9Skip2
SUB.W D0,n_oldlength(A0)
ADD.W D0,D0
ADD.L D0,n_oldstart(A0)
BRA.B ss9Done
ss9Skip2
MOVE.W #$0001,n_oldlength(A0)
ss9Done
; -----------------------------------------------------------------------------
MOVE.L n_oldstart(A0),D0
MOVE.L D0,ns_sampleptr(A4)
MOVEQ #0,D1
MOVE.W n_oldlength(A0),D1
ADD.L D1,D0
ADD.L D1,D0
MOVE.L D0,ns_endptr(A4)
; check for loop
MOVE.W n_repeat(A0),D1
ADD.W n_replen(A0),D1
CMP.W #1,D1 ; (n_repeat+n_replen) > 1? (loop enabled)
BLS.B sconorep ; nope, no loop...
; set loop pointers
MOVE.W n_replen(A0),D1
MOVE.L n_loopstart(A0),D0
MOVE.L D0,ns_repeatptr(A4)
ADD.L D1,D0
ADD.L D1,D0
MOVE.L D0,ns_rependptr(A4)
; 8bitbubsy:
; Fix for one-shot loops (where n_repeat=0 and n_replen < n_length)
; This is needed with our new scopes which wraps around loop points internally
MOVE.W n_repeat(A0),D0
BNE.B .skip ; n_repeat != 0
MOVE.L ns_endptr(A4),D0
CMP.L ns_rependptr(A4),D0 ; ns_rependptr != ns_endptr? (loopend < samplelen)
BEQ.B .skip ; nope, they are equal
ST ns_oneshotflag(A2) ; yes, activate oneshot flag for one loop cycle
.skip RTS
sconorep
CLR.L ns_repeatptr(A4)
RTS
scopeYTab
dc.w -640,-640,-640,-640,-600,-600,-600,-600,-560,-560,-560,-560,-520,-520,-520,-520
dc.w -480,-480,-480,-480,-440,-440,-440,-440,-400,-400,-400,-400,-360,-360,-360,-360
dc.w -320,-320,-320,-320,-280,-280,-280,-280,-240,-240,-240,-240,-200,-200,-200,-200
dc.w -160,-160,-160,-160,-120,-120,-120,-120, -80, -80, -80, -80, -40, -40, -40, -40
dc.w 0, 0, 0, 0, 40, 40, 40, 40, 80, 80, 80, 80, 120, 120, 120, 120
dc.w 160, 160, 160, 160, 200, 200, 200, 200, 240, 240, 240, 240, 280, 280, 280, 280
dc.w 320, 320, 320, 320, 360, 360, 360, 360, 400, 400, 400, 400, 440, 440, 440, 440
dc.w 480, 480, 480, 480, 520, 520, 520, 520, 560, 560, 560, 560, 600, 600, 600, 600
dc.w 640
; --- Scopes drawing in real VU-Meters mode (fetch peak) ---
rScoDraw
MOVE.L D7,-(SP)
MOVE.L D4,-(SP)
SF D7 ; do not draw scopes
TST.B ScopeEnable
BEQ.W rsdkip
CMP.W #1,CurrScreen
BNE.W rsdkip
TST.B EdEnable
BNE.W rsdkip
ST D7 ; do draw scopes
rsdkip CMP.B #64,D5
BLS.B rsdsk1
MOVEQ #64,D5
rsdsk1 EXT.W D5
LSL.W #8,D5
ADD.W D5,D5 ; D5.W = 0..32768
NEG.W D5 ; D5.W = -0..32768
MOVE.L ns_sampleptr(A2),A0
MOVEQ #5-1,D2
ADDQ #6,A4
LEA (64*2)+scopeYTab(PC),A5
; --PT2.3D bug fix: scope loop fix
MOVE.L ns_endptr(A2),D4
TST.L ns_repeatptr(A2) ; loop enabled?
BEQ.B rsdlp1 ; no, let's use the old scope routine
TST.B ns_oneshotflag(A2) ; oneshot cycle?
BNE.B rsdlp1 ; yes, let's use the original scope routine first
; ---- new scope routine for looped samples ----
MOVE.L ns_rependptr(A2),D4 ; sample loop end
MOVE.L ns_repeatptr(A2),A3 ; sample loop start
rsdlp1LOOP
MOVEQ #8-1,D3 ; we do 8 pixels per bitplane byte
rsdlp2LOOP
CMP.L D4,A0 ; did we reach sample loop end yet?
BHS.B rWrapLoop ; yes, wrap loop
rsdlnowrap
MOVE.B (A0)+,D0 ; get byte from sample data
EXT.W D0 ; extend to word
MULS.W D5,D0 ; multiply by volume
SWAP D0 ; D0.W = -63..64
MOVE.W D0,D1 ; D1 = amplitude
BPL.B rnotSigned ; D1 >= 0?
NEG.W D1 ; no, D1 = ABS(D1)
rnotSigned
CMP.W (A4),D1 ; D1 < amp?
BLS.B rnoNewStore ; yes, don't update
MOVE.W D1,(A4) ; store current amp for use in real VU-Meter mode
rnoNewStore
TST.B D7 ; draw scopes or not?
BEQ.B rsdlskip ; nope...
ADD.W D0,D0
MOVE.W (A5,D0.W),D0
BSET D3,(A1,D0.W) ; set the current bitplane bit
rsdlskip
DBRA D3,rsdlp2LOOP
ADDQ #1,A1 ; we have done 8 bits now, increase bitplane ptr
DBRA D2,rsdlp1LOOP
MOVE.L (SP)+,D4
MOVE.L (SP)+,D7
SUBQ #6,A4
BRA.W sdlpos
rWrapLoop
MOVE.L A3,A0 ; set read address to sample loop start
BRA.B rsdlnowrap
; --END OF FIX--------------------
; ---- old scope routine for non-looping samples ----
rsdlp1
MOVEQ #8-1,D3 ; we do 8 pixels per bitplane byte
rsdlp2
MOVEQ #0,D0
CMP.L D4,A0 ; did we reach sample end yet?
BHS.B rnoNewStore2 ; yes, draw empty sample
MOVE.B (A0)+,D0 ; get byte from sample data
EXT.W D0 ; extend to word
MULS.W D5,D0 ; multiply by volume
SWAP D0 ; D0.W = -63..64
MOVE.W D0,D1 ; D1 = amplitude
BPL.B rnotSigned2 ; D1 >= 0?
NEG.W D1 ; no, D1 = ABS(D1)
rnotSigned2
CMP.W (A4),D1 ; D1 < amp?
BLS.B rnoupdate ; yes, don't update
MOVE.W D1,(A4) ; store current value for use in real VU-Meter mode
rnoupdate
ADD.W D0,D0
MOVE.W (A5,D0.W),D0
rnoNewStore2
TST.B D7 ; draw scopes or not?
BEQ.B rsdlskip2 ; nope...
BSET D3,(A1,D0.W) ; set the current bitplane bit
rsdlskip2
DBRA D3,rsdlp2
ADDQ #1,A1 ; we have done 8 bits now, increase bitplane ptr
DBRA D2,rsdlp1
MOVE.L (SP)+,D4
MOVE.L (SP)+,D7
SUBQ #6,A4
BRA.W sdlpos
ToggleAnaScope
BSR.W WaitForButtonUp
TST.B AboutScreenShown
BNE.B HideAboutScreen
MOVE.W MouseX2,D0
MOVE.W MouseY2,D1
CMP.W #55,D1
BHI.B tasny
CMP.W #305,D0
BHI.B ShowAboutScreen
tasny MOVEQ #0,D4
TST.B AnaScopFlag
BNE.B tasana
ST AnaScopFlag
BRA.W RedrawAnaScope
tasana SF AnaScopFlag
BRA.W RedrawAnaScope
HideAboutScreen
MOVEQ #0,D4
MOVE.B SaveScope,ScopeEnable
MOVE.B SaveDA,DisableAnalyzer
SF AboutScreenShown
BRA.W RedrawAnaScope
CNOP 0,4
xBlankSample dc.l BlankSample
SamDrawStart dc.l 0
SamDrawEnd dc.l 0
DisableScopeMuting dc.b 0
ScopeEnable dc.b 0
AnaScopFlag dc.b 1
EVEN
ShowAboutScreen
MOVE.B ScopeEnable(PC),SaveScope
MOVE.B DisableAnalyzer,SaveDA
SF ScopeEnable
ST DisableAnalyzer
ST AboutScreenShown
BSR.W ClearAnalyzerColors
BSR.W ClearRightArea
MOVEQ #1,D4
LEA AboutBoxData,A0
MOVE.L #AboutBoxSize,D0
BSR.W cgjojo ; decompact
RTS
;---- Show Free/Tune Memory ----
DoShowFreeMem
ST UpdateFreeMem
ShowFreeMem
MOVEM.L D0-D7/A0-A6,-(SP)
TST.B UpdateFreeMem
BEQ.B sfmskp
SF UpdateFreeMem
CLR.L FreeMemory
CLR.L TuneMemory
sfmskp BSR.B ShowTuneMem
MOVEQ #MEMF_CHIP,D1
TST.B ShowPublicFlag
BEQ.B sfmskp2
MOVEQ #MEMF_PUBLIC,D1
sfmskp2 MOVE.L 4.W,A6
JSR _LVOAvailMem(A6)
CMP.L FreeMemory(PC),D0
BEQ.B fremend
MOVE.L D0,FreeMemory
TST.B ShowDecFlag
BNE.B shfrdec
CMP.L #$00FFFFFF,D0
BLS.B sfmskp3
MOVE.L #$00FFFFFF,D0
sfmskp3
MOVE.L D0,D6
MOVE.W #5273,TextOffset
SWAP D0
AND.W #$FF,D0
MOVE.W D0,WordNumber
JSR PrintHexByte
MOVE.W D6,WordNumber
JSR PrintHexWord
fremend MOVEM.L (SP)+,D0-D7/A0-A6
RTS
shfrdec MOVE.L FreeMemory(PC),D0
MOVE.W #5273,TextOffset
JSR Print6DecDigits
BRA.B fremend
ShowTuneMem
MOVE.L SongDataPtr,A0
LEA 42(A0),A0
MOVE.W TuneUp(PC),D7
SUBQ.W #1,D7
MOVE.W #31,TuneUp
MOVEQ #0,D0 ; Zero length
stumeloop MOVEQ #0,D1
MOVE.W (A0),D1
ADD.L D1,D1
ADD.L D1,D0 ; Add samplelength
LEA 30(A0),A0
DBRA D7,stumeloop
ADD.L #1084,D0 ; Add 1084 to length
MOVE.L SongDataPtr,A0
MOVEQ #128-1,D7
LEA 952(A0),A0
MOVEQ #0,D6
stumeloop2
MOVE.B (A0)+,D5
CMP.B D5,D6
BHI.B stumeskip
MOVE.B D5,D6
stumeskip
DBRA D7,stumeloop2
ADDQ.W #1,D6
MOVE.W D6,NumPatterns
LSL.L #8,D6
LSL.L #2,D6
ADD.L D6,D0 ; Add 1024 x Number of patterns
CMP.L TuneMemory(PC),D0
BEQ.W Return1
MOVE.L D0,TuneMemory
TST.B ShowDecFlag
BNE.B shtudec
MOVE.L D0,D6
MOVE.W #4993,TextOffset
SWAP D0
AND.W #$FF,D0
MOVE.W D0,WordNumber
JSR PrintHexByte
MOVE.W D6,WordNumber
JMP PrintHexWord
shtudec MOVE.L TuneMemory(PC),D0
MOVE.W #4993,TextOffset
JMP Print6DecDigits
CNOP 0,4
FreeMemory dc.l 0
TuneMemory dc.l 0
TuneUp dc.w 31
UpdateFreeMem dc.b 0
EVEN
;---- Audio Channel Toggles ----
CheckToggle ; this routine is now officially spaghettios in PT2.3E
MOVE.W MouseY2,D0
CMP.W #1,CurrScreen
BNE.W Return1
CMP.W #44,D0
BHS.W Return1
MOVEQ #1,D6
BTST #2,$DFF016 ; right mouse button
BNE.B DoToggleMute
CLR.W $DFF0A8
CLR.W $DFF0B8
CLR.W $DFF0C8
CLR.W $DFF0D8
ST n_muted+audchan1temp
ST n_muted+audchan2temp
ST n_muted+audchan3temp
ST n_muted+audchan4temp
CLR.W audchan1toggle
CLR.W audchan2toggle
CLR.W audchan3toggle
CLR.W audchan4toggle
DoToggleMute
CMP.W #34,D0
BHS.W ToggleCh4
CMP.W #23,D0
BHS.B ToggleCh3
CMP.W #12,D0
BHS.B ToggleCh2
ToggleCh1
LEA audchan1toggle(PC),A0
TST.W (A0)
BEQ.B RestoreCh1
CLR.W $DFF0A8
ST n_muted+audchan1temp
BRA.W TogCh
RestoreCh1
SF n_muted+audchan1temp
BSR.W SetBackCh1Vol
BRA.B TogCh
ToggleCh2
LEA audchan2toggle(PC),A0
TST.W (A0)
BEQ.B RestoreCh2
ST n_muted+audchan2temp
CLR.W $DFF0B8
BRA.B TogCh
RestoreCh2
SF n_muted+audchan2temp
BSR.W SetBackCh2Vol
BRA.B TogCh
ToggleCh3
LEA audchan3toggle(PC),A0
TST.W (A0)
BEQ.B RestoreCh3
ST n_muted+audchan3temp
CLR.W $DFF0C8
BRA.B TogCh
RestoreCh3
SF n_muted+audchan3temp
BSR.W SetBackCh3Vol
BRA.B TogCh
ToggleCh4
LEA audchan4toggle(PC),A0
TST.W (A0)
BEQ.B RestoreCh4
ST n_muted+audchan4temp
CLR.W $DFF0D8
BRA.B TogCh
RestoreCh4
SF n_muted+audchan4temp
BSR.W SetBackCh4Vol
TogCh
CLR.B RawKeyCode
EOR.W #1,(A0)
BSR.B RedrawToggles
TST.B D6 ; did we come from the keyboard keys?
BEQ.B tcskip ; yes, don't wait for mouse button up
BSR.W WaitForButtonUp
tcskip
;JSR Wait_4000 ; unneeded, makes muting more laggy
;JMP Wait_4000 ; --
RTS
RedrawToggles
CMP.W #1,CurrScreen
BNE.W Return1
LEA audchan1toggle(PC),A0
BSR.B RedrawSingleTogg
LEA audchan2toggle(PC),A0
BSR.B RedrawSingleTogg
LEA audchan3toggle(PC),A0
BSR.B RedrawSingleTogg
LEA audchan4toggle(PC),A0
RedrawSingleTogg
LEA BitplaneData,A1
MOVEQ #0,D0
MOVE.W 2(A0),D0
ADD.L D0,A1
MOVEQ #0,D0
MOVE.W 4(A0),D0
LEA ToggleONdata,A2
TST.W (A0)
BNE.B rtskip
LEA ToggleOFFdata,A2
rtskip ADD.L D0,A2
MOVEQ #11-1,D4
rtloop2 MOVE.W 88(A2),10240(A1)
MOVE.W (A2)+,(A1)
LEA 40(A1),A1
DBRA D4,rtloop2
RTS
; this portition is called from somewhere else
rtdoit MOVEQ #11-1,D4
rtloop MOVE.W 176(A2),10240(A1)
MOVE.W (A2)+,(A1)
LEA 40(A1),A1
DBRA D4,rtloop
RTS
;---- VU-meters ----
VUMeters
MOVEQ #-23,D0 ; lowest possible sprite value (-23 = 233)
LEA VUSpriteData1,A0
CMP.B (A0),D0 ; VU #1 == 233?
BEQ.B svum2 ; yes, don't sink
ADDQ.B #1,(A0) ; sink
svum2 LEA 200(A0),A0 ; A0 = VU #2 sprite
CMP.B (A0),D0 ; VU #2 == 233?
BEQ.B svum3 ; yes, don't sink
ADDQ.B #1,(A0) ; sink
svum3 LEA 200(A0),A0 ; A0 = VU #3 sprite
CMP.B (A0),D0 ; VU #3 == 233?
BEQ.B svum4 ; yes, don't sink
ADDQ.B #1,(A0) ; sink
svum4 LEA 200(A0),A0 ; A0 = VU #4 sprite
CMP.B (A0),D0 ; VU #4 == 233?
BEQ.B svumend ; yes, don't sink
ADDQ.B #1,(A0) ; sink
svumend RTS
RealVUMeters
LEA VUSpriteData1,A0
LEA 6+audchan1toggle(PC),A1
LEA VUmeterHeights,A2
; ------------------------
MOVEQ #4-1,D3
rvuloop MOVE.W (A1),D0
MOVE.B (A2,D0.W),(A0)
SUBQ.W #5,(A1)
BPL.B .L0
CLR.W (A1)
.L0 ADDQ #8,A1
LEA 200(A0),A0
DBRA D3,rvuloop
RTS
; last value = sample peak from scopes (0..64, for real VU-meters)
audchan1toggle dc.w 1, 78,$00,0
audchan2toggle dc.w 1, 518,$16,0
audchan3toggle dc.w 1, 958,$2C,0
audchan4toggle dc.w 1,1398,$42,0
;---- Disk Op. ----
DiskOp CLR.B RawKeyCode
MOVE.W CurrScreen,D0
CMP.W #3,D0
BEQ.W ExitFromDir
CMP.W #1,D0
BNE.W Return1
ShowDirScreen
ST DiskOpWasJustOpened
BSR.W WaitForButtonUp
MOVE.W #3,CurrScreen
ST DisableAnalyzer
ST NoSampleInfo
BSR.W ClearAnalyzerColors
BSR.W Clear100Lines
BSR.W SaveMainPic
lbC001DF6
BSR.B SwapDirScreen
BEQ.W DisplayMainAll
BSR.W ShowDiskSpace
BSR.W ShowModPackMode
BSR.W ShowPackModeTrackBuff
BSR.W ShowSaveModePattBuff
DoAutoDir
TST.B AutoDirFlag
BEQ.B lbC001E42
MOVE.W DirPathNum(PC),D0
BEQ.W LoadModuleGadg
CMP.W #1,D0
BEQ.W LoadSongGadg
CMP.W #2,D0
BEQ.W LoadSampleGadg
CMP.W #3,D0
BEQ.W LoadTrackGadg
CMP.W #4,D0
BEQ.W SavePatternGadg
BRA.W SelectModules
lbC001E42
MOVE.W DirPathNum(PC),D0
BEQ.W SelectModules
CMP.W #1,D0
BEQ.W SelectSongs
CMP.W #2,D0
BEQ.W SelectSamples
CMP.W #3,D0
BEQ.W SelectTracks
CMP.W #4,D0
BEQ.W SelectPatterns
BRA.W SelectModules
SwapDirScreen
MOVE.L DecompMemPtr,D0
BEQ.B sdirs2
MOVE.L D0,A1
BSR.B sdirs4
BRA.W FreeDecompMem
sdirs2 LEA DirScreenData,A0
TST.W DiskOpScreen2
BEQ.B sdirs3
LEA DirScreen2Data,A0
sdirs3 MOVE.L #DirScreenSize,D0 ; exact size for both screens
BSR.W Decompact
BEQ.B sxoutofmem
sdirs4 LEA BitplaneData,A0
MOVEQ #2-1,D2 ; 2 bitplanes
sdloop1 MOVE.W #1000-1,D0 ; 100 scanlines
sdloop2 MOVE.L (A1)+,(A0)+
DBRA D0,sdloop2
LEA 6240(A0),A0
DBRA D2,sdloop1
BSR.W FreeDecompMem
MOVEQ #-1,D0
RTS
sxoutofmem
BSR.W ssxfree
MOVEQ #0,D0
RTS
CheckDirGadgets
MOVE.W MouseX2,D0
MOVE.W MouseY2,D1
CMP.W #44,D1
BHI.W CheckDirGadgets2
CMP.W #33,D1
BLS.B ExtrasMenu
CMP.W #11,D0
BLO.W DirBrowseGadg
CMP.W #177,D0
BLO.W DirPathGadg
CMP.W #187,D0
BLO.W ChangeDiskOpMode
CMP.W #216,D0
BLO.W ParentDirGadg
CMP.W #308,D0
BLO.W ShowFreeDiskGadg
BRA.W CheckDirGadgets2
ExtrasMenu
CLR.W SelectDiskFlag
MOVEM.L D0/D1,-(SP)
BSR.W ClearFileNames
LEA FileNamesPtr(PC),A5
MOVE.W FileNameScrollPos(PC),D0
BSR.W RedrawFileNames
MOVEM.L (SP)+,D0/D1
CMP.W #82,D0
BHS.W ToggleMenu
CMP.W #22,D1
BHI.B DeleteFileGadg
CMP.W #11,D1
BHI.B RenameFileGadg
BRA.W DiskFormatGadg
RenameFileGadg
BSR.W StorePtrCol
BSR.W WaitForButtonUp
BSR.W ClearFileNames
MOVE.L PathPtr,A4
BSR.W ShowDirPath
LEA FileNamesPtr(PC),A5
BSR.W HasDiskChanged
BEQ.B RenameFileDirOk
BSR.W ClearDirTotal
BSR.W DirDisk
BNE.W RestorePtrCol
RenameFileDirOk
MOVE.W FileNameScrollPos(PC),D0
BSR.W RedrawFileNames
MOVE.W #10,Action
LEA SelectFileText,A0
JSR ShowStatusText
BRA.W RestorePtrCol
DeleteFileGadg
MOVE.W DirPathNum(PC),D0
BEQ.W DeleteModuleGadg
CMP.W #1,D0
BEQ.W DeleteSongGadg
CMP.W #2,D0
BEQ.W DeleteSampleGadg
CMP.W #3,D0
BEQ.W DeleteTrackGadg
CMP.W #4,D0
BEQ.W DeletePattGadg
RTS
ToggleMenu
CMP.W #146,D0
BHS.W SelectMenu
CMP.W #22,D1
BHI.W ToggleSaveModeBuff
CMP.W #11,D1
BHI.W TogglePackModeBuff
ToggleModPack
EOR.B #1,ModPackMode
ShowModPackMode
LEA ToggleOFFText(PC),A0
TST.B ModPackMode
BEQ.B smpmskp
LEA ToggleONText2(PC),A0
smpmskp MOVEQ #3,D0
MOVE.W #175,D1
JSR ShowText3
BRA.W WaitForButtonUp
ChangeDiskOpMode
CLR.W SelectDiskFlag
NOT.W DiskOpScreen2
CMP.W #1,DirPathNum
BNE.B lbC002022
MOVE.W #3,DirPathNum
lbC002022
CMP.W #2,DirPathNum
BNE.B lbC002034
MOVE.W #4,DirPathNum
lbC002034
CMP.W #3,DirPathNum
BNE.B lbC002046
MOVE.W #1,DirPathNum
lbC002046
CMP.W #4,DirPathNum
BNE.B lbC002058
MOVE.W #2,DirPathNum
lbC002058
BRA.W lbC001DF6
ShowNotImpl
LEA NotImplText(PC),A0
JSR ShowStatusText
BRA.W SetErrorPtrCol
NotImplText dc.b 'Not implemented',0
EVEN
TogglePackModeBuff
TST.W DiskOpScreen2
BEQ.B TogglePackMode
ToggleTrackBuffFlag
EOR.B #1,LoadTrackToBufferFlag
BRA.B ShowPackModeTrackBuff
TogglePackMode
EOR.B #1,PackMode
ShowPackModeTrackBuff
TST.W DiskOpScreen2
BEQ.B ShowPackMode
LEA ToggleCURText(PC),A0
TST.B LoadTrackToBufferFlag
BEQ.B spmtbskip
LEA ToggleBUFText(PC),A0
spmtbskip
MOVEQ #3,D0
MOVE.W #615,D1
JSR ShowText3
BRA.W WaitForButtonUp
ShowPackMode
LEA ToggleOFFText(PC),A0
TST.B PackMode
BEQ.B spmskip
LEA ToggleONText2(PC),A0
spmskip MOVEQ #3,D0
MOVE.W #615,D1
JSR ShowText3
BRA.W WaitForButtonUp
ToggleSaveModeBuff
TST.W DiskOpScreen2
BEQ.B ToggleSaveMode
TogglePattBuffFlag
EOR.B #1,LoadPattToBufferFlag
BRA.B ShowSaveModePattBuff
ToggleSaveMode
ADDQ.B #1,RawIFFPakMode
CMP.B #3,RawIFFPakMode
BNE.B ShowSaveModePattBuff
SF RawIFFPakMode
ShowSaveModePattBuff
TST.W DiskOpScreen2
BEQ.B ShowSampleSaveMode
LEA ToggleCURText(PC),A0
TST.B LoadPattToBufferFlag
BEQ.B ssmpbskip
LEA ToggleBUFText(PC),A0
ssmpbskip
MOVEQ #3,D0
MOVE.W #1055,D1
JSR ShowText3
BRA.W WaitForButtonUp
ShowSampleSaveMode
LEA RAWText(PC),A0
TST.B RawIFFPakMode
BEQ.B sssmskip
LEA IFFText(PC),A0
CMP.B #1,RawIFFPakMode
BEQ.B sssmskip
LEA PAKText(PC),A0
sssmskip
MOVEQ #3,D0
MOVE.W #1055,D1
JSR ShowText3
BRA.W WaitForButtonUp
RAWText dc.b "RAW",0
IFFText dc.b "IFF",0
PAKText dc.b "PAK",0
EVEN
SelectMenu
CMP.W #156,D0
BHS.B LoadMenu
CMP.W #22,D1
BHI.W SelectSamples
CMP.W #11,D1
BHI.W SelectSongs
BRA.W SelectModules
LoadMenu
CMP.W #238,D0
BHS.B SaveMenu
CMP.W #22,D1
BHI.W LoadSampleGadg
CMP.W #11,D1
BHI.W LoadSongGadg
BRA.W LoadModuleGadg
SaveMenu
CMP.W #22,D1
BHI.W SaveSampleGadg
CMP.W #11,D1
BHI.W SaveSongGadg
BRA.W SaveModuleGadg
CheckDirGadgets2
MOVE.W MouseX2,D0
MOVE.W MouseY2,D1
CMP.W #3,CurrScreen
BNE.W Return1
CMP.W #308,D0
BLO.W FileNamePressed
CMP.W #42,D1
BLS.W lbC0037F8
CMP.W #51,D1
BLS.W FilenameOneUp
CMP.W #82,D1
BLO.B ExitFromDir
CMP.W #91,D1
BLO.W FilenameOneDown
BRA.W lbC003926
ExitFromDir
CLR.W SelectDiskFlag
BSR.W WaitForButtonUp
CLR.B RawKeyCode
BSR.W RestoreMainPic
BSR.W Clear100Lines
DisplayMainAll
BSR.W DisplayMainScreen
JSR ShowSongLength
JSR ShowSampleInfo
JSR ShowSongName
JSR Show_MS
TST.W LoadInProgress
BNE.B dimaskp
JSR ShowAllRight
dimaskp JMP ShowPosition
DirBrowseGadg
BTST #2,$DFF016 ; right mouse button
BEQ.W ShowDiskDrives
DirBrowseGadg2
MOVEQ #0,D3
MOVE.W DirPathNum(PC),D3
LEA dpnum(PC),A0
ADD.L D3,A0
MOVEQ #0,D0
MOVE.B (A0),D0
ADDQ.B #1,D0
MOVE.B lbB002386(PC),D1
CMP.B D1,D0
BLO.B lbC002264
MOVEQ #0,D0
lbC002264 MOVE.B D0,(A0)
MOVE.L PathPtr,A0
MOVEQ #64-1,D1
MOVEQ #0,D2
lbC002270 MOVE.B D2,(A0)+
DBRA D1,lbC002270
TST.W D0
BEQ.B lbC00227E
BSR.B lbC0022E0
BRA.B lbC0022C8
lbC00227E
LEA ModulesPath,A0
TST.W D3
BEQ.B lbC0022BE
LEA SongsPath,A0
CMP.W #1,D3
BEQ.B lbC0022BE
LEA SamplePath,A0
CMP.W #2,D3
BEQ.B lbC0022BE
LEA TrackPath,A0
CMP.W #3,D3
BEQ.B lbC0022BE
LEA PattPath,A0
CMP.W #4,D3
BEQ.B lbC0022BE
LEA ModulesPath,A0
lbC0022BE
MOVE.L PathPtr,A1
lbC0022C4
MOVE.B (A0)+,(A1)+
BNE.B lbC0022C4
lbC0022C8
BSR.W ShowDirPath
MOVE.W #3,WaitTime
BRA.W WaitALittle
CNOP 0,4
dpnum dc.l 0
dc.w 0
DirPathNum
dc.w 5
lbC0022E0 MOVE.L A2,-(SP)
MOVE.B D0,D3
MOVE.L DOSBase,A0
MOVE.L 34(A0),A0
MOVE.L 24(A0),D1
LSL.L #2,D1
MOVE.L D1,A0
MOVE.L 4(A0),D1
LSL.L #2,D1
MOVE.L D1,A0
MOVEQ #1,D0
MOVEQ #0,D2
lbC002302 CMP.L #2,4(A0)
BEQ.B lbC002322
;CMP.L #0,4(A0)
TST.L 4(A0)
BEQ.B lbC002334
lbC002316 MOVE.L (A0),D1
BEQ.B lbC002362
LSL.L #2,D1
MOVE.L D1,A0
BRA.B lbC002302
lbC002322 ADDQ.W #1,D0
TST.L D2
BNE.B lbC002316
SUBQ.B #1,D3
BNE.B lbC002316
MOVE.L 40(A0),D2
LSL.L #2,D2
BRA.B lbC002316
lbC002334 MOVE.L 40(A0),D1
BEQ.B lbC002316
LSL.L #2,D1
MOVE.L D1,A2
CMP.B #3,(A2)+
BNE.B lbC002316
CMP.B #$44,(A2)+
BNE.B lbC002316
CMP.B #$46,(A2)
BNE.B lbC002316
ADDQ.W #1,D0
TST.L D2
BNE.B lbC002316
SUBQ.B #1,D3
BNE.B lbC002316
MOVE.L 40(A0),D2
LSL.L #2,D2
BRA.B lbC002316
lbC002362 MOVE.L PathPtr,A1
MOVE.L D2,A0
MOVE.B D0,lbB002386
MOVE.B (A0)+,D1
BEQ.B lbC002382
AND.B #$1F,D1
lbC002378 MOVE.B (A0)+,(A1)+
SUBQ.B #1,D1
BNE.B lbC002378
MOVE.B #$3A,(A1)+
lbC002382 MOVE.L (SP)+,A2
RTS
ActionTemp dc.w 0
lbB002386 dc.b 2
DiskOpWasJustOpened dc.b 0
SelectDiskText dc.b 'Select disk',0
OldDiskOpMode dc.b 0
EVEN
ShowDiskDrives
BSR.W WaitForButtonUp
BSR.W ClearFileNames
MOVE.W Action,ActionTemp
CLR.W Action
LEA SelectDiskText(PC),A0
JSR ShowStatusText
MOVE.W #1,SelectDiskFlag
CLR.W FileListBufferEntry
MOVEQ #' ',D0
LEA FileListBuffer(PC),A0
MOVE.L #(36*16)-1,D1
sdLoop1 MOVE.B D0,(A0)+
DBRA D1,sdLoop1
MOVEQ #0,D3
MOVE.W DirPathNum(PC),D3
LEA dpnum(PC),A0
ADD.L D3,A0
SUBQ.B #1,(A0)
BSR.W DirBrowseGadg2
LEA ModulesPath,A0
TST.W D3
BEQ.B sddSkp1
LEA SongsPath,A0
CMP.W #1,D3
BEQ.B sddSkp1
LEA SamplePath,A0
CMP.W #2,D3
BEQ.B sddSkp1
LEA TrackPath,A0
CMP.W #3,D3
BEQ.B sddSkp1
LEA PattPath,A0
CMP.W #4,D3
BEQ.B sddSkp1
LEA ModulesPath,A0
sddSkp1
LEA FileListBuffer(PC),A1
sdLoop2 MOVE.B (A0)+,(A1)+
BNE.B sdLoop2
MOVE.B #' ',-1(A1)
MOVEQ #1,D0
LEA FileListBuffer(PC),A1
MOVE.L A1,A3
MOVEQ #0,D4
MOVE.B lbB002386(PC),D4
SUBQ.W #1,D4
CMP.B #15,D4
BLO.B sddSkp2
MOVEQ #15,D4
sddSkp2 LEA 36(A3),A3
MOVE.L A3,A1
MOVEM.L D0/A2,-(SP)
MOVE.B D0,D3
MOVE.L DOSBase,A0
MOVE.L 34(A0),A0
MOVE.L 24(A0),D1
LSL.L #2,D1
MOVE.L D1,A0
MOVE.L 4(A0),D1
LSL.L #2,D1
MOVE.L D1,A0
MOVEQ #1,D0
MOVEQ #0,D2
lbC002496
CMP.L #2,4(A0)
BEQ.B lbC0024B6
TST.L 4(A0)
BEQ.B lbC0024C8
lbC0024AA
MOVE.L (A0),D1
BEQ.B lbC0024F6
LSL.L #2,D1
MOVE.L D1,A0
BRA.B lbC002496
lbC0024B6
ADDQ.W #1,D0
TST.L D2
BNE.B lbC0024AA
SUBQ.B #1,D3
BNE.B lbC0024AA
MOVE.L 40(A0),D2
LSL.L #2,D2
BRA.B lbC0024AA
lbC0024C8
MOVE.L 40(A0),D1
BEQ.B lbC0024AA
LSL.L #2,D1
MOVE.L D1,A2
CMP.B #3,(A2)+
BNE.B lbC0024AA
CMP.B #$44,(A2)+
BNE.B lbC0024AA
CMP.B #$46,(A2)
BNE.B lbC0024AA
ADDQ.W #1,D0
TST.L D2
BNE.B lbC0024AA
SUBQ.B #1,D3
BNE.B lbC0024AA
MOVE.L 40(A0),D2
LSL.L #2,D2
BRA.B lbC0024AA
lbC0024F6
MOVE.L D2,A0
MOVE.B (A0)+,D1
BEQ.B lbC00250A
AND.B #$1F,D1
lbC002500
MOVE.B (A0)+,(A1)+
SUBQ.B #1,D1
BNE.B lbC002500
MOVE.B #':',(A1)+
lbC00250A
MOVEM.L (SP)+,D0/A2
ADDQ.B #1,D0
DBRA D4,sddSkp2
lbC002516
LEA FileListBuffer(PC),A0
MOVE.W FileListBufferEntry(PC),D0
MULU.W #36,D0
ADD.L D0,A0
MOVEQ #36,D0
MOVE.W #1881,D1
MOVEQ #0,D4
MOVE.B lbB002386(PC),D4
CMP.B #8,D4
BLE.B lbC002542
MOVEQ #8,D4
lbC002542 SUBQ.W #1,D4
lbC002544
MOVEM.L D0-D7/A0-A6,-(SP)
JSR ShowText3
MOVEM.L (SP)+,D0-D7/A0-A6
LEA 36(A0),A0
ADD.L #240,D1
DBRA D4,lbC002544
RTS
SelectDiskFlag dc.w 0
FileListBufferEntry dc.w 0
FileListBuffer dcb.b 36*16,0
EVEN
SelectModules
MOVEQ #0,D0
BRA.B lbC0027CA
SelectSongs
TST.W DiskOpScreen2
BNE.B SelectTracks
MOVEQ #1,D0
BRA.B lbC0027CA
SelectSamples
TST.W DiskOpScreen2
BNE.B SelectPatterns
MOVEQ #2,D0
BRA.B lbC0027CA
SelectTracks
MOVEQ #3,D0
BRA.B lbC0027CA
SelectPatterns
MOVEQ #4,D0
lbC0027CA
TST.B DiskOpWasJustOpened
BNE.B ChangePath
TST.B ModOnlyFlag
BEQ.B ChangePath
CMP.B OldDiskOpMode(PC),D0
BEQ.B ChangePath
MOVE.B D0,OldDiskOpMode
LEA FileNamesPtr(PC),A0
CLR.L 4(A0)
ChangePath
SF DiskOpWasJustOpened
LEA TextBitplane+178,A0
MOVEQ #0,D2
MOVEQ #27-1,D1
chpalop MOVE.W D2,(A0)
LEA 40(A0),A0
DBRA D1,chpalop
LEA ModulesPath2,A4
MOVE.W #178,D1
MOVE.W D0,DirPathNum
BEQ.B chpaski
LEA SongsPath2,A4
MOVE.W #618,D1
CMP.W #1,D0
BEQ.B chpaski
LEA SamplePath2,A4
MOVE.W #1058,D1
CMP.W #2,D0
BEQ.B chpaski
LEA TrackPath2,A4
MOVE.W #618,D1
CMP.W #3,D0
BEQ.B chpaski
LEA PattPath2,A4
MOVE.W #1058,D1
CMP.W #4,D0
BEQ.B chpaski
LEA ModulesPath2,A4
MOVE.W #178,D1
chpaski LEA TextBitplane,A0
ADD.W D1,A0
MOVE.W #$0100,(A0)
MOVE.W #$0F80,40(A0)
MOVE.W #$0FC0,80(A0)
MOVE.W #$0F80,120(A0)
MOVE.W #$0100,160(A0)
MOVE.L A4,PathPtr
BSR.W ShowDirPath
BRA.W WaitForButtonUp
;---- Song Gadgets ----
LoadTrackGadg
BSR.W lbC002E76
BSR.W StorePtrCol
BSR.W WaitForButtonUp
BSR.W ClearFileNames
BSR.W SelectTracks
LEA FileNamesPtr(PC),A5
BSR.W HasDiskChanged
BEQ.B LoadTrackDirOk
BSR.W ClearDirTotal
BSR.W DirDisk
BNE.W RestorePtrCol
LoadTrackDirOk
MOVE.W FileNameScrollPos(PC),D0
BSR.W RedrawFileNames
MOVE.W #11,Action
LEA SelectTrackText,A0
JSR ShowStatusText
BRA.W RestorePtrCol
SaveTrack
BSR.W SelectTracks
LEA SaveTrackText,A0
BSR.W AreYouSure
BNE.W Return1
BSR.W ClearFileNames
LEA FormatBoxPos,A0
LEA TrackNameBox,A1
BSR.W DoSwapBox
BSR.W WaitForButtonUp
LEA EnterFilenameText,A0
JSR ShowStatusText
BSR.W lbC002E64
BSR.W StorePtrCol
BSR.W SetWaitPtrCol
LEA InputFileName,A6
MOVE.L #"trk.",(A6)+
MOVE.L A6,ShowTextPtr
MOVE.L A6,TextEndPtr
ADD.L #16,TextEndPtr
MOVE.W #14,TextLength
MOVE.W #3012,A4
CLR.B EnterTextFlag
JSR GetTextLine
BSR.W RestorePtrCol
LEA TrackNameBox,A1
LEA FormatBoxPos,A0
BSR.W DoSwapBox
BSR.W ClearFileNames
LEA TrackPath2,A0
BSR.W CopyPath
LEA InputFileName,A0
MOVEQ #20-1,D0
stloop
MOVE.B (A0)+,(A1)+
DBRA D0,stloop
JSR StopIt
BSR.W lbC002AD4
MOVE.W #11,Action
JMP ShowAllRight
DeleteTrackGadg
BSR.W WaitForButtonUp
BSR.W ClearFileNames
BSR.W SelectTracks
LEA FileNamesPtr(PC),A5
BSR.W HasDiskChanged
BEQ.B lbC0029D8
BSR.W ClearDirTotal
BSR.W DirDisk
BEQ.B lbC0029D8
BRA.W RestorePtrCol
lbC0029D8
MOVE.W FileNameScrollPos(PC),D0
BSR.W RedrawFileNames
MOVE.W #12,Action
LEA SelectTrackText,A0
JSR ShowStatusText
BRA.W SetDeletePtrCol
LoadTrack
MOVE.W #1,LoadInProgress
LEA TrackPath2,A0
BSR.W CopyPath
LEA DirInputName,A0
MOVEQ #DirNameLength-1,D0
lotrloop2
MOVE.B (A0)+,(A1)+
DBRA D0,lotrloop2
MOVE.L #TrackReadBuffer,DiskDataPtr
MOVE.L #FileName,FileNamePtr
MOVE.L #64*4,DiskDataLength
LEA LoadingTrackText,A0
JSR ShowStatusText
JSR DoLoadData
BEQ.B lotrdone
JSR CheckAbort
BEQ.B lotrdone
TST.B LoadTrackToBufferFlag
BNE.B LoadTrackToBuffer
MOVE.L SongDataPtr,A0
LEA sd_patterndata(A0),A0
MOVE.L PatternNumber,D0
LSL.L #8,D0
LSL.L #2,D0
ADD.L D0,A0
MOVEQ #0,D0
MOVE.W PattCurPos,D0
DIVU.W #6,D0
AND.L #3,D0
LSL.L #2,D0
ADD.L D0,A0
LEA TrackReadBuffer,A1
MOVEQ #64-1,D0
lotrloop3
MOVE.L (A1)+,(A0)
LEA 16(A0),A0
DBRA D0,lotrloop3
BRA.B lotrskip
LoadTrackToBuffer
LEA TrackBuffer,A1
LEA TrackReadBuffer,A0
MOVEQ #64-1,D0
lotrloop4
MOVE.L (A0)+,(A1)+
DBRA D0,lotrloop4
lotrskip
TST.B AutoExitFlag
BEQ.B lotrdone
BSR.W ExitFromDir
lotrdone
CLR.W LoadInProgress
JSR ShowAllRight
BSR.W SetNormalPtrCol
JSR RedrawPattern
RTS
lbC002AD4
MOVE.L #FileName,FileNamePtr
MOVE.L #TrackBuffer,DiskDataPtr
TST.B LoadTrackToBufferFlag
BNE.B lbC002B38
MOVE.L #TrackReadBuffer,DiskDataPtr
MOVE.L SongDataPtr,A0
LEA sd_patterndata(A0),A0
MOVE.L PatternNumber,D0
LSL.L #8,D0
LSL.L #2,D0
ADD.L D0,A0
MOVEQ #0,D0
MOVE.W PattCurPos,D0
DIVU.W #6,D0
AND.L #3,D0
LSL.L #2,D0
ADD.L D0,A0
LEA TrackReadBuffer,A1
MOVEQ #64-1,D0
lbC002B2E
MOVE.L (A0),(A1)+
LEA 16(A0),A0
DBRA D0,lbC002B2E
lbC002B38
MOVE.L #$100,DiskDataLength
JSR DoSaveData
JSR ShowAllRight
BSR.W SetNormalPtrCol
BRA.W DoAutoDir
DeleteTrack
LEA DeleteTrackText,A0
BSR.W AreYouSure
BNE.W DeleteTrackGadg
LEA DeletingTrackText,A0
JSR ShowStatusText
LEA TrackPath2,A0
BSR.W CopyPath
LEA DirInputName,A0
MOVEQ #DirNameLength-1,D0
dtrloop MOVE.B (A0)+,(A1)+
DBRA D0,dtrloop
MOVE.W #11,Action
JMP Delete3
SavePatternGadg
BSR.W lbC002E76
BSR.W StorePtrCol
BSR.W WaitForButtonUp
BSR.W ClearFileNames
BSR.W SelectPatterns
LEA FileNamesPtr(PC),A5
BSR.W HasDiskChanged
BEQ.B SavePatternDirOk
BSR.W ClearDirTotal
BSR.W DirDisk
BNE.W RestorePtrCol
SavePatternDirOk
MOVE.W FileNameScrollPos(PC),D0
BSR.W RedrawFileNames
MOVE.W #13,Action
LEA SelectPatternText,A0
JSR ShowStatusText
BRA.W RestorePtrCol
SavePattern
BSR.W SelectPatterns
LEA SavePatternText,A0
BSR.W AreYouSure
BNE.W Return1
BSR.W ClearFileNames
LEA TrackNameBox,A1
LEA FormatBoxPos,A0
BSR.W DoSwapBox
BSR.W WaitForButtonUp
LEA EnterFilenameText,A0
JSR ShowStatusText
BSR.W lbC002E64
BSR.W StorePtrCol
BSR.W SetWaitPtrCol
LEA InputFileName,A6
MOVE.L #"pat.",(A6)+
MOVE.L A6,ShowTextPtr
MOVE.L A6,TextEndPtr
ADD.L #16,TextEndPtr
MOVE.W #14,TextLength
MOVE.W #3012,A4
CLR.B EnterTextFlag
JSR GetTextLine
BSR.W RestorePtrCol
LEA TrackNameBox,A1
LEA FormatBoxPos,A0
BSR.W DoSwapBox
BSR.W ClearFileNames
LEA PattPath2,A0
BSR.W CopyPath
LEA InputFileName,A0
MOVEQ #20-1,D0
spaloop MOVE.B (A0)+,(A1)+
DBRA D0,spaloop
JSR StopIt
BSR.W DoSavePattern
MOVE.W #13,Action
JMP ShowAllRight
DeletePattGadg
BSR.W WaitForButtonUp
BSR.W ClearFileNames
BSR.W SelectPatterns
LEA FileNamesPtr(PC),A5
BSR.W HasDiskChanged
BEQ.B lbC002CD0
BSR.W ClearDirTotal
BSR.W DirDisk
BEQ.B lbC002CD0
BRA.W RestorePtrCol
lbC002CD0
MOVE.W FileNameScrollPos(PC),D0
BSR.W RedrawFileNames
MOVE.W #14,Action
LEA SelectPatternText,A0
JSR ShowStatusText
BRA.W SetDeletePtrCol
LoadPattern
MOVE.W #1,LoadInProgress
LEA PattPath2,A0
BSR.W CopyPath
LEA DirInputName,A0
MOVEQ #DirNameLength-1,D0
lopaloop2
MOVE.B (A0)+,(A1)+
DBRA D0,lopaloop2
MOVE.L #PattDiskBuffer,DiskDataPtr
MOVE.L #FileName,FileNamePtr
MOVE.L #64*4*4,DiskDataLength
LEA LoadingPatternText,A0
JSR ShowStatusText
JSR DoLoadData
BEQ.B lopadone
JSR CheckAbort
BEQ.B lopadone
TST.B LoadPattToBufferFlag
BNE.B LoadPattToBuffer
MOVE.L SongDataPtr,A0
LEA sd_patterndata(A0),A0
MOVE.L PatternNumber,D0
LSL.L #8,D0
LSL.L #2,D0
ADD.L D0,A0
LEA PattDiskBuffer,A1
MOVE.W #(64*4)-1,D0
lopaloop3
MOVE.L (A1)+,(A0)+
DBRA D0,lopaloop3
BRA.B lopaskip
LoadPattToBuffer
LEA PatternBuffer,A1
LEA PattDiskBuffer,A0
MOVE.W #(64*4)-1,D0
lopaloop4
MOVE.L (A0)+,(A1)+
DBRA D0,lopaloop4
lopaskip
TST.B AutoExitFlag
BEQ.B lopadone
BSR.W ExitFromDir
lopadone
CLR.W LoadInProgress
JSR ShowAllRight
BSR.W SetNormalPtrCol
JSR RedrawPattern
RTS
DoSavePattern
MOVE.L #FileName,FileNamePtr
MOVE.L #PatternBuffer,DiskDataPtr
TST.B LoadPattToBufferFlag
BNE.B dsapattskip
MOVE.L #PattDiskBuffer,DiskDataPtr
MOVE.L SongDataPtr,A0
LEA sd_patterndata(A0),A0
MOVE.L PatternNumber,D0
LSL.L #8,D0
LSL.L #2,D0
ADD.L D0,A0
LEA PattDiskBuffer,A1
MOVE.W #(64*4)-1,D0
dsapattloop
MOVE.L (A0)+,(A1)+
DBRA D0,dsapattloop
dsapattskip
MOVE.L #64*4*4,DiskDataLength
JSR DoSaveData
JSR ShowAllRight
BSR.W SetNormalPtrCol
BRA.W DoAutoDir
DeletePattern
LEA DeletePatternText,A0
BSR.W AreYouSure
BNE.W DeletePattGadg
LEA DeletingPatternText,A0
JSR ShowStatusText
LEA PattPath2,A0
BSR.W CopyPath
LEA DirInputName,A0
MOVEQ #DirNameLength-1,D0
dpaloop MOVE.B (A0)+,(A1)+
DBRA D0,dpaloop
MOVE.W #13,Action
JMP Delete3
lbC002E64
LEA InputFileName,A0
MOVEQ #20-1,D0
lbC002E6C
MOVE.B #0,(A0)+
DBRA D0,lbC002E6C
RTS
lbC002E76
CMP.W #2,Action
BEQ.B lbC002EAC
CMP.W #4,Action
BEQ.B lbC002EAC
CMP.W #6,Action
BEQ.B lbC002EAC
CMP.W #12,Action
BEQ.B lbC002EAC
CMP.W #14,Action
BEQ.B lbC002EAC
BRA.W Return1
lbC002EAC
BSR.W SetNormalPtrCol
RTS
;---- Song Gadgets ----
LoadSongGadg
TST.W DiskOpScreen2
BNE.W LoadTrackGadg
BSR.B lbC002E76
BSR.W StorePtrCol
BSR.W WaitForButtonUp
BSR.W ClearFileNames
BSR.W SelectSongs
LEA FileNamesPtr(PC),A5
BSR.W HasDiskChanged
BEQ.B LoadSongDirOk
BSR.W ClearDirTotal
BSR.W DirDisk
BNE.W RestorePtrCol
LoadSongDirOk
MOVE.W FileNameScrollPos(PC),D0
BSR.W RedrawFileNames
MOVE.W #1,Action
LEA SelectSongText,A0
JSR ShowStatusText
BRA.W RestorePtrCol
SaveSongGadg
TST.W DiskOpScreen2
BNE.W SaveTrack
BSR.W SelectSongs
LEA SaveSongText,A0
BSR.W AreYouSure
BNE.W Return1
BSR.W RestorePtrCol
BSR.W ClearFileNames
JSR StopIt
JSR SaveSong
MOVE.W #1,Action
RTS
DeleteSongGadg
TST.W DiskOpScreen2
BNE.W DeleteTrackGadg
BSR.W WaitForButtonUp
BSR.W ClearFileNames
BSR.W SelectSongs
LEA FileNamesPtr(PC),A5
BSR.W HasDiskChanged
BEQ.B DeleteSongDirOk
BSR.W ClearDirTotal
BSR.W DirDisk
BEQ.B DeleteSongDirOk
BRA.W RestorePtrCol
DeleteSongDirOk
MOVE.W FileNameScrollPos(PC),D0
BSR.W RedrawFileNames
MOVE.W #2,Action
LEA SelectSongText,A0
JSR ShowStatusText
BRA.W SetDeletePtrCol
;---- Module Gadgets ----
LoadModuleGadg
BSR.W lbC002E76
BSR.W StorePtrCol
BSR.W WaitForButtonUp
BSR.W ClearFileNames
BSR.W SelectModules
LEA FileNamesPtr(PC),A5
BSR.W HasDiskChanged
BEQ.B LoadModDirOk
BSR.W ClearDirTotal
BSR.W DirDisk
BEQ.B LoadModDirOk
BRA.W RestorePtrCol
LoadModDirOk
MOVE.W FileNameScrollPos(PC),D0
BSR.W RedrawFileNames
MOVE.W #3,Action
LEA SelectModuleText,A0
JSR ShowStatusText
BRA.W RestorePtrCol
SaveModuleGadg
CLR.W lbW015B92
TST.B SaveIconsFlag
BEQ.B smogskip
MOVE.W #1,lbW015B92
smogskip
CLR.W makeExeModFlag
BTST #2,$DFF016 ; right mouse button
BNE.B smogskip2
MOVE.W #1,makeExeModFlag
smogskip2
BSR.W SelectModules
LEA SaveModuleText,A0
CMP.W #1,makeExeModFlag
BNE.B smogskip3
LEA SaveExeText,A0
smogskip3
BSR.W AreYouSure
BNE.W Return1
JSR SaveModule
MOVE.W #3,Action
JMP ShowAllRight
DeleteModuleGadg
BSR.W WaitForButtonUp
BSR.W ClearFileNames
BSR.W SelectModules
LEA FileNamesPtr(PC),A5
BSR.W HasDiskChanged
BEQ.B DeleteModDirOk
BSR.W ClearDirTotal
BSR.W DirDisk
BEQ.B DeleteModDirOk
BRA.W RestorePtrCol
DeleteModDirOk
MOVE.W FileNameScrollPos(PC),D0
BSR.W RedrawFileNames
MOVE.W #4,Action
LEA SelectModuleText,A0
JSR ShowStatusText
BRA.W SetDeletePtrCol
;---- Sample Gadgets ----
LoadSampleGadg
TST.W DiskOpScreen2
BNE.W SavePatternGadg
BSR.W lbC002E76
BSR.W StorePtrCol
BSR.W WaitForButtonUp
BSR.W ClearFileNames
BSR.W SelectSamples
LEA FileNamesPtr(PC),A5
BSR.W HasDiskChanged
BEQ.B LoadSampleDirOk
BSR.W ClearDirTotal
BSR.W DirDisk
BEQ.B LoadSampleDirOk
BRA.W RestorePtrCol
LoadSampleDirOk
MOVE.W FileNameScrollPos(PC),D0
BSR.W RedrawFileNames
MOVE.W #5,Action
LEA SelectSampleText,A0
JSR ShowStatusText
BRA.W RestorePtrCol
xNotSampleNull JMP NotSampleNull
SaveSampleGadg
TST.W DiskOpScreen2
BNE.W SavePattern
BSR.W SelectSamples
CLR.B RawKeyCode
MOVE.W InsNum,D0
BEQ.B xNotSampleNull
LEA SaveSampleText,A0
BSR.W AreYouSure
BNE.W Return1
dosavesample
BSR.W StorePtrCol
JSR CreateSampleName
CMP.B #2,RawIFFPakMode
BNE.W WriteSample ; PAK flag disabled
; Sample Crunch (PAK)
TST.L DiskDataLength
BEQ.W Return1
LEA FileName,A0
dssaloop
TST.B (A0)+
BNE.B dssaloop
MOVE.B #'.',-1(A0)
MOVE.B #'p',(A0)+
MOVE.B #'p',(A0)+
MOVE.B #$00,(A0)
ShowSampleCrunchBox
BSR.W ClearFileNames
LEA FormatBoxPos,A0
LEA CrunchBoxData,A1
BSR.W DoSwapBox
JSR ShowCrunchModeTexts
LEA AreYouSureText,A0
JSR ShowStatusText
dssaloop2
BSR.W DoKeyBuffer
MOVE.B RawKeyCode,D0
CMP.B #69,D0 ; ESC
BEQ.B AbortSampleCrunchBox
BSR.W CheckPatternRedraw2
BTST #6,$BFE001 ; left mouse button
BNE.B dssaloop2
MOVE.W MouseX,D0
MOVE.W MouseY,D1
CMP.W #89,D0
BLO.B dssaloop2
CMP.W #212,D0
BHI.B dssaloop2
CMP.W #72,D1
BLO.B SampleCrunchSettings
CMP.W #82,D1
BHI.B dssaloop2
CMP.W #136,D0
BLO.W DoSampleCrunch
CMP.W #166,D0
BLO.B dssaloop2
AbortSampleCrunchBox
LEA CrunchBoxData,A1
LEA FormatBoxPos,A0
BSR.W DoSwapBox
BSR.W ClearFileNames
LEA CrunchAbortedText(PC),A0
JSR ShowStatusText
BRA.W SetErrorPtrCol
SampleCrunchSettings
CMP.W #$36,D1
BLO.W dssaloop2
CMP.W #$88,D0
BLO.B SampleCrunchSpeed
CMP.W #$A6,D0
BLO.W dssaloop2
ADDQ.L #1,CrunchBufferMode
CMP.L #3,CrunchBufferMode
BNE.B tcbmskip
CLR.L CrunchBufferMode
tcbmskip
JSR ShowCrunchModeTexts
BRA.W dssaloop2
SampleCrunchSpeed
ADDQ.L #1,CrunchSpeed
CMP.L #5,CrunchSpeed
BNE.B tcsskip
CLR.L CrunchSpeed
tcsskip
JSR ShowCrunchModeTexts
BRA.W dssaloop2
DoSampleCrunch
LEA CrunchBoxData,A1
LEA FormatBoxPos,A0
BSR.W DoSwapBox
BSR.W ClearFileNames
WriteSample
MOVE.L DiskDataLength,D1
BEQ.W Return1
MOVEQ #0,D1
MOVE.W InsNum,D1
LSL.L #2,D1
LEA SongDataPtr,A0
MOVE.L (A0,D1.W),DiskDataPtr
BSR.W SetDiskPtrCol
MOVE.L DOSBase,A6
MOVE.L FileNamePtr,D1
MOVE.L #1006,D2
JSR _LVOOpen(A6)
MOVE.L D0,FileHandle
BNE.B SaveSample
JSR CantOpenFile
BRA.W ErrorRestoreCol
SaveSample
LEA SavingSampleText,A0
JSR ShowStatusText
TST.B RawIFFPakMode
BEQ.B WriteRawSample
CMP.B #2,RawIFFPakMode
BEQ.B WritePakSample
WriteIFFSample
MOVE.L FileHandle,D1
MOVE.L #IFFFORM,D2
MOVEQ #IFFEND-IFFFORM,D3
MOVE.L D3,-(SP)
JSR _LVOWrite(A6)
CMP.L (SP)+,D3
BEQ.B WriteRawSample
JSR CantSaveFile
WriteRawSample
MOVE.L FileHandle,D1
MOVE.L DiskDataPtr,D2
MOVE.L DiskDataLength,D3
JSR _LVOWrite(A6)
CMP.L DiskDataLength,D3
BEQ.B wrsskip
JSR CantSaveFile
wrsskip
MOVE.L FileHandle,D1
JSR _LVOClose(A6)
CLR.L FileHandle
MOVE.W #5,Action
JSR ShowAllRight
BSR.W RestorePtrCol
BRA.W DoAutoDir
WritePakSample
CLR.L CrunchInfoPtr
MOVE.L DiskDataLength,D0
ADD.L #104,D0
MOVE.L #MEMF_CLEAR!MEMF_PUBLIC,D1
JSR PTAllocMem
MOVE.L D0,CrunchBufferPtr
BNE.B wpsskip
JSR OutOfMemErr
BRA.W SampleCrunchCleanUp
wpsskip
MOVE.L CrunchBufferPtr(PC),A1
TST.B SamplePackFlag
BEQ.B wpsskip2
LEA IFFFORM(PC),A0
MOVEQ #104-1,D0
wpsloop
MOVE.B (A0)+,(A1)+
DBRA D0,wpsloop
wpsskip2
MOVE.L DiskDataPtr,A0
MOVE.L DiskDataLength,D0
SUBQ.L #1,D0
wpsloop2
MOVE.B (A0)+,(A1)+
DBRA D0,wpsloop2
MOVE.L PPLibBase,D0
BNE.B wpsskip3
LEA PPLibName,A1
MOVE.L 4.W,A6
MOVEQ #0,D0
JSR _LVOOpenLibrary(A6)
MOVE.L D0,PPLibBase
BNE.B wpsskip3
LEA PPLibErrorText,A0
BRA.W SampleCrunchError
wpsskip3
MOVE.L D0,A6
CMP.W #$23,20(A6)
BGE.B wpsskip4
LEA MustHavePP35Text,A0
BRA.W SampleCrunchError
wpsskip4
MOVE.L CrunchSpeed,D0
MOVE.L CrunchBufferMode,D1
LEA CrunchInterrupt,A0
SUB.L A1,A1
MOVE.L PPLibBase,A6
JSR _LVOppAllocCrunchInfo(A6)
MOVE.L D0,CrunchInfoPtr
BEQ.W SampleCrunchOutOfMemory
LEA CrunchingText,A0
JSR ShowStatusText
MOVE.L CrunchInfoPtr(PC),A0
MOVE.L CrunchBufferPtr(PC),A1
MOVE.L DiskDataLength,D0
TST.B SamplePackFlag
BEQ.B wpsskip5
ADD.L #104,D0
wpsskip5
MOVE.L PPLibBase,A6
JSR _LVOppCrunchBuffer(A6)
LEA CrunchAbortedText(PC),A0
;CMP.L #0,D0
TST.L D0
BEQ.W SampleCrunchError
LEA BufOverflowText(PC),A0
CMP.L #-1,D0
BEQ.W SampleCrunchError
MOVE.L D0,CrunchBufferLen
LEA CrunchGainText,A0
JSR ShowStatusText
MOVE.L CrunchBufferLen(PC),D1
MOVE.L DiskDataLength,D2
TST.B SamplePackFlag
BEQ.B wpsskip6
ADD.L #104,D2
wpsskip6
CMP.L #$FFFF,D2
BLE.B wpsskip7
LSR.L #1,D2
LSR.L #1,D1
BRA.B wpsskip6
wpsskip7
MULU.W #100,D1
DIVU.W D2,D1
NEG.W D1
ADD.W #100,D1
MOVE.W D1,WordNumber
MOVE.W #5139,TextOffset
JSR Print3DecDigits
MOVE.W #ERR_WAIT_TIME,WaitTime
BSR.W WaitALittle
LEA SavingSampleText,A0
JSR ShowStatusText
MOVE.L FileHandle,D0
MOVE.L CrunchSpeed,D1
MOVEQ #0,D2
MOVEQ #0,D3
MOVE.L PPLibBase,A6
JSR _LVOppWriteDataHeader(A6)
MOVE.L FileHandle,D1
MOVE.L CrunchBufferPtr(PC),D2
MOVE.L CrunchBufferLen(PC),D3
MOVE.L DOSBase,A6
JSR _LVOWrite(A6)
CMP.L CrunchBufferLen(PC),D3
BEQ.B SampleCrunchCleanUp
JSR CantSaveFile
SampleCrunchCleanUp
MOVE.L FileHandle,D1
MOVE.L DOSBase,A6
JSR _LVOClose(A6)
;CMP.L #0,CrunchInfoPtr
TST.L CrunchInfoPtr
BEQ.B sccskip
MOVE.L CrunchInfoPtr(PC),A0
MOVE.L PPLibBase,A6
JSR _LVOppFreeCrunchInfo(A6)
sccskip
MOVE.L CrunchBufferPtr(PC),D1
BEQ.B sccskip2
MOVE.L D1,A1
MOVE.L DiskDataLength,D0
ADD.L #104,D0
JSR PTFreeMem
sccskip2
BSR.W SetNormalPtrCol
JSR ShowAllRight
BRA.W DoAutoDir
SampleCrunchError
JSR ShowStatusText
BSR.W SetErrorPtrCol
MOVE.W #ERR_WAIT_TIME,WaitTime
BSR.W WaitALittle
BRA.B SampleCrunchCleanUp
SampleCrunchOutOfMemory
LEA NoBufMemText(PC),A0
JSR ShowStatusText
MOVE.W #ERR_WAIT_TIME,WaitTime
BSR.W WaitALittle
LEA ChooseSmallerText(PC),A0
JSR ShowStatusText
MOVE.W #ERR_WAIT_TIME,WaitTime
BSR.W WaitALittle
MOVE.L CrunchBufferPtr(PC),D1
BEQ.B scoomskip
MOVE.L D1,A1
MOVE.L DiskDataLength,D0
ADD.L #104,D0
JSR PTFreeMem
scoomskip
MOVE.L FileHandle,D1
MOVE.L DOSBase,A6
JSR _LVOClose(A6)
BRA.W ShowSampleCrunchBox
CNOP 0,4
CrunchBufferLen dc.l 0
CrunchInfoPtr dc.l 0
CrunchBufferPtr dc.l 0
CrunchAbortedText dc.b 'Crunch aborted!',0
BufOverflowText dc.b 'Buffer Overflow!',0
NoBufMemText dc.b 'No mem for buffer',0
ChooseSmallerText dc.b 'Choose smaller !!',0
EVEN
CNOP 0,4
IFFFORM dc.b "FORM"
dc.l 0
dc.b "8SVX"
IFFVHDR dc.b "VHDR"
dc.l 20
dc.l 0,0,32 ; oneshot, repeat, hisamples
dc.w 16726 ; This is really NTSC (16574 for PAL!!!)
dc.b 1,0 ; octaves, compression
dc.l $10000 ; volume
IFFNAME dc.b "NAME"
dc.l 24
dcb.b 24,0
dc.b "ANNO"
dc.l 16
dc.b "ProTracker 2.3F",0
IFFBODY dc.b "BODY"
dc.l 0
IFFEND
;---- Delete Sample ----
DeleteSampleGadg
TST.W DiskOpScreen2
BNE.W DeletePattGadg ; different buttons in Disk Op. #2
BSR.W StorePtrCol
BSR.W WaitForButtonUp
BSR.W ClearFileNames
BSR.W SelectSamples
LEA FileNamesPtr(PC),A5
BSR.W HasDiskChanged
BEQ.B DeleteSamDirOk
BSR.W ClearDirTotal
BSR.W DirDisk
BEQ.B DeleteSamDirOk
BRA.W RestorePtrCol
DeleteSamDirOk
MOVE.W FileNameScrollPos(PC),D0
BSR.W RedrawFileNames
MOVE.W #6,Action
LEA SelectSampleText,A0
JSR ShowStatusText
BRA.W SetDeletePtrCol
;---- Directory Path Gadget ----
DirPathGadg
BSR.W StorePtrCol
BSR.W SetWaitPtrCol
MOVE.L PathPtr,A6
MOVE.L A6,ShowTextPtr
MOVE.L A6,TextEndPtr
ADD.L #63,TextEndPtr
MOVE.W #18,TextLength
MOVE.W #1484,A4
BSR.W GetTextLine
; PT2.3D change: refresh dir after typing dir + enter
TST.W AbortStrFlag
BNE.W SetNormalPtrCol
MOVE.L D0,-(SP)
MOVE.W DirPathNum(PC),D0
BSR.W ChangePath
BSR ClearFileNames
MOVE.L A5,-(SP)
LEA FileNamesPtr(PC),A5
BSR.W ClearDirTotal
BSR.W DirDisk
BEQ.W dpgok
MOVEA.L (SP)+,A5
MOVE.L (SP)+,D0
BRA.W SetNormalPtrCol
dpgok
BSR.W RedrawFileNames
MOVEA.L (SP)+,A5
MOVE.L A0,-(SP)
MOVE.W DirPathNum(PC),D0 ; D0 = DirPathNum (Disk Op. Load/Save mode)
BEQ.B moduleAction ; D0 #0 = load module
CMP.B #1,D0
BEQ.B songAction ; D0 #1 = load song
sampleAction ; D0 #2 = load sample
MOVE.W #5,Action ; load sample action
LEA SelectSampleText,A0
BRA.B dpgend
moduleAction
MOVE.W #3,Action ; load module action
LEA SelectModuleText,A0
BRA.B dpgend
songAction
MOVE.W #1,Action ; load song action
LEA SelectSongText,A0
dpgend
JSR ShowStatusText
MOVE.L (SP)+,A0
MOVE.L (SP)+,D0
; ----------------------------------------------------
BRA.W SetNormalPtrCol
CopyPath
LEA FileName,A1
TST.B (A0) ; If no path
BEQ.W Return1
cploop MOVE.B (A0)+,(A1)+ ; Copy path to filename
BNE.B cploop
CMP.B #':',-2(A1) ; If ending with ':' it's ok
BEQ.B PathCharBack
CMP.B #'/',-2(A1) ; If ending with '/' it's ok
BEQ.B PathCharBack
MOVE.B #'/',-1(A1) ; Add '/' to end path
RTS
PathCharBack
SUBQ.L #1,A1
RTS
ShowDirPath
CMP.W #3,CurrScreen
BNE.W Return1
MOVEM.L D0/D1/A0/A1,-(SP)
MOVE.L PathPtr,A0
MOVEQ #18,D0
MOVE.W #1484,D1
JSR ShowText3
MOVEM.L (SP)+,D0/D1/A0/A1
RTS
;---- File List Gadgets ----
FilenameOneUp
ST SetSignalFlag
TST.W SelectDiskFlag
BNE.B fnouskip
TST.W Action
BEQ.W Return1
JSR GUIDelay ; PT2.3D change: wait properly on every scroll
fnouskip2
LEA FileNamesPtr(PC),A5
MOVE.W FileNameScrollPos(PC),D0
BEQ.W Return1
SUBQ.W #1,D0
BTST #2,$DFF016 ; right mouse button
BNE.W RedrawFileNames
SUBQ.W #3,D0
BPL.W RedrawFileNames
MOVEQ #0,D0
BRA.W RedrawFileNames
fnouskip
MOVE.W FileListBufferEntry(PC),D0
BEQ.W Return1
SUBQ.W #1,D0
MOVE.W D0,FileListBufferEntry
BRA.W lbC002516
lbC0037F8
TST.W SelectDiskFlag
BNE.B lbC003826
TST.W Action
BEQ.W Return1
BTST #2,$DFF016 ; right mouse button
BEQ.B lbC003832
LEA FileNamesPtr(PC),A5
MOVE.W FileNameScrollPos(PC),D0
BEQ.W Return1
lbC003820
CLR.W D0
BRA.W RedrawFileNames
lbC003826
CLR.W FileListBufferEntry
BRA.W lbC002516
lbC003832
TST.W SelectDiskFlag
BNE.W Return1
LEA FileNamesPtr(PC),A5
MOVE.W FileNameScrollPos(PC),D0
MULU.W #36,D0
MOVE.L (A5),A1
MOVE.B (A1,D0.L),D1
CMP.L #'mod.',(A1,D0.L)
BNE.B lbC00385C
MOVE.B 4(A1,D0.L),D1
lbC00385C
BSR.W lbC0039E8
SUB.L #$24,D0
BMI.B lbC003820
MOVE.B (A1,D0.L),D2
CMP.L #'mod.',(A1,D0.L)
BNE.B lbC00387A
MOVE.B 4(A1,D0.L),D2
lbC00387A
BSR.W lbC0039F0
CMP.B D1,D2
BEQ.B lbC00385C
MOVE.B D2,D1
lbC003884
SUBI.L #$24,D0
BMI.B lbC003820
MOVE.B (A1,D0.L),D2
CMP.L #'mod.',(A1,D0.L)
BNE.B lbC00389E
MOVE.B 4(A1,D0.L),D2
lbC00389E
BSR.W lbC0039F0
CMP.B D1,D2
BEQ.B lbC003884
DIVU.W #$24,D0
ADDQ.W #1,D0
BRA.W RedrawFileNames
FilenameOneDown
ST SetSignalFlag
TST.W SelectDiskFlag
BNE.B fnodskip
TST.W Action
BEQ.W Return1
JSR GUIDelay ; PT2.3D change: wait properly on every scroll
fnodskip2
LEA FileNamesPtr(PC),A5
MOVE.W FileNameScrollPos(PC),D0
ADDQ.W #1,D0
BTST #2,$DFF016 ; right mouse button
BNE.B fnod2
ADDQ.W #3,D0
fnod2 MOVE.W 16(A5),D1
SUBQ.W #8,D1
BMI.W Return1
CMP.W D1,D0
BLS.W RedrawFileNames
MOVE.W D1,D0
BRA.W RedrawFileNames
fnodskip
MOVEQ #0,D0
MOVE.B lbB002386(PC),D0
CMP.W #8,D0
BLE.W Return1
SUBQ.W #8,D0
MOVE.W FileListBufferEntry(PC),D1
CMP.W D0,D1
BGE.W Return1
ADDQ.W #1,D1
MOVE.W D1,FileListBufferEntry
BRA.W lbC002516
lbC003926
TST.W SelectDiskFlag
BNE.B lbC00395A
TST.W Action
BEQ.W Return1
BTST #2,$DFF016 ; right mouse button
BEQ.B lbC00397A
LEA FileNamesPtr(PC),A5
MOVE.W FileNameScrollPos(PC),D0
MOVE.W 16(A5),D1
SUBQ.W #8,D1
BMI.W Return1
MOVE.W D1,D0
BRA.W RedrawFileNames
lbC00395A
MOVEQ #0,D0
MOVE.B lbB002386(PC),D0
CMP.W #8,D0
BLE.W Return1
SUBQ.W #8,D0
MOVE.W D0,FileListBufferEntry
BRA.W lbC002516
lbC00397A
TST.W SelectDiskFlag
BNE.W Return1
LEA FileNamesPtr(PC),A5
MOVE.W FileNameScrollPos(PC),D0
MULU.W #36,D0
MOVE.L (A5),A1
MOVE.B (A1,D0.L),D1
CMP.L #'mod.',(A1,D0.L)
BNE.B lbC0039A4
MOVE.B 4(A1,D0.L),D1
lbC0039A4
BSR.B lbC0039E8
ADD.L #$24,D0
MOVE.W 16(A5),D2
SUBQ.W #8,D2
BMI.W Return1
MULU.W #36,D2
CMP.L D2,D0
BLS.B lbC0039C8
MOVE.L D2,D0
DIVU.W #36,D0
BRA.W RedrawFileNames
lbC0039C8
MOVE.B (A1,D0.L),D2
CMP.L #'mod.',(A1,D0.L)
BNE.B lbC0039DA
MOVE.B 4(A1,D0.L),D2
lbC0039DA
BSR.B lbC0039F0
CMP.B D1,D2
BEQ.B lbC0039A4
DIVU.W #$24,D0
BRA.W RedrawFileNames
lbC0039E8
MOVE.B D1,D3
BSR.B lbC0039F8
MOVE.B D3,D1
RTS
lbC0039F0
MOVE.B D2,D3
BSR.B lbC0039F8
MOVE.B D3,D2
RTS
lbC0039F8
CMP.B #65,D3
BLO.B lbC003A08
CMP.B #90,D3
BHI.B lbC003A08
ADD.B #32,D3
lbC003A08
RTS
;---- Clicked on a filename ----
FileNamePressed
SUB.W #44,D1
ST UpdateFreeMem
CMP.W #3,D1
BLO.W Return1
CMP.W #50,D1
BHI.W Return1
SUBQ.W #3,D1
AND.L #$FFFF,D1
DIVU.W #6,D1
TST.W SelectDiskFlag
BNE.W lbC003ADC
TST.W Action
BEQ.W Return1
MOVE.W D1,FileNameScrollPos+2
LEA FileNamesPtr(PC),A5
MOVE.W FileNameScrollPos(PC),D0
ADD.W D1,D0
CMP.W 16(A5),D0
BHS.W Return1
MULU.W #36,D0
ADD.L (A5),D0
MOVE.L D0,A0
TST.L 32(A0)
BMI.W AddDirectory
MOVEQ #DirNameLength-1,D0
LEA DirInputName,A1
fnploop MOVE.B (A0)+,(A1)+
DBRA D0,fnploop
MOVE.W Action,D6
CMP.W #1,D6
BEQ.W LoadSong
CMP.W #2,D6
BEQ.W DeleteSong
CMP.W #3,D6
BEQ.W xLoadModule
CMP.W #4,D6
BEQ.W DeleteModule
CMP.W #5,D6
BEQ.W LoadSample
CMP.W #6,D6
BEQ.W DeleteSample
CMP.W #10,D6
BEQ.W RenameFile
CMP.W #11,D6
BEQ.W LoadTrack
CMP.W #12,D6
BEQ.W DeleteTrack
CMP.W #13,D6
BEQ.W LoadPattern
CMP.W #14,D6
BEQ.W DeletePattern
RTS
lbC003ADC
ADD.W FileListBufferEntry(PC),D1
MOVEQ #0,D3
MOVE.W DirPathNum(PC),D3
LEA dpnum(PC),A0
ADD.L D3,A0
MOVEQ #0,D0
MOVE.B lbB002386(PC),D0
CMP.B D0,D1
BLO.B lbC003AFE
RTS
lbC003AFE
SUBQ.B #1,D1
MOVE.B D1,(A0)
BSR.W DirBrowseGadg2
CLR.W SelectDiskFlag
MOVE.W ActionTemp(PC),Action
BRA.W DoAutoDir
xLoadModule JMP LoadModule
AddDirectory
MOVE.L A0,-(SP)
MOVE.L PathPtr,A0
BSR.W CopyPath
MOVE.L (SP)+,A0
MOVEQ #DirNameLength-1,D0
addplop MOVE.B (A0)+,(A1)+
DBRA D0,addplop
LEA FileName,A0
MOVE.L PathPtr,A1
MOVEQ #97-1,D0 ; 62
addplp2 MOVE.B (A0)+,(A1)+
DBRA D0,addplp2
addpdir BSR.W ShowDirPath
MOVE.W Action,D6
CMP.W #1,D6
BEQ.W LoadSongGadg
CMP.W #2,D6
BEQ.B xDeleteSongGadg
CMP.W #3,D6
BEQ.W LoadModuleGadg
CMP.W #4,D6
BEQ.B xDeleteModuleGadg
CMP.W #5,D6
BEQ.W LoadSampleGadg
CMP.W #6,D6
BEQ.B xDeleteSampleGadg
CMP.W #10,D6
BEQ.W RenameFileGadg
CMP.W #11,D6
BEQ.W LoadTrackGadg
CMP.W #12,D6
BEQ.B xDeleteTrackGadg
CMP.W #13,D6
BEQ.W SavePatternGadg
CMP.W #14,D6
BEQ.B xDeletePattGadg
RTS
xDeleteModuleGadg
BSR.W DoAutoDir
BRA.W DeleteModuleGadg
xDeleteSongGadg
BSR.W DoAutoDir
BRA.W DeleteSongGadg
xDeleteSampleGadg
BSR.W DoAutoDir
BRA.W DeleteSampleGadg
xDeleteTrackGadg
BSR.W DoAutoDir
BRA.W DeleteTrackGadg
xDeletePattGadg
BSR.W DoAutoDir
BRA.W DeletePattGadg
ParentDirGadg
BSR.W WaitForButtonUp
MOVE.L PathPtr,A0
MOVE.L A0,A1
pdgloop TST.B (A1)+
BNE.B pdgloop
SUBQ.L #1,A1
CMP.L A0,A1
BLS.W Return1
SUBQ.L #1,A1
CMP.B #'/',(A1)
BNE.B pdgskp1
CLR.B (A1)
pdgskp1 CMP.B #':',(A1)
BEQ.W addpdir
CMP.B #'/',(A1)
BEQ.B pdgslsh
CLR.B (A1)
CMP.L A0,A1
BLS.W addpdir
SUBQ.L #1,A1
BRA.B pdgskp1
pdgslsh CLR.B (A1)
BRA.W addpdir
CNOP 0,4
FileNamesPtr
dc.l 0 ; A5+ 0
dc.l 0 ; + 4
dc.l 0 ; + 8
dc.l 0 ; +12
dc.w 0 ; +16
dc.w 24 ; +18
FileNameScrollPos
dc.w 0
dc.w 0
;---- Has Disk Changed ----
HasDiskChanged
MOVE.L DOSBase,A6
MOVE.L A4,D1
MOVEQ #-2,D2
JSR _LVOLock(A6)
MOVE.L D0,FileLock
BEQ.B ExamineError
MOVE.L FileLock,D1
MOVE.L #FileInfoBlock,D2
JSR _LVOExamine(A6)
TST.L D0
BEQ.B ExamineError
LEA FileInfoBlock,A0
MOVE.L ofib_DateStamp+ds_Days(A0),D0
CMP.L 4(A5),D0
BNE.B DiskChanged
MOVE.L ofib_DateStamp+ds_Minute(A0),D0
CMP.L 8(A5),D0
BNE.B DiskChanged
MOVE.L ofib_DateStamp+ds_Tick(A0),D0
CMP.L 12(A5),D0
BNE.B DiskChanged
MOVE.L FileLock,D1
JSR _LVOUnLock(A6)
MOVEQ #0,D0
RTS
DiskChanged
MOVE.L ofib_DateStamp+ds_Days(A0),4(A5)
MOVE.L ofib_DateStamp+ds_Minute(A0),8(A5)
MOVE.L ofib_DateStamp+ds_Tick(A0),12(A5)
MOVE.L FileLock,D1
JSR _LVOUnLock(A6)
MOVEQ #-1,D0
RTS
ExamineError
CLR.L 4(A5)
MOVEQ #-1,D0
RTS
ShowFreeDiskGadg
CLR.W SelectDiskFlag
BSR.W WaitForButtonUp
MOVE.L PathPtr,A4
BSR.B LockAndGetInfo
BNE.W Return1
BSR.W DirDiskUnlock
BSR.W ClearFileNames
LEA FileNamesPtr(PC),A5
MOVE.W FileNameScrollPos(PC),D0
BSR.W RedrawFileNames
JMP ShowAllRight
LockAndGetInfo
BSR.W StorePtrCol
BSR.W SetDiskPtrCol
CLR.W FileNameScrollPos
MOVE.L DOSBase,A6
MOVE.L A4,D1
MOVEQ #-2,D2
JSR _LVOLock(A6)
MOVE.L D0,FileLock
BEQ.W DirDiskError
LEA ReadingDirText,A0
JSR ShowStatusText
MOVE.L FileLock,D1
MOVE.L #InfoData,D2
JSR _LVOInfo(A6)
LEA InfoData,A0
MOVE.L 12(A0),D0 ; id_NumBlocks
; -------------------------------------------------
; This code snippet was taken from PT3.15.S
MOVEM.L D3/D4,-(SP)
MOVE.L 16(A0),D1 ; id_NumBlocksUsed
MOVE.L 20(A0),D2 ; id_BytesPerBlock
SUB.L D1,D0 ; Sub all blocks used from total blocks
MOVE.W D0,D3 ; THIS IS NOT VERY FAST!!!!!
SWAP D0 ; We must split register, coz mulu won't
MOVE.W D0,D4 ; accept longwords!
MULU.W D2,D3 ; Ex: cannot calc a volume with size: 50 Mb
MULU.W D2,D4 ; But now we can! hehe! Plystre!
SWAP D4
OR.L D4,D3 ; OKI. Let's insert the "reminder"!!!
MOVE.L D3,FreeDiskSpace ; Here is the size of bytes free on disk!
MOVEM.L (SP)+,D3/D4
; -------------------------------------------------
ShowDiskSpace
MOVE.W #1510,TextOffset
MOVE.L FreeDiskSpace,D7
TST.B ShowDecFlag
BNE.B sdsdec
SWAP D7
MOVE.W D7,WordNumber
JSR PrintHexWord
SWAP D7
MOVE.W D7,WordNumber
JSR PrintHexWord
MOVEQ #0,D0
RTS
sdsdec
; PT2.3D bug fix: show "A LOT..." when free space is more than 8 digits
CMP.L #99999999,D7
BLS.B sdsdecok
MOVE.L #tooMuchText,ShowTextPtr
MOVE.W #8,TextLength
JSR ShowText
BRA.B sdsdecend
sdsdecok
DIVU.W #10000,D7
MOVE.W D7,WordNumber
JSR Print4DecDigits
SWAP D7
MOVE.W D7,WordNumber
JSR Print4DecDigits
sdsdecend
MOVEQ #0,D0
RTS
tooMuchText dc.b "A LOT..."
EVEN
;---- Get Disk Directory ----
AllocDirMem
ADD.W #50,DirEntries
MOVE.W DirEntries(PC),D0
MULU.W #36,D0
MOVE.L DirAllocSize(PC),D6
MOVE.L D0,DirAllocSize
MOVE.L #MEMF_CLEAR,D1
JSR PTAllocMem
MOVE.L D0,D7
BEQ.B baehsj
MOVE.L FileNamesPtr(PC),D1
MOVE.L D7,FileNamesPtr
TST.L D1
BEQ.W Return1
TST.L D6
BEQ.W Return1
MOVE.L D1,A0
MOVE.L D7,A1
MOVE.L D6,D0
admloop MOVE.B (A0)+,(A1)+
SUBQ.L #1,D6
BNE.B admloop
MOVE.L D1,A1
JSR PTFreeMem
RTS
FreeDirMem
MOVE.L FileNamesPtr(PC),D1
BEQ.W Return1
MOVE.L D1,A1
MOVE.L DirAllocSize(PC),D0
JSR PTFreeMem
CLR.L FileNamesPtr
CLR.W DirAllocSize
CLR.W DirEntries
RTS
baehsj JSR OutOfMemErr
MOVEQ #-1,D0
RTS
CNOP 0,4
DirAllocSize dc.l 0
DirEntries dc.w 0
DirDisk BSR.B FreeDirMem
BSR.W AllocDirMem
BSR.W LockAndGetInfo ; puts DOSBase into A6
BNE.W Return1
MOVE.L FileLock,D1
MOVE.L #FileInfoBlock,D2
JSR _LVOExamine(A6)
TST.L D0
BEQ.B DirDiskError
ddloop1 MOVE.L FileLock,D1
MOVE.L #FileInfoBlock,D2
MOVE.L DOSBase,A6
JSR _LVOExNext(A6)
TST.L D0
BEQ.B DirDiskUnlock
BTST #2,$DFF016 ; right mouse button
BEQ.B AbortDir
BSR.W NewDirEntry
BRA.B ddloop1
AbortDir
CLR.L 4(A5)
LEA DirAbortedText(PC),A0
JSR ShowStatusText
BSR.B DirDiskUnlock
BSR WaitALittle
JSR ShowAllRight
MOVEQ #0,D0
RTS
DirDiskUnlock
MOVE.L FileLock,D1
JSR _LVOUnLock(A6)
BSR RestorePtrCol
MOVEQ #0,D0
RTS
DirAbortedText dc.b 'dir aborted !',0
EVEN
DirDiskError
TST.L FileLock
BEQ.B ddeskip
MOVE.L FileLock,D1
JSR _LVOUnLock(A6)
ddeskip ;BSR.W PTScreenToFront (8bitbubsy: this causes issues on exit!)
BSR.W RestorePtrCol
LEA CantFindDirText(PC),A0
JSR ShowStatusText
BSR.W SetErrorPtrCol
MOVEQ #-1,D0
RTS
ClearDirTotal
CLR.W 16(A5)
RTS
CantFindDirText dc.b "can't find dir !",0
EVEN
NewDirEntry
LEA FIB_FileName,A0
TST.B ShowDirsFlag
BNE.B ndeok1
TST.L FIB_EntryType
BPL.W Return1
ndeok1 TST.L FIB_EntryType
BPL.B ndeok2
TST.B ModOnlyFlag
BEQ.B ndeok2
TST.W DirPathNum
BNE.B ndeok2
MOVE.L (A0),D0
AND.L #$DFDFDFFF,D0
CMP.L #'MOD.',D0
BNE.W Return1
ndeok2 MOVE.W 16(A5),D0
CMP.W DirEntries(PC),D0
BLO.B ndeok3
MOVE.L A0,-(SP)
BSR.W AllocDirMem
MOVE.L (SP)+,A0
ndeok3 MOVE.W 16(A5),D6
BEQ.B ndeadd1 ; If first entry
SUBQ.W #1,D6
MOVE.L (A5),A1
ndeloopname
MOVEQ #0,D2
MOVE.L FIB_EntryType,D0
MOVE.L 32(A1),D1
TST.L D0
BPL.B ndesfil ; if directory, all is well
TST.L D1
BMI.B ndenext ; was file, so skip if directory
BRA.B ndelopc
ndesfil TST.L D1 ; if file
BPL.B ndeinse
ndelopc MOVE.B (A0,D2.W),D0 ; Get a character
BEQ.B ndeinse
CMP.B #96,D0 ; Lowercase?
BLO.B ndeskp1
SUB.B #32,D0 ; Switch to upper
ndeskp1 MOVE.B (A1,D2.W),D1
BEQ.B ndenext
CMP.B #96,D1
BLO.B ndeskp2
SUB.B #32,D1
ndeskp2 CMP.B D0,D1
BHI.B ndeinse
BNE.B ndenext
ADDQ.W #1,D2
BRA.B ndelopc
ndenext LEA 36(A1),A1 ; next entry
DBRA D6,ndeloopname ; loop entries
MOVE.L (A5),A1
MOVE.W 16(A5),D0
MULU.W #36,D0
ADD.W D0,A1
BRA.B ndeadd2
ndeinse MOVE.L (A5),A2
MOVE.W 16(A5),D0
MULU.W #36,D0
ADD.W D0,A2
MOVE.L A2,A3
LEA 36(A3),A3
nde3loop MOVE.W -(A2),-(A3)
CMP.L A2,A1
BNE.B nde3loop
BRA.B ndeadd2
ndeadd1 MOVE.L (A5),A1 ; Put new filename into list
ndeadd2 LEA FIB_FileName,A0
MOVE.L A1,A3
MOVEQ #36-1,D0 ; Clear old filename
nde4loop
CLR.B (A3)+
DBRA D0,nde4loop
MOVE.W FIB_DateStamp+ds_Days+2,30(A1)
MOVEQ #-1,D0
TST.L FIB_EntryType
BPL.B ndefskp
MOVE.L FIB_FileSize,D0
ndefskp MOVE.L D0,32(A1)
MOVEQ #30-1,D0 ; Copy new filename
nde4loop2
MOVE.B (A0)+,D1
MOVE.B D1,(A1)+
TST.B D1
BEQ.B nde4skip
DBRA D0,nde4loop2
nde4skip
ADDQ.W #1,16(A5) ; Files + 1
RTS
RedrawFileNames
MOVE.L D0,-(SP)
BSR.W ShowDirPath
MOVE.L (SP)+,D0
MOVE.W D0,FileNameScrollPos
TST.W 16(A5)
BEQ.W Return1
MOVEA.W #1881,A6
MOVE.W A6,TextOffset
MOVE.L (A5),D6
MULU.W #36,D0
ADD.L D0,D6
MOVE.W 16(A5),D0
SUB.W FileNameScrollPos(PC),D0
CMP.W #8,D0
BHS.B ShowFileNames
SUBQ.W #1,D0
MOVE.W D0,D7
BRA.B sfnloop
ShowFileNames
MOVE.W #$91,D0
BSR.W WaitForVBlank
MOVEQ #8-1,D7
sfnloop MOVE.W A6,TextOffset
MOVE.L D6,A0
MOVEQ #0,D0
MOVE.W 30(A0),D0
BSR.W CalculateDate
MOVE.W TheDay(PC),WordNumber
JSR Print2DecDigits
MOVE.W TheMonth(PC),WordNumber
JSR Print2DecDigits
MOVE.W TheYear(PC),WordNumber
JSR Print2DecDigits
ADDQ.W #1,TextOffset
MOVE.L D6,ShowTextPtr
MOVE.W #24,TextLength
TST.W DirPathNum
BNE.B sfnskip
TST.B ModOnlyFlag
BEQ.B sfnskip
MOVE.L D6,A0
MOVE.L (A0),D0
AND.L #$DFDFDFFF,D0
CMP.L #"MOD.",D0
BNE.B sfnskip
ADDQ.L #4,ShowTextPtr
sfnskip JSR SpaceShowText
LEA 32(A6),A6
MOVE.W A6,TextOffset
MOVE.L D6,A0
MOVE.L 32(A0),D1
BMI.B sfndir
TST.B ShowDecFlag
BNE.B sfndec
SWAP D1
AND.W #$000F,D1
BSR.W ShowOneDigit
MOVE.L D6,A0
MOVE.W 34(A0),WordNumber
JSR PrintHexWord
sfnend ADD.L #36,D6
LEA 208(A6),A6
DBRA D7,sfnloop
RTS
sfndec MOVE.L D1,D0
SUBQ.W #1,TextOffset
JSR Print6DecDigits
BRA.B sfnend
sfndir MOVE.L #DirText,ShowTextPtr
SUBQ.W #1,TextOffset
MOVE.W #6,TextLength
JSR ShowText
BRA.B sfnend
CalculateDate
DIVU.W #1461,D0
LSL.W #2,D0
MOVE.W D0,TheYear
CLR.W D0
SWAP D0
CMP.W #789,D0
BEQ.B cadleap
BLO.B cadskp2
SUBQ.W #1,D0
cadskp2 DIVU.W #365,D0
MOVE.L D0,D1
SWAP D1
CMP.W #4,D0
BLO.B cadskip
SUBQ.W #1,D0
cadskip ADD.W D0,TheYear
LEA MonthTable(PC),A1
MOVEQ #24,D0
cadloop SUBQ.W #2,D0
MOVE.W (A1,D0.W),D2
CMP.W D2,D1
BHS.B cadskp3
TST.W D0
BNE.B cadloop
cadskp3 LSR.W #1,D0
ADDQ.W #1,D0
MOVE.W D0,TheMonth
SUB.W D2,D1
ADDQ.W #1,D1
MOVE.W D1,TheDay
cadend MOVEQ #0,D0
MOVE.W TheYear(PC),D0
ADD.W #78,D0
DIVU.W #100,D0
SWAP D0
MOVE.W D0,TheYear
RTS
cadleap ADDQ.W #2,TheYear
MOVE.W #2,TheMonth
MOVE.W #29,TheDay
BRA.B cadend
TheYear dc.w 0
TheMonth dc.w 0
TheDay dc.w 0
MonthTable dc.w 0,31,59,90,120,151,181,212,243,273,304,334
DirText dc.b " (DIR)"
EVEN
;---- Update Mousepointer Position ----
UpdatePointerPos
MOVE.W MouseX(PC),D0
ADDQ.W #3,D0
MOVE.W MouseY(PC),D1
MOVEQ #16,D2
MOVE.L PointerSpritePtr(PC),A0
JMP SetSpritePos
;---- Play Song ----
PlaySong
MOVEQ #0,D0
SongFrom
BSR.W StopIt
BTST #2,$DFF016 ; right mouse button
BNE.B sofr1
MOVE.W PlayFromPos(PC),D0
sofr1 MOVE.W D0,ScrPattPos
LSL.W #4,D0
AND.L #$FFF,D0
MOVE.L D0,PatternPosition
wfbu1 BTST #6,$BFE001 ; left mouse button
BEQ.B wfbu1
CLR.B RawKeyCode
CLR.B SaveKey
BSR.W SetPlayPtrCol
CLR.L PlaybackSecsFrac
CLR.L PlaybackSecs
BSR.W DrawPlaybackCounter
MOVE.L #'patp',RunMode
CLR.W DidQuantize
MOVE.L #-1,LongFFFF
BSR.W SetScrPatternPos
SetPlayPosition
MOVE.L CurrPos,D0
MOVE.L SongDataPtr,A0
CMP.B sd_numofpatt(A0),D0
BHS.B SongPosToZero
MOVE.L CurrPos,SongPosition
RTS
SongPosToZero
CLR.L SongPosition
CLR.L CurrPos
RTS
;---- Play Pattern ----
PlayPattern
CMP.W #8,CurrScreen
BEQ.W lbC009F6C
ppskip
MOVEQ #0,D0
PattFrom
BSR.W StopIt
BTST #2,$DFF016 ; right mouse button
BNE.B pafr1
MOVE.W PlayFromPos(PC),D0
pafr1 MOVE.W D0,ScrPattPos
LSL.W #4,D0
AND.L #$FFF,D0
MOVE.L D0,PatternPosition
wfbu2 BTST #6,$BFE001 ; left mouse button
BEQ.B wfbu2
CLR.B RawKeyCode
CLR.B SaveKey
MOVE.L #'patt',RunMode
BSR.W SetPlayPtrCol
RTS
;---- Record Pattern/Song ----
RecordPattern
MOVEQ #0,D0
RecordFrom
; 8bitbubsy: allow CTRL+Fn (ALT+Fn is already allowed)
;TST.W SamScrEnable
;BNE.W Return1
;
BSR.W StopIt
BTST #2,$DFF016 ; right mouse button
BNE.B refr1
MOVE.W PlayFromPos(PC),D0
refr1 MOVE.W D0,ScrPattPos
LSL.W #4,D0
AND.L #$FFF,D0
MOVE.L D0,PatternPosition
wfbu3 BTST #6,$BFE001 ; left mouse button
BEQ.B wfbu3
BSR.W SetEditPtrCol
CLR.B RawKeyCode
CLR.B SaveKey
BSR.W SaveUndo
MOVE.L #'edit',EditMode
MOVE.L #'patt',RunMode
TST.B RecordMode
BEQ.W Return1
MOVE.L #'patp',RunMode
BRA.W SetPlayPosition
;---- Show Main Screen ----
DisplayMainScreen
CLR.W BlockMarkFlag
MOVE.W #1,CurrScreen
SF NoSampleInfo
TST.W LoadInProgress
BNE.B dmsskp3
BSR.W SetNormalPtrCol
TST.W RunMode
BEQ.B dmsskip
BSR.W SetPlayPtrCol
dmsskip TST.L EditMode
BEQ.B dmsskp2
BSR.W SetEditPtrCol
dmsskp2 BSR.W StorePtrCol
dmsskp3 ST DisableAnalyzer
BSR.W ClearAnaHeights
BSR.W ClearRightArea
LEA TopMenusPos,A0
LEA TopMenusBuffer,A1
MOVEQ #44-1,D0
cgloop4 MOVEQ #25-1,D1
cgloop5 MOVE.B (A1)+,(A0)+
MOVE.B 1099(A1),10239(A0)
DBRA D1,cgloop5
LEA 15(A0),A0
DBRA D0,cgloop4
BSR.W RedrawToggles
BSR.W DrawPlaybackCounter
TST.B EdEnable
BNE.W EditOp
MOVEQ #0,D4
RedrawAnaScope
MOVE.W #145,D0
BSR.W WaitForVBlank
SF ScopeEnable
ST DisableAnalyzer
BSR.W ClearRightArea
LEA SpectrumAnaData,A0
MOVE.L #SpectrumAnaSize,D0
TST.B AnaScopFlag
BEQ.B cgjojo
LEA ScopeData,A0
MOVE.L #ScopeSize,D0
cgjojo BSR.W Decompact
BEQ.B cgjaja
LEA SpectrumAnaPos,A0
MOVEQ #1,D7
cgloop1 MOVEQ #55-1,D6 ; 55 lines in picture.
cgloop2 MOVEQ #25-1,D5 ; 25 bytes(x8)
cgloop3 MOVE.B (A1)+,(A0)+
DBRA D5,cgloop3
ADDQ #1,A1
LEA 15(A0),A0
DBRA D6,cgloop2
LEA 8040(A0),A0
DBRA D7,cgloop1
BSR.W FreeDecompMem
cgjaja TST.L D4
BNE.W Return1
TST.B AnaScopFlag
BNE.B cgscope
BSR.W ClearAnaHeights
BSR.B ClearRightArea
SF DisableAnalyzer
BRA.W SetAnalyzerColors
cgscope ST ScopeEnable
BRA.W ClearAnalyzerColors
;---- Clear Areas ----
ClearFileNames
MOVE.W #145,D0
BSR.W WaitForVBlank
LEA TextBitplane+1800,A1
MOVE.W #550-1,D0
MOVEQ #0,D1
cfnloop MOVE.L D1,(A1)+
DBRA D0,cfnloop
RTS
ClearRightArea
LEA TextBitplane+55,A0
MOVEQ #0,D2
MOVEQ #99-1,D0
cnblloop1
MOVEQ #25-1,D1
cnblloop2
MOVE.B D2,(A0)+
DBRA D1,cnblloop2
LEA 15(A0),A0
DBRA D0,cnblloop1
RTS
Clear100Lines
LEA TextBitplane,A0
MOVE.W #1000-1,D0
MOVEQ #0,D1
chlloop MOVE.L D1,(A0)+
DBRA D0,chlloop
RTS
;---- Are You Sure Requester ----
AreYouSure
MOVE.L A0,LastAreYouSureTextPtr
ST DisableScopeMuting
MOVE.B DisableAnalyzer,SaveDA
MOVE.B ScopeEnable(PC),SaveScope
SF ScopeEnable
JSR ShowStatusText
BSR.W StorePtrCol
BSR.W SetWaitPtrCol
BSR.W Wait_4000
CMP.W #1,CurrScreen
BNE.B aysskip
TST.B DisableAnalyzer
BNE.B aysskip
ST DisableAnalyzer
BSR.W ClearAnaHeights
BSR.W ClearRightArea
aysskip LEA SureBoxData,A1
BSR.W SwapBoxMem
BSR.W WaitForButtonUp
BSR.W Wait_4000
CLR.B RawKeyCode
surebuttoncheck
ST AskBoxShown
BTST #2,$DFF016 ; right mouse button
BEQ.B SureAnswerNo
BSR.W CheckPatternRedraw2
BSR.W DoKeyBuffer
MOVE.B RawKeyCode,D0
CMP.B #21,D0 ; Pressed Y
BEQ.W SureAnswerYes
CMP.B #68,D0 ; Pressed Return
BEQ.W SureAnswerYes
CMP.B #54,D0 ; Pressed N
BEQ.B SureAnswerNo
CMP.B #69,D0 ; Pressed Esc
BEQ.B SureAnswerNo
BTST #6,$BFE001 ; left mouse button
BNE.B surebuttoncheck
MOVE.W MouseX(PC),D0
MOVE.W MouseY(PC),D1
CMP.W #$AB,D0
BLO.B surebuttoncheck
CMP.W #$FC,D0
BHI.B surebuttoncheck
CMP.W #$48,D1
BLO.B surebuttoncheck
CMP.W #$52,D1
BHI.B surebuttoncheck
CMP.W #$C5,D0
BLO.B SureAnswerYes
CMP.W #$EA,D0
BLO.B surebuttoncheck
SureAnswerNo
LEA SureBoxData,A1
BSR.W SwapBoxMem
JSR ShowAllRight
BSR.W ClearAnaHeights
MOVE.B SaveDA,DisableAnalyzer
MOVE.B SaveScope,ScopeEnable
; --PT2.3D change: don't show busy mouse on 15 sample .mod loading
MOVE.L LastAreYouSureTextPtr(PC),A0
LEA Loadas31Text(PC),A1
CMP.L A0,A1
BEQ.B noBusyCursor
BSR.W ErrorRestoreCol
noBusyCursor
; ----------------------------------------------------------------
BSR.W WaitForButtonUp
BSR.W Wait_4000
CLR.B RawKeyCode
MOVEQ #-1,D0
SF AskBoxShown
RTS
CNOP 0,4
LastAreYouSureTextPtr dc.l 0
SureAnswerYes
LEA SureBoxData,A1
BSR.B SwapBoxMem
JSR ShowAllRight
BSR.W ClearAnaHeights
MOVE.B SaveDA,DisableAnalyzer
MOVE.B SaveScope,ScopeEnable
BSR.W RestorePtrCol
BSR.B WaitForButtonUp
BSR.W Wait_4000
CLR.B RawKeyCode
MOVEQ #0,D0
SF AskBoxShown
SF DisableScopeMuting
RTS
SwapBoxMem
LEA SureBoxPos,A0
MOVEQ #39-1,D0
ssbmloop1
MOVEQ #13-1,D1
ssbmloop2
MOVE.B 10240(A0),D2
MOVE.B 546(A1),10240(A0)
MOVE.B D2,546(A1)
MOVE.B (A0),D2
MOVE.B (A1),(A0)+
MOVE.B D2,(A1)+
DBRA D1,ssbmloop2
LEA $001B(A0),A0
ADDQ #1,A1
DBRA D0,ssbmloop1
LEA TextBitplane+2100,A0
LEA TextDataBuffer,A1
MOVEQ #39-1,D0
ssbmloop3
MOVEQ #13-1,D1
ssbmloop4
MOVE.B (A0),D2
MOVE.B (A1),(A0)+
MOVE.B D2,(A1)+
DBRA D1,ssbmloop4
LEA $1B(A0),A0
ADDQ #1,A1
DBRA D0,ssbmloop3
RTS
WaitForButtonUp
BTST #6,$BFE001 ; left mouse button
BEQ.B WaitForButtonUp
BTST #2,$DFF016 ; right mouse button
BEQ.B WaitForButtonUp
MOVE.W #$91,D0
WaitForVBlank
MOVE.L $DFF004,D1
LSR.L #8,D1
AND.W #$1FF,D1
CMP.W D1,D0
BNE.B WaitForVBlank
RTS
;---- Set Pointercolors ----
SetDeletePtrCol
MOVE.L A6,-(SP)
MOVE.L CopListColorPtr(PC),A6
MOVE.W #$0AA,2(A6)
MOVE.W #$077,6(A6)
MOVE.W #$044,10(A6)
MOVE.L (SP)+,A6
RTS
SetNormalPtrCol
MOVE.L A6,-(SP)
MOVE.L CopListColorPtr(PC),A6
MOVE.W #$0AAA,2(A6)
MOVE.W #$0777,6(A6)
MOVE.W #$0444,10(A6)
MOVE.L (SP)+,A6
RTS
SetDiskPtrCol
MOVE.L A6,-(SP)
MOVE.L CopListColorPtr(PC),A6
MOVE.W #$0A0,2(A6)
MOVE.W #$070,6(A6)
MOVE.W #$040,10(A6)
MOVE.L (SP)+,A6
RTS
SetPlayPtrCol
MOVE.L A6,-(SP)
MOVE.L CopListColorPtr(PC),A6
MOVE.W #$AA0,2(A6)
MOVE.W #$770,6(A6)
MOVE.W #$440,10(A6)
MOVE.L (SP)+,A6
RTS
SetEditPtrCol
MOVE.L A6,-(SP)
MOVE.L CopListColorPtr(PC),A6
MOVE.W #$05B,2(A6)
MOVE.W #$049,6(A6)
MOVE.W #$006,10(A6)
MOVE.L (SP)+,A6
RTS
SetWaitPtrCol
MOVE.L A6,-(SP)
MOVE.L CopListColorPtr(PC),A6
MOVE.W #$A5A,2(A6)
MOVE.W #$727,6(A6)
MOVE.W #$404,10(A6)
MOVE.L (SP)+,A6
RTS
SetErrorPtrCol
MOVE.L A6,-(SP)
MOVE.L CopListColorPtr(PC),A6
MOVE.W #$C00,2(A6)
MOVE.W #$900,6(A6)
MOVE.W #$700,10(A6)
MOVE.L (SP)+,A6
ST UpdateFreeMem
BSR.B WaitALittle
JSR ShowAllRight
BSR.W SetNormalPtrCol
SF DisableScopeMuting ; kludge
MOVEQ #0,D0
RTS
WaitALittle
MOVEQ #0,D1
MOVE.W WaitTime(PC),D1
BNE.B WaitD1
MOVEQ #1,D1
WaitD1 AND.L #$FFFF,D1 ; 8bb: just in case...
MOVEM.L D0/A0-A1/A6,-(SP)
MOVE.L DOSBase,A6
JSR _LVODelay(A6)
MOVEM.L (SP)+,D0/A0-A1/A6
MOVE.W #ERR_WAIT_TIME,WaitTime
RTS
WaitTime dc.w ERR_WAIT_TIME
StorePtrCol
MOVE.L A6,-(SP)
MOVE.L CopListColorPtr(PC),A6
MOVE.W 2(A6),PointerCol1Save
MOVE.W 6(A6),PointerCol2Save
MOVE.W 10(A6),PointerCol3Save
MOVE.L (SP)+,A6
RTS
ErrorRestoreCol
BSR.W SetErrorPtrCol
RestorePtrCol
MOVE.L A6,-(SP)
ST UpdateFreeMem
MOVE.L CopListColorPtr(PC),A6
MOVE.W PointerCol1Save,2(A6)
MOVE.W PointerCol2Save,6(A6)
MOVE.W PointerCol3Save,10(A6)
MOVE.L (SP)+,A6
RTS
;---- Check special keys ----
CheckPlayKeys
MOVE.B RawKeyCode,D0
CMP.B #101,D0
BEQ.W PlaySong
CMP.B #103,D0
BEQ.W PlayPattern
CMP.B #64,D0
BNE.B cpkskip
TST.L RunMode
BNE.W StopIt
TST.L EditMode
BNE.W StopIt
BRA.W Edit
cpkskip
CMP.B #97,D0
BEQ.W RecordPattern
CMP.B #69,D0
BEQ.W EscPressed
CMP.B #66,D0
BEQ.W TabulateCursor
;CMP.B #127,D0 (8bb: probably broke in PT2.3...)
;BEQ.W GotoCLI
CMP.B #48,D0
BEQ.W TurnOffVoices
CMP.B #42,D0
BEQ.W DecAutoInsSlot
CMP.B #43,D0
BEQ.W IncAutoInsSlot
CMP.B #60,D0
BEQ.W KillSample
CMP.B #13,D0
BEQ.W togglepnote
CMP.B #67,D0
BEQ.B ToggleHiLoInstr
MOVE.W HiLowInstr,D1
LEA kpinstable(PC),A0
MOVEQ #0,D2
kpinsloop
CMP.B (A0,D2.W),D0
BEQ.B kpinsfound
ADDQ.W #1,D2
CMP.W #16,D2
BLO.B kpinsloop
RTS
kpinsfound
ADD.W D2,D1
BEQ.B insnull
BRA.B redrsa2
ToggleHiLoInstr
BCHG #4,HiLowInstr+1
MOVE.W InsNum,D1
BCHG #4,D1
BRA.B redrsa2
ShiftOn
MOVE.W #1,ShiftKeyStatus
RTS
redrsa3 MOVE.W D1,InsNum
redrsam CLR.B RawKeyCode
CLR.L SavSamInf
JSR ShowSampleInfo
JMP RedrawSample
insnull TST.W InsNum
BEQ.B insnul2
MOVE.W InsNum,LastInsNum
CLR.W InsNum
MOVEQ #0,D1
BRA.B redrsa2
insnul2 JMP ShowSampleInfo
kpinstable
dc.b 15,90,91,92
dc.b 93,61,62,63,74
dc.b 45,46,47,94,29,30
dc.b 31
EVEN
redrsa2
TST.B pnoteflag
BEQ.B redrsa3
CLR.B RawKeyCode
TST.W AltKeyStatus
BNE.B setpnote
MOVE.W D1,InsNum
JSR ShowSampleInfo
MOVE.W InsNum,D0
ADD.W D0,D0
MOVE.W pnotetable(PC,D0.W),D0
MOVEQ #-1,D2
BSR.W playtheinstr
JMP RedrawSample
pnotetable
dc.w 24,24,24,24,24,24,24,24,24,24
dc.w 24,24,24,24,24,24,24,24,24,24
dc.w 24,24,24,24,24,24,24,24,24,24
dc.w 24,24
setpnote
ADD.W D1,D1
LEA pnotetable(PC,D1.W),A0
MOVE.L A0,SplitAddress
MOVE.W #4,SamNoteType
LEA SelectNoteText(PC),A0
JMP ShowStatusText
SelectNoteText dc.b "select note",0
EVEN
togglepnote
CLR.B RawKeyCode
MOVEQ #0,D0
MOVE.B pnoteflag(PC),D0
ADDQ.B #1,D0
CMP.B #3,D0
BLO.B tpnskp
MOVEQ #0,D0
tpnskp MOVE.B D0,pnoteflag
LEA pnotechar(PC,D0.W),A0
MOVEQ #1,D0
MOVE.W #5159,D1
JMP ShowText3
pnotechar dc.b 32,128,129
pnoteflag dc.b 0
EVEN
;---- Check transpose keys ----
CheckTransKeys
TST.W LeftAmigaStatus
BEQ.W Return1
MOVE.W PattCurPos,D0
BSR.W GetPositionPtr
MOVE.B RawKeyCode,D1
CLR.B RawKeyCode
MOVE.B SampleAllFlag(PC),-(SP)
BSR.B ctksub
MOVE.B (SP)+,SampleAllFlag
RTS
ctksub MOVEQ #0,D0
SF SampleAllFlag
CMP.B #1,D1
BEQ.W NoteUp
CMP.B #16,D1
BEQ.W NoteDown
CMP.B #32,D1
BEQ.W OctaveUp
CMP.B #49,D1
BEQ.W OctaveDown
MOVE.W #300,D0
CMP.B #2,D1
BEQ.W NoteUp
CMP.B #17,D1
BEQ.W NoteDown
CMP.B #33,D1
BEQ.W OctaveUp
CMP.B #50,D1
BEQ.W OctaveDown
MOVEQ #0,D0
ST SampleAllFlag
CMP.B #3,D1
BEQ.W NoteUp
CMP.B #18,D1
BEQ.W NoteDown
CMP.B #34,D1
BEQ.W OctaveUp
CMP.B #51,D1
BEQ.W OctaveDown
MOVE.W #300,D0
CMP.B #4,D1
BEQ.W NoteUp
CMP.B #19,D1
BEQ.W NoteDown
CMP.B #35,D1
BEQ.W OctaveUp
CMP.B #52,D1
BEQ.W OctaveDown
RTS
;---- Check control keys ----
CheckCtrlKeys
TST.W CtrlKeyStatus
BEQ.W Return1
MOVEQ #0,D0
MOVE.B RawKeyCode,D0
CMP.B #35,D0 ; F
BEQ.W ToggleFilter
CMP.B #33,D0 ; S
BEQ.W ToggleSplit
CMP.B #55,D0 ; M
BEQ.W ToggleMultiMode
CMP.B #16,D0 ; Q
BEQ.W UnmuteAll
CMP.B #32,D0 ; A
BEQ.W ToggleMute
CMP.B #49,D0 ; Z
BEQ.W RestoreEffects
CMP.B #19,D0 ; R
BEQ.W RestoreFKeyPos
CMP.B #20,D0 ; T
BEQ.W SwapTrack
CMP.B #53,D0 ; B
BEQ.W BeginBlock
CMP.B #51,D0 ; C
BEQ.W CopyBlock
CMP.B #50,D0 ; X
BEQ.W CutBlock
CMP.B #34,D0 ; D
BEQ.W DeleteBlock
CMP.B #25,D0 ; P
BEQ.W PasteBlock
CMP.B #23,D0 ; I
BEQ.W InsertBlock
CMP.B #38,D0 ; J
BEQ.W JoinPasteBlock
CMP.B #54,D0 ; N
BEQ.W Re_MarkBlock
CMP.B #21,D0 ; Y
BEQ.W BackwardsBlock
CMP.B #17,D0 ; W
BEQ.W PolyphonizeBlock
CMP.B #18,D0 ; E
BEQ.W ExpandTrack
CMP.B #24,D0 ; O
BEQ.W ContractTrack
CMP.B #37,D0 ; H
BEQ.W TransBlockUp
CMP.B #40,D0 ; L
BEQ.W TransBlockDown
CMP.B #39,D0 ; K
BEQ.W KillToEndOfTrack
CMP.B #22,D0 ; U
BEQ.W UndoLastChange
CMP.B #68,D0 ; CR
BEQ.W InsCmdTrack
CMP.B #65,D0 ; Del
BEQ.W DelCmdTrack
CMP.B #1,D0
BLO.W Return1
CMP.B #10,D0
BHI.W Return1
BNE.B cckskip
MOVEQ #0,D0
cckskip MOVE.W D0,EditMoveAdd
CLR.B RawKeyCode
ADD.B #'0',D0
LEA ematext(PC),A0
MOVE.B D0,11(A0)
JSR ShowStatusText
BSR.W Show_MS
MOVE.W #20,WaitTime
BSR.W WaitALittle
JMP ShowAllRight
ematext dc.b 'editskip = 0',0
EVEN
;---- Check alt keys ----
TogglePosEdScreen
CMP.W #3,CurrScreen
BEQ.W Return2 ; if Disk Op. is shown
BRA.W PosEd
ToggleRecMode
EOR.B #1,RecordMode
BEQ.B trmSkip
LEA RecSongText(PC),A0
BRA.B trmShow
trmSkip
LEA RecPattText(PC),A0
trmShow
JSR ShowStatusText
; update rec mode string in edit op. #2 (if shown)
CMP.W #1,CurrScreen
BNE.B trmEnd
CMP.B #2,EdScreen
BNE.B trmEnd
BSR.W ShowRecordMode
trmEnd
BSR.W WaitALittle
JSR ShowAllRight
RTS
RecPattText dc.b 'rec mode: patt',0
RecSongText dc.b 'rec mode: song',0
EVEN
CheckAltKeys
TST.W AltKeyStatus
BEQ.W Return1
MOVEQ #0,D0
MOVE.B RawKeyCode,D0
CMP.B #49,D0 ; Z
BEQ.W ToggleCh1
CMP.B #50,D0 ; X
BEQ.W ToggleCh2
CMP.B #51,D0 ; C
BEQ.W ToggleCh3
CMP.B #52,D0 ; V
BEQ.W ToggleCh4
CMP.B #53,D0 ; B
BEQ.B xBoost
CMP.B #35,D0 ; F
BEQ.B xFilter
CMP.B #20,D0 ; T
BEQ.B xTuningTone
CMP.B #33,D0 ; S
BEQ.B xSamplerScreen
CMP.B #19,D0 ; R
BEQ.B xResample
CMP.B #18,D0 ; E
BEQ.W DoEditOp
CMP.B #23,D0 ; I
BEQ.W AutoInsert
CMP.B #34,D0 ; D
BEQ.W DiskOp
CMP.B #39,D0 ; K
BEQ.W KillInstrTrack
CMP.B #32,D0 ; A
BEQ.B xSampler
CMP.B #16,D0 ; Q
BEQ.W ChkQuit
CMP.B #21,D0 ; Y
BEQ.W SaveAllSamples
CMP.B #55,D0 ; M
BEQ.W ToggleMetroFlag
CMP.B #25,D0 ; P (new in PT2.3E)
BEQ.W TogglePosEdScreen
CMP.B #36,D0 ; G (new in PT2.3E)
BEQ.W ToggleRecMode
RTS
xFilter JMP Filter
xBoost JMP Boost
xTuningTone JMP TuningTone
xSamplerScreen JMP SamplerScreen
xResample JMP Resample
xSampler JMP Sampler
;---- List Quick Jump Routines (SHIFT+alphanumeric) ----
CheckListQuickJump
TST.W AltKeyStatus
BNE.W Return1
TST.W CtrlKeyStatus
BNE.W Return1
TST.W LeftAmigaStatus
BNE.W Return1
TST.W ShiftKeyStatus
BEQ.W Return1
CMP.W #3,CurrScreen
BEQ.B DiskOpQuickJump
CMP.W #6,CurrScreen
BEQ.W PLSTQuickJump
CMP.W #4,CurrScreen
BEQ.W PEDQuickJump
RTS
GetASCIIKey
MOVEQ #0,D1
MOVE.B RawKeyCode,D1
BEQ.B gakskip
BTST #7,D1
BNE.B gakskip
LEA UnshiftedKeymap,A4
AND.W #$7F,D1
CMP.B #64,D1
BHI.B gakskip
MOVE.B (A4,D1.W),D1
CLR.B RawKeyCode
RTS
gakskip
MOVEQ #-1,D1
RTS
DiskOpQuickJump
BSR.B GetASCIIKey
BMI.W Return1
LEA FileNamesPtr(PC),A5
MOVE.L (A5),A1
MOVEQ #-36,D0
BSR.W lbC0039E8
doqjloop
ADD.L #36,D0
MOVE.W 16(A5),D2
SUBQ.W #8,D2
BMI.W Return1
MULU.W #36,D2
CMP.L D2,D0
BLS.B doqjskip
MOVE.L D2,D0
DIVU.W #36,D0
BSR.W RedrawFileNames
BRA.W ErrorRestoreCol
doqjskip
MOVE.B (A1,D0.L),D2
TST.W DirPathNum
BNE.B doqjskip2
CMP.L #'mod.',(A1,D0.L)
BNE.B doqjloop
MOVE.B 4(A1,D0.L),D2
doqjskip2
BSR.W lbC0039F0
CMP.B D1,D2
BNE.B doqjloop
DIVU.W #36,D0
BRA.W RedrawFileNames
PLSTQuickJump
BSR.W GetASCIIKey
BMI.W Return1
TST.W lbW010D56
BNE.W Return1
MOVE.L PLSTmem,A1
MOVEQ #-30,D0
BSR.W lbC0039E8
plstqjloop
ADD.L #30,D0
MOVE.W PresetMarkTotal,D2
SUB.W #12,D2
BMI.W Return1
MULU.W #30,D2
CMP.L D2,D0
BLS.B plstqjskip
MOVE.L D2,D0
DIVU.W #30,D0
JSR lbC010F82
BRA.W ErrorRestoreCol
plstqjskip
MOVE.B 6(A1,D0.L),D2
BSR.W lbC0039F0
CMP.B D1,D2
BNE.B plstqjloop
DIVU.W #30,D0
JMP lbC010F82
PEDQuickJump
BSR.W GetASCIIKey
BMI.W Return1
MOVE.L PLSTmem,A1
MOVEQ #-30,D0
pedqjloop
ADD.L #30,D0
MOVEQ #0,D2
MOVE.W PresetTotal,D2
SUB.W #10,D2
BMI.W Return1
MULU.W #30,D2
CMP.L D2,D0
BLS.B pedqjskip
MOVE.L D2,D0
DIVU.W #30,D0
JSR pdodsx
BRA.W ErrorRestoreCol
pedqjskip
MOVE.B 6(A1,D0.L),D2
CMP.B D1,D2
BNE.B pedqjloop
DIVU.W #30,D0
MOVE.W D0,PEDpos
JMP ShowPresetNames
;----
ToggleMetroFlag
CLR.B RawKeyCode
TST.W ShiftKeyStatus
BNE.B SetMetroChannel
EOR.B #1,MetroFlag
BRA.W Show_MS
SetMetroChannel
MOVEQ #0,D0
MOVE.W PattCurPos,D0
DIVU.W #6,D0
ADDQ.W #1,D0
MOVE.B D0,MetroChannel
CMP.W #1,CurrScreen
BNE.W Return1
TST.B EdEnable
BEQ.W Return1
CMP.B #2,EdScreen
BNE.W Return1
BRA.W ShowMetronome
AutoInsert
CLR.B RawKeyCode
EOR.B #1,AutoInsFlag
ShowAutoInsert
CMP.W #4,CurrScreen
BEQ.W Return1
MOVE.W #" ",D0
TST.B AutoInsFlag
BEQ.B auins2
MOVE.B #'I',D0
LSL.W #8,D0
MOVE.B AutoInsSlot,D0
ADD.B #'1',D0
CMP.B #'9'+1,D0
BNE.B auins2
MOVE.B #'0',D0
auins2 MOVE.W D0,AutoInsText
MOVE.W #4560,D1
MOVEQ #2,D0
LEA AutoInsText(PC),A0
JMP ShowText3
AutoInsText dc.w 0
AutoInsFlag dc.b 0
MetroFlag dc.b 0
EVEN
DecAutoInsSlot
CLR.B RawKeyCode
TST.B AutoInsFlag
BEQ.W Return1
MOVE.B AutoInsSlot,D0
SUBQ.B #1,D0
TST.W ShiftKeyStatus
BEQ.B daisskip
SUBQ.B #3,D0
daisskip
TST.B D0
BMI.B daisskip3
daisskip2
MOVE.B D0,AutoInsSlot
BRA.W Show_MS
daisskip3
MOVEQ #0,D0
BRA.B daisskip2
IncAutoInsSlot
CLR.B RawKeyCode
TST.B AutoInsFlag
BEQ.W Return1
MOVE.B AutoInsSlot,D0
ADDQ.B #1,D0
TST.W ShiftKeyStatus
BEQ.B iaisskip
ADDQ.B #3,D0
iaisskip
CMP.B #9,D0
BLE.B iaisskip2
MOVEQ #9,D0
iaisskip2
MOVE.B D0,AutoInsSlot
BRA.W Show_MS
SaveInstr dc.w 0
SaveAllSamples
LEA SaveAllSamplesText(PC),A0
BSR.W AreYouSure
BNE.B sarts
MOVE.W InsNum,SaveInstr
MOVE.W #1,InsNum
.loop JSR ShowSampleInfo
BSR.W dosavesample
ADDQ.W #1,InsNum
CMP.W #32,InsNum
BLO.B .loop
MOVE.W SaveInstr(PC),InsNum
JMP ShowSampleInfo
sarts
RTS
SaveAllSamplesText
dc.b "save all samples?",0
EVEN
;---- Jump between channels ----
TabulateCursor
CLR.B RawKeyCode
TST.W ShiftKeyStatus
BNE.B TabCurRight
MOVEQ #0,D0
MOVE.W PattCurPos,D0
DIVU.W #6,D0
ADDQ.W #1,D0
CMP.W #4,D0
BNE.B tacskip
MOVEQ #0,D0
tacskip MULU.W #6,D0
MOVE.W D0,PattCurPos
BRA.W UpdateCursorPos
TabCurRight
MOVEQ #0,D0
MOVE.W PattCurPos,D0
ADDQ.W #5,D0
DIVU.W #6,D0
SUBQ.W #1,D0
BPL.B tacskip
MOVEQ #3,D0
BRA.B tacskip
;---- Escape was pressed ----
EscPressed CLR.B RawKeyCode
CLR.B SaveKey
MOVE.W CurrScreen,D0
CMP.W #2,D0
BLO.B BotExit
TopExit MOVE.W CurrScreen,D0
CMP.W #2,D0
BEQ.W ExitHelpScreen
CMP.W #3,D0
BEQ.W ExitFromDir
CMP.W #4,D0
BEQ.B pedexit
CMP.W #5,D0
BEQ.W ExitSetup
CMP.W #6,D0
BEQ.B plstexit
CMP.W #7,D0
BEQ.W ExitSetup
CMP.W #8,D0
BEQ.B plstexit
RTS
BotExit TST.W SamScrEnable
BNE.B samplerexit
TST.W BlockMarkFlag
BNE.W blkunma
CMP.W #1,CurrScreen
BNE.W Return1
TST.B EdEnable
BNE.W ExitEditOp
RTS
samplerexit
JMP ExitFromSam
pedexit JMP PED_Exit
plstexit JMP ExitPLST
GotoCLI CLR.B RawKeyCode
CLR.B SaveKey
TST.L RunMode
BNE.B gcliskip
BSR.W StopIt
BSR.W ResetMusicInt
gcliskip BSR.W WorkbenchToFront
MOVE.L ExtCmdAddress(PC),D1
BEQ.B gcliskip2
CLR.L ExtCmdAddress
MOVE.L ExtCmdWindow(PC),D2
MOVEQ #0,D3
MOVE.L DOSBase,A6
JSR _LVOExecute(A6)
gcliskip2 ADDQ.B #1,LastRawkey
TST.L RunMode
BNE.B gcliskip3
BSR.W SetMusicInt
gcliskip3
BRA.W PTScreenToFront
;---- Check Help Key ----
HelpSelectText dc.b '* help selected *',0
PLSTSelectText dc.b '* plst selected *',0
PLSTHelpFlag dc.b 0 ; free 0
EVEN
CheckHelpKey
CMP.B #95,RawKeyCode ; Help Key pressed ?
BNE.W Return1
CLR.B RawKeyCode
TST.W ShiftKeyStatus
BEQ.B realhlp
LEA HelpSelectText(PC),A0
EOR.B #1,PLSTHelpFlag
BEQ.B chksel
LEA PLSTSelectText(PC),A0
chksel JSR ShowStatusText
BSR.W WaitALittle
JMP ShowAllRight
gtoPLST JMP PLST
realhlp TST.B PLSTHelpFlag
BNE.B gtoPLST
CMP.W #2,CurrScreen
BEQ.W ExitHelpScreen
BSR.W TopExit
MOVE.W CurrScreen,SaveCurrScreen
SF ScopeEnable
ST DisableAnalyzer
ST NoSampleInfo
BSR.W ClearAnalyzerColors
BSR.W SwapHelpScreen
BEQ.W exithlp
BSR.W Clear100Lines
TST.L HelpTextIndex+4
BNE.B chkskip
BSR.W GetHelpIndex
chkskip MOVE.L #HelpFileName,D1
MOVE.L #1005,D2
MOVE.L DOSBase,A6
JSR _LVOOpen(A6)
MOVE.L D0,FileHandle
BNE.W ShowHelpPage
LEA PTPath,A0
BSR.W CopyPath
LEA HelpFileName(PC),A0
MOVEQ #8-1,D0
hefilop MOVE.B (A0)+,(A1)+
DBRA D0,hefilop
MOVE.L #FileName,D1
MOVE.L #1005,D2
MOVE.L DOSBase,A6
JSR _LVOOpen(A6)
MOVE.L D0,FileHandle
BEQ.W HelpFileError
BRA.B ShowHelpPage
ExitHelpScreen
MOVE.L FileHandle,D1
BEQ.B ehsskip
MOVE.L DOSBase,A6
JSR _LVOClose(A6)
ehsskip BSR.W Clear100Lines
BSR.B SwapHelpScreen
exithlp MOVE.W SaveCurrScreen,CurrScreen
BRA.W DisplayMainAll
SwapHelpScreen
MOVE.L DecompMemPtr,D0
BEQ.B shelps2
MOVE.L D0,A1
BSR.W ssets3
BRA.W FreeDecompMem
shelps2 LEA HelpScreenData,A0
MOVE.L #HelpScreenSize,D0
BSR.W Decompact
BEQ.W Return1
ssets3
LEA BitplaneData,A0
MOVEQ #2-1,D2
sxloop1 MOVE.W #1000-1,D0
sxloop2 MOVE.L (A0),D1
MOVE.L (A1),(A0)+
MOVE.L D1,(A1)+
DBRA D0,sxloop2
LEA 6240(A0),A0
DBRA D2,sxloop1
RTS
ShowHelpPage
MOVE.W #2,CurrScreen
MOVE.W HelpPage(PC),D0
AND.W #$00FF,D0
LSL.W #2,D0
LEA HelpTextIndex,A0
MOVE.L FileHandle,D1
BEQ.W Return1
MOVE.L (A0,D0.W),D2
ADD.L #1024,D2
MOVEQ #-1,D3
MOVE.L DOSBase,A6
JSR _LVOSeek(A6)
MOVE.L FileHandle,D1
MOVE.L #HelpTextData,D2
MOVE.L #656,D3
JSR _LVORead(A6)
BSR.W Clear100Lines
LEA HelpTextData+16,A6
MOVEQ #120,D6
MOVEQ #16-1,D7
shploop MOVEQ #0,D0
MOVE.L A6,A1
shplop2 CMP.B #10,(A1)+
BEQ.B ShowHelpLine
TST.B -1(A1)
BEQ.B ShowHelpLine
ADDQ.W #1,D0
BRA.B shplop2
ShowHelpLine
MOVE.L A6,ShowTextPtr
MOVE.L A1,A6
MOVE.W D6,TextOffset
MOVE.W D0,TextLength
BEQ.B shlskip
JSR ShowText
shlskip ADD.W #240,D6
DBRA D7,shploop
BSR.W Wait_4000
BRA.W Wait_4000
HelpPage dc.w 1
HelpUp LEA HelpTextData+7,A0
BRA.B HelpMove
HelpDown
LEA HelpTextData+10,A0
BRA.B HelpMove
HelpLeft
LEA HelpTextData+4,A0
BRA.B HelpMove
HelpRight
LEA HelpTextData+13,A0
HelpMove CLR.B RawKeyCode
MOVEQ #0,D0
JSR HexToInteger2
TST.W D0
BEQ.W Return1
AND.W #$00FF,D0
MOVE.W D0,HelpPage
BRA.W ShowHelpPage
GetHelpIndex
MOVE.L LaHeTx,D0
CMP.L HelpTextIndex,D0
BEQ.W Return1
MOVE.L #HelpFileName,D1
MOVE.L #1005,D2
MOVE.L DOSBase,A6
JSR _LVOOpen(A6)
MOVE.L D0,FileHandle
BNE.B gehein
LEA PTPath,A0
BSR.W CopyPath
LEA HelpFileName(PC),A0
MOVEQ #8-1,D0
hefilp2 MOVE.B (A0)+,(A1)+
DBRA D0,hefilp2
MOVE.L #FileName,D1
MOVE.L #1005,D2
MOVE.L DOSBase,A6
JSR _LVOOpen(A6)
MOVE.L D0,FileHandle
BEQ.B HelpFileError
gehein MOVE.L D0,D1
MOVE.L #HelpTextIndex,D2
MOVE.L #256*4,D3
JSR _LVORead(A6)
MOVE.L FileHandle,D1
JSR _LVOClose(A6)
MOVE.L HelpTextIndex,LaHeTx
RTS
HelpFileError
MOVE.W #2,CurrScreen
LEA NoHelpText(PC),A0
MOVE.W #1887,D1
MOVEQ #24,D0
JMP ShowText3
NoHelpText dc.b 'Unable to open helpfile!'
HelpFileName dc.b 'PT.help',0
EVEN
;---- Check Function Keys F6-F10 ----
CheckF6_F10
CMP.B #85,RawKeyCode
BNE.B CheckF7
CLR.B RawKeyCode
TST.W ShiftKeyStatus
BEQ.B cf6skip
MOVE.W ScrPattPos,F6pos
ShowPosSetText LEA PosSetText,A0
JSR ShowStatusText
MOVEQ #9-1,D2
spsloop BSR.W Wait_4000
DBRA D2,spsloop
JMP ShowAllRight
cf6skip MOVE.W F6pos(PC),D0
chkalt TST.W AltKeyStatus
BNE.W PattFrom
TST.W CtrlKeyStatus
BNE.W RecordFrom
TST.W LeftAmigaStatus
BNE.W SongFrom
TST.W RunMode
BNE.W Return1
MOVE.W D0,ScrPattPos
BRA.W SetScrPatternPos
CheckF7 CMP.B #86,RawKeyCode
BNE.B CheckF8
CLR.B RawKeyCode
TST.W ShiftKeyStatus
BEQ.B cf7skip
MOVE.W ScrPattPos,F7pos
BRA.B ShowPosSetText
cf7skip MOVE.W F7pos(PC),D0
BRA.B chkalt
CheckF8 CMP.B #87,RawKeyCode
BNE.B CheckF9
CLR.B RawKeyCode
TST.W ShiftKeyStatus
BEQ.B cf8skip
MOVE.W ScrPattPos,F8pos
BRA.W ShowPosSetText
cf8skip MOVE.W F8pos(PC),D0
BRA.W chkalt
CheckF9 CMP.B #88,RawKeyCode
BNE.B CheckF10
CLR.B RawKeyCode
TST.W ShiftKeyStatus
BEQ.B cf9skip
MOVE.W ScrPattPos,F9pos
BRA.W ShowPosSetText
cf9skip MOVE.W F9pos(PC),D0
BRA.W chkalt
CheckF10
CMP.B #89,RawKeyCode
BNE.W Return1
CLR.B RawKeyCode
TST.W ShiftKeyStatus
BEQ.B cf10skip
MOVE.W ScrPattPos,F10pos
BRA.W ShowPosSetText
cf10skip MOVE.W F10pos(PC),D0
BRA.W chkalt
F6pos dc.w 0
F7pos dc.w 16
F8pos dc.w 32
F9pos dc.w 48
F10pos dc.w 63
;---- Check Function Keys F3-F5 ----
CheckF3_F5
MOVEQ #0,D0
MOVE.L D0,A0
TST.W ShiftKeyStatus
BNE.W CCP4
TST.W CtrlKeyStatus
BNE.W CCP4
TST.W AltKeyStatus
BNE.W CutCopPas
CMP.B #68,RawKeyCode
BEQ.B StepPlayForward
CMP.B #65,RawKeyCode
BEQ.B StepPlayBackward
TST.W SamScrEnable
BEQ.W Return1
CMP.B #82,RawKeyCode
BEQ.B xSamCut
CMP.B #83,RawKeyCode
BEQ.B xSamCop
CMP.B #84,RawKeyCode
BEQ.B xSamPas
RTS
xSamCut JMP SamCut
xSamCop JMP SamCopy
xSamPas JMP SamPaste
StepPlayForward
MOVE.W #1,StepPlayEnable
BSR.W DoStopIt
MOVE.W ScrPattPos,D0
BSR.W pafr1
spfloop
BSR.W Wait_4000
TST.W StepPlayEnable
BNE.B spfloop
BRA.W SetScrPatternPos
StepPlayBackward
MOVE.W #1,StepPlayEnable
BSR.W DoStopIt
MOVE.W ScrPattPos,D0
BSR.W pafr1
spbloop
BSR.W Wait_4000
TST.W StepPlayEnable
BNE.B spbloop
MOVE.W ScrPattPos,D0
SUBQ.W #2,D0
AND.W #63,D0
MOVE.W D0,ScrPattPos
BRA.W SetScrPatternPos
StepPlayEnable dc.w 0
CCP4 MOVEQ #0,D0
MOVE.W PattCurPos,D0
DIVU.W #6,D0
AND.L #3,D0
LSL.L #2,D0
MOVE.L D0,A0
CutCopPas
ADD.L SongDataPtr,A0
LEA sd_patterndata(A0),A0
MOVE.L PatternNumber,D0
LSL.L #8,D0
LSL.L #2,D0
ADD.L D0,A0
TST.W AltKeyStatus
BNE.B CutCopPasPatt
TST.W CtrlKeyStatus
BNE.B CutCopPasCmds
CutCopPasTrack
CMP.B #82,RawKeyCode
BEQ.W CutTrack
CMP.B #83,RawKeyCode
BEQ.W CopyTrack
CMP.B #84,RawKeyCode
BEQ.W PasteTrack
CMP.B #68,RawKeyCode
BEQ.W InsNoteTrack
CMP.B #65,RawKeyCode
BEQ.W DelNoteTrack
RTS
CutCopPasPatt
CMP.B #82,RawKeyCode
BEQ.B CutPattern
CMP.B #83,RawKeyCode
BEQ.B CopyPattern
CMP.B #84,RawKeyCode
BEQ.B PastePattern
CMP.B #68,RawKeyCode
BEQ.W InsNotePattern
CMP.B #65,RawKeyCode
BEQ.W DelNotePattern
RTS
CutCopPasCmds
CMP.B #82,RawKeyCode
BEQ.W CutCmds
CMP.B #83,RawKeyCode
BEQ.W CopyCmds
CMP.B #84,RawKeyCode
BEQ.W PasteCmds
RTS
CutPattern
BSR.W SaveUndo
LEA PatternBuffer,A1
MOVE.W #256-1,D0
MOVEQ #0,D1
cupaloop
MOVE.L (A0),(A1)+
MOVE.L D1,(A0)+
DBRA D0,cupaloop
CLR.B RawKeyCode
JMP RedrawPattern
CopyPattern
LEA PatternBuffer,A1
MOVE.W #256-1,D0
copaloop
MOVE.L (A0)+,(A1)+
DBRA D0,copaloop
CLR.B RawKeyCode
RTS
PastePattern
BSR.W SaveUndo
LEA PatternBuffer,A1
MOVE.W #256-1,D0
papaloop
MOVE.L (A1)+,(A0)+
DBRA D0,papaloop
CLR.B RawKeyCode
JMP RedrawPattern
CutTrack
BSR.W SaveUndo
LEA TrackBuffer,A1
MOVEQ #64-1,D0
MOVEQ #0,D1
cutrloop
MOVE.L (A0),(A1)+
MOVE.L D1,(A0)
LEA 16(A0),A0
DBRA D0,cutrloop
CLR.B RawKeyCode
JMP RedrawPattern
CopyTrack
LEA TrackBuffer,A1
MOVEQ #64-1,D0
cotrloop
MOVE.L (A0),(A1)+
LEA 16(A0),A0
DBRA D0,cotrloop
CLR.B RawKeyCode
RTS
PasteTrack
BSR.W SaveUndo
LEA TrackBuffer,A1
MOVEQ #64-1,D0
patrloop
MOVE.L (A1)+,(A0)
LEA 16(A0),A0
DBRA D0,patrloop
CLR.B RawKeyCode
JMP RedrawPattern
InsNotePattern
BSR.W SaveUndo
MOVEQ #0,D0
BSR.W GetPositionPtr
BSR.B inotr
MOVEQ #6,D0
BSR.W GetPositionPtr
BSR.B inotr
MOVEQ #12,D0
BSR.W GetPositionPtr
BSR.B inotr
MOVEQ #18,D0
BSR.W GetPositionPtr
BSR.B inotr
BRA.B intskip
InsNoteTrack
BSR.W SaveUndo
BSR.B inotr
intskip CLR.B RawKeyCode
ADD.W D2,ScrPattPos
AND.W #$3F,ScrPattPos
BSR.W SetScrPatternPos
JMP RedrawPattern
inotr MOVE.W ScrPattPos,D1
LSL.W #4,D1
CMP.W #63*16,D1
BEQ.B inoskip
MOVE.W #992,D0
intloop MOVE.L (A0,D0.W),16(A0,D0.W)
SUB.W #16,D0
CMP.W D1,D0
BGE.B intloop
inoskip MOVEQ #1,D2
CLR.L (A0,D1.W)
RTS
InsCmdTrack
BSR.W SaveUndo
MOVE.W PattCurPos,D0
BSR.W GetPositionPtr
BSR.B icmtr
BRA.B intskip
icmtr
MOVE.W ScrPattPos,D1
LSL.W #4,D1
CMP.W #63*16,D1
BEQ.B icmskip
MOVE.W #992,D0
icmloop MOVE.W 2(A0,D0.W),D2
AND.W #$0FFF,D2
AND.W #$F000,18(A0,D0.W)
OR.W D2,18(A0,D0.W)
SUB.W #16,D0
CMP.W D1,D0
BGE.B icmloop
icmskip MOVEQ #1,D2
AND.W #$F000,2(A0,D1.W)
RTS
DelNotePattern
BSR.W SaveUndo
MOVEQ #0,D0
BSR.W GetPositionPtr
BSR.B dnt
MOVEQ #6,D0
BSR.W GetPositionPtr
BSR.B dnt
MOVEQ #12,D0
BSR.W GetPositionPtr
BSR.B dnt
MOVEQ #18,D0
BSR.W GetPositionPtr
BSR.B dnt
BRA.W intskip
DelNoteTrack
BSR.W SaveUndo
BSR.B dnt
BRA.W intskip
dnt MOVE.W ScrPattPos,D0
BEQ.W Return1
SUBQ.W #1,D0
LSL.W #4,D0
dntloop MOVE.L 16(A0,D0.W),(A0,D0.W)
ADD.W #16,D0
CMP.W #1024,D0
BLO.B dntloop
MOVE.W #1008,D1
MOVEQ #-1,D2
CLR.L (A0,D1.W)
RTS
DelCmdTrack
BSR.W SaveUndo
MOVE.W PattCurPos,D0
BSR.W GetPositionPtr
BSR.B dct
BRA.W intskip
dct MOVE.W ScrPattPos,D0
BEQ.W Return1
SUBQ.W #1,D0
LSL.W #4,D0
dctloop MOVE.W 18(A0,D0.W),D2
AND.W #$0FFF,D2
AND.W #$F000,2(A0,D0.W)
OR.W D2,2(A0,D0.W)
ADD.W #16,D0
CMP.W #1024,D0
BLO.B dctloop
MOVE.W #1008,D1
MOVEQ #-1,D2
AND.W #$F000,2(A0,D1.W)
RTS
CutCmds BSR.W SaveUndo
LEA CmdsBuffer,A1
CLR.W D0
cucmloop
MOVE.L (A0,D0.W),(A1)+
AND.L #$FFFFF000,(A0,D0.W)
ADD.W #16,D0
CMP.W #1024,D0
BNE.B cucmloop
CLR.B RawKeyCode
JMP RedrawPattern
CopyCmds
LEA CmdsBuffer,A1
CLR.W D0
cocmloop
MOVE.L (A0,D0.W),(A1)+
ADD.W #16,D0
CMP.W #1024,D0
BNE.B cocmloop
CLR.B RawKeyCode
RTS
PasteCmds
BSR.W SaveUndo
LEA CmdsBuffer,A1
CLR.W D0
pacmloop
MOVE.L (A0,D0.W),D1
AND.L #$FFFFF000,D1
MOVE.L (A1)+,D2
AND.L #$00000FFF,D2
OR.L D2,D1
MOVE.L D1,(A0,D0.W)
ADD.W #16,D0
CMP.W #1024,D0
BNE.B pacmloop
CLR.B RawKeyCode
JMP RedrawPattern
;---- Swap Tracks ----
SwapTrack
BSR.W StorePtrCol
BSR.W SetWaitPtrCol
LEA SwapTrackText(PC),A0
JSR ShowStatusText
swtloop BSR.W GetHexKey
CMP.B #128,D1
BEQ.B swtabor
TST.B D1
BEQ.B swtabor
CMP.B #4,D1
BHI.B swtloop
BSR.W SaveUndo
SUBQ.L #1,D1
LSL.L #2,D1
MOVE.L D1,D0
MOVE.L SongDataPtr,A0
LEA sd_patterndata(A0),A0
MOVE.L PatternNumber,D1
LSL.L #8,D1
LSL.L #2,D1
ADD.L D1,A0
MOVE.L A0,A1
ADD.L D0,A0
MOVEQ #0,D0
MOVE.W PattCurPos,D0
DIVU.W #6,D0
AND.L #$F,D0
LSL.L #2,D0
ADD.L D0,A1
MOVEQ #64-1,D1
swtloop2
MOVE.L (A0),D0
MOVE.L (A1),(A0)
MOVE.L D0,(A1)
LEA 16(A0),A0
LEA 16(A1),A1
DBRA D1,swtloop2
JSR RedrawPattern
swtabor JSR ShowAllRight
BRA.W RestorePtrCol
SwapTrackText dc.b 'Swap (1/2/3/4) ?',0
EVEN
;---- Block Commands ----
BlockFromPos dc.w 0
BlockToPos dc.w 0
BlockMarkFlag dc.w 0
BlockBufferFlag dc.w 0
JoinPasteFlag dc.w 0
PolyPasteFlag dc.w 0
BuffFromPos dc.w 0
BuffToPos dc.w 0
BlockMarkText dc.b 'mark block 00-00',0
BlockErrorText dc.b 'no block marked !',0
BufEmptyText dc.b 'buffer is empty !',0
EVEN
BeginBlock
CLR.B RawKeyCode
TST.W BlockMarkFlag
BEQ.B beblskp
blkunma CLR.W BlockMarkFlag
JMP ShowAllRight
beblskp MOVE.W #1,BlockMarkFlag
MOVE.W ScrPattPos,BlockFromPos
MOVE.W ScrPattPos,BlockToPos
ShowBlockPos
MOVE.W BlockFromPos(PC),D0
MOVE.W BlockToPos(PC),D1
CMP.W D0,D1
BHS.B sbpskip
EXG D0,D1
sbpskip LEA BlockMarkText+12(PC),A0
BSR.B IntTo2DecAscii
LEA BlockMarkText+15(PC),A0
MOVE.W D1,D0
BSR.B IntTo2DecAscii
LEA BlockMarkText(PC),A0
JMP ShowStatusText
Re_MarkBlock
CLR.B RawKeyCode
MOVE.W #1,BlockMarkFlag
MOVE.W BlockToPos(PC),ScrPattPos
BSR.W SetScrPatternPos
BRA.B ShowBlockPos
CheckBlockPos
TST.W BlockMarkFlag
BEQ.W Return1
MOVE.W ScrPattPos,D0
CMP.W BlockToPos(PC),D0
BEQ.W Return1
MOVE.W D0,BlockToPos
BRA.B ShowBlockPos
IntTo2DecAscii
AND.L #$FF,D0
DIVU.W #10,D0
ADD.B #'0',D0
MOVE.B D0,-1(A0)
SWAP D0
ADD.B #'0',D0
MOVE.B D0,(A0)
RTS
CutBlock
; --PT2.3D change: CTRL+X = sample data cut in sampler screen
TST.W SamScrEnable
BNE.W xSamCut
; -----------------------------------------------------------
CLR.B RawKeyCode
TST.W BlockMarkFlag
BEQ.W BlockError
BSR.B cobldo
MOVE.W #1,BlockMarkFlag
BRA.W ClearBlock
CopyBlock
; --PT2.3D change: CTRL+C = sample data copy in sampler screen
TST.W SamScrEnable
BNE.W xSamCop
; ------------------------------------------------------------
CLR.B RawKeyCode
TST.W BlockMarkFlag
BEQ.W BlockError
cobldo CLR.W BlockMarkFlag
MOVE.W #1,BlockBufferFlag
MOVE.W PattCurPos,D0
BSR.W GetPositionPtr
LEA BlockBuffer,A1
MOVEQ #64-1,D0
cobllop MOVE.L (A0),(A1)
LEA 16(A0),A0
LEA 16(A1),A1
DBRA D0,cobllop
MOVE.W BlockFromPos(PC),D0
MOVE.W BlockToPos(PC),D1
CMP.W D0,D1
BHS.B coblskp
EXG D0,D1
coblskp MOVE.W D0,BuffFromPos
MOVE.W D1,BuffToPos
JMP ShowAllRight
PasteBlock
CLR.B RawKeyCode
TST.W BlockBufferFlag
BEQ.W BufferError
BSR.W SaveUndo
MOVE.W PattCurPos,D0
BSR.W GetPositionPtr
LEA BlockBuffer,A1
MOVE.W BuffFromPos(PC),D0
MOVE.W BuffToPos(PC),D1
MOVE.W ScrPattPos,D2
LSL.W #4,D0
LSL.W #4,D1
LSL.W #4,D2
pabllop MOVE.L (A1,D0.W),D3
TST.W JoinPasteFlag
BEQ.B pablskp
MOVE.L D3,D4
AND.L #$FFFFF000,D4
BNE.B pablskp
MOVE.L (A0,D2.W),D4
AND.L #$FFFFF000,D4
AND.L #$00000FFF,D3
OR.L D4,D3
pablskp MOVE.L D3,(A0,D2.W)
CMP.W D0,D1
BEQ.B pablend
CMP.W #63*16,D0
BEQ.B pablend
CMP.W #63*16,D2
BEQ.B pablend
ADD.W #16,D0
ADD.W #16,D2
TST.W PolyPasteFlag
BEQ.B pabllop
MOVEM.L D0-D2/A1,-(SP)
BSR.W GotoNextMulti
MOVE.W PattCurPos,D0
BSR.W GetPositionPtr
MOVEM.L (SP)+,D0-D2/A1
BRA.B pabllop
pablend CLR.W JoinPasteFlag
CLR.W PolyPasteFlag
JSR ShowAllRight
JSR RedrawPattern
TST.W ShiftKeyStatus
BNE.W Return1
MOVE.W BuffToPos(PC),D0
SUB.W BuffFromPos(PC),D0
ADDQ.W #1,D0
ADD.W ScrPattPos,D0
CMP.W #63,D0
BLS.B pablset
MOVEQ #0,D0
pablset MOVE.W D0,ScrPattPos
BRA.W SetScrPatternPos
PolyphonizeBlock
MOVE.W #1,PolyPasteFlag
JoinPasteBlock
MOVE.W #1,JoinPasteFlag
BRA.W PasteBlock
InsertBlock CLR.B RawKeyCode
TST.W BlockBufferFlag
BEQ.W BufferError
CMP.W #63,ScrPattPos
BEQ.W PasteBlock
MOVE.W BuffToPos(PC),D0
SUB.W BuffFromPos(PC),D0
inbllop MOVE.L D0,-(SP)
MOVE.W PattCurPos,D0
BSR.W GetPositionPtr
BSR.W inotr
MOVE.L (SP)+,D0
DBRA D0,inbllop
BRA.W PasteBlock
DeleteBlock
CLR.B RawKeyCode
TST.W BlockMarkFlag
BEQ.W BlockError
BSR.W SaveUndo
MOVE.W BlockFromPos(PC),D0
MOVE.W BlockToPos(PC),D1
CMP.W D0,D1
BHS.B deblskp
EXG D0,D1
deblskp CMP.W #63,D1
BEQ.B ClearBlock
CLR.W BlockMarkFlag
MOVE.W D0,ScrPattPos
ADDQ.W #1,ScrPattPos
SUB.W D0,D1
MOVE.W D1,D0
debllop MOVE.L D0,-(SP)
MOVE.W PattCurPos,D0
BSR.W GetPositionPtr
BSR.W dnt
MOVE.L (SP)+,D0
DBRA D0,debllop
SUBQ.W #1,ScrPattPos
JSR ShowAllRight
JMP RedrawPattern
ClearBlock
TST.W BlockMarkFlag
BEQ.W BlockError
BSR.W SaveUndo
CLR.W BlockMarkFlag
MOVE.W PattCurPos,D0
BSR.W GetPositionPtr
MOVE.W BlockFromPos(PC),D0
MOVE.W BlockToPos(PC),D1
CMP.W D0,D1
BHS.B clblskp
EXG D0,D1
clblskp LSL.W #4,D0
LSL.W #4,D1
MOVEQ #0,D2
clbllop MOVE.L D2,(A0,D0.W)
CMP.W D0,D1
BEQ.B clblend
ADD.W #16,D0
BRA.B clbllop
clblend JSR ShowAllRight
JMP RedrawPattern
; inverts the pattern data (prepares it for backwards play hack)
CheckPatternInvertKeys
TST.W CtrlKeyStatus
BEQ.W Return1
TST.W AltKeyStatus
BEQ.W Return1
TST.W ShiftKeyStatus
BEQ.W Return1
TST.W LeftAmigaStatus
BEQ.W Return1
MOVE.B RawKeyCode,D0
CMP.B #70,D0 ; DEL
BNE.W Return1
CLR.B RawKeyCode
BSR.W StorePtrCol
MOVE.L PatternNumber,D3
MOVE.W PattCurPos,D4
MOVE.L #0,PatternNumber
.loop1 CLR.W PattCurPos
.loop2 MOVE.W PattCurPos,D0
BSR.W GetPositionPtr
CLR.W D0
MOVE.W #$3F0,D1
BSR.W babllop
ADDQ.W #6,PattCurPos
CMP.W #24,PattCurPos
BNE.B .loop2
TST.W NumPatterns
BEQ.B .skip
ADDQ.L #1,PatternNumber
MOVE.L PatternNumber,D0
CMP.W NumPatterns,D0
BNE.B .loop1
.skip BSR.W RestorePtrCol
MOVE.L D3,PatternNumber
MOVE.W D4,PattCurPos
JSR RedrawPattern
RTS
BackwardsBlock
CLR.B RawKeyCode
TST.W BlockMarkFlag
BEQ.W BlockError
BSR.W SaveUndo
CLR.W BlockMarkFlag
MOVE.W PattCurPos,D0
BSR.W GetPositionPtr
MOVE.W BlockFromPos(PC),D0
MOVE.W BlockToPos(PC),D1
CMP.W D0,D1
BHS.B bablskp
EXG D0,D1
bablskp LSL.W #4,D0
LSL.W #4,D1
babllop MOVE.L (A0,D0.W),D2
MOVE.L (A0,D1.W),(A0,D0.W)
MOVE.L D2,(A0,D1.W)
CMP.W D1,D0
BHS.B bablend
ADD.W #16,D0
SUB.W #16,D1
CMP.W D1,D0
BHS.B bablend
BRA.B babllop
bablend JSR ShowAllRight
JMP RedrawPattern
TransBlockUp
SF trblflag
BRA.B trbldo
TransBlockDown
ST trblflag
trbldo CLR.B RawKeyCode
TST.W BlockMarkFlag
BEQ.B BlockError
BSR.W SaveUndo
MOVE.W #2,NoteShift
MOVE.W BlockFromPos(PC),D0
MOVE.W BlockToPos(PC),D1
CMP.W D0,D1
BHS.B trblskp
EXG D0,D1
trblskp MOVE.W D0,D5
LSL.W #4,D5
SUB.W D0,D1
MOVE.W D1,D6
MOVE.W PattCurPos,D0
BSR.W GetPositionPtr
LEA (A0,D5.W),A3
MOVEQ #0,D3
MOVE.B SampleAllFlag(PC),sampallsave
ST SampleAllFlag
TST.B trblflag
BEQ.B trblup
BSR.W sandlo2
MOVE.B sampallsave(PC),SampleAllFlag
JMP RedrawPattern
trblup BSR.W sanulo2
MOVE.B sampallsave(PC),SampleAllFlag
JMP RedrawPattern
trblflag dc.b 0
sampallsave dc.b 0
EVEN
BlockError
LEA BlockErrorText(PC),A0
JSR ShowStatusText
BRA.W SetErrorPtrCol
BufferError
LEA BufEmptyText(PC),A0
JSR ShowStatusText
BRA.W SetErrorPtrCol
ExpandTrack
CLR.B RawKeyCode
BSR.W SaveUndo
MOVE.W ScrPattPos,PosSave
ADDQ.W #1,ScrPattPos
CMP.W #64,ScrPattPos
BHS.B extrend
extrlop MOVE.W PattCurPos,D0
BSR.W GetPositionPtr
BSR.W inotr
ADDQ.W #2,ScrPattPos
CMP.W #64,ScrPattPos
BLO.B extrlop
extrend MOVE.W PosSave(PC),ScrPattPos
JMP RedrawPattern
ContractTrack
CLR.B RawKeyCode
BSR.W SaveUndo
MOVE.W ScrPattPos,PosSave
ADDQ.W #2,ScrPattPos ; --PT2.3D bug fix: was #1 (fixes CTRL+O)
CMP.W #64,ScrPattPos
BHS.B cotrend
cotrlop MOVE.W PattCurPos,D0
BSR.W GetPositionPtr
BSR.W dnt
ADDQ.W #1,ScrPattPos ; --PT2.3D bug fix: was #2 (fixes CTRL+O)
CMP.W #64,ScrPattPos
BLO.B cotrlop
cotrend MOVE.W PosSave(PC),ScrPattPos
JMP RedrawPattern
PosSave dc.w 0
KillToEndOfTrack
CLR.B RawKeyCode
BSR.B SaveUndo
MOVE.W PattCurPos,D0
BSR.W GetPositionPtr
MOVE.W ScrPattPos,D0
MOVE.W D0,D1
LSL.W #4,D1
LEA (A0,D1.W),A0
MOVEQ #0,D1
TST.W ShiftKeyStatus
BNE.B KillToStart
kteot
CLR.L (A0)
LEA 16(A0),A0
ADDQ.W #1,D0
CMP.W #64,D0
BLO.B kteot
JMP RedrawPattern
KillToStart
CLR.L (A0)
LEA -16(A0),A0
TST.W D0
BEQ.B xRedrawPattern
SUBQ.W #1,D0
BRA.B KillToStart
xRedrawPattern JMP RedrawPattern
UndoLastChange
CLR.B RawKeyCode
MOVEQ #0,D0
BSR.W GetPositionPtr
LEA UndoBuffer,A1
MOVE.W #256-1,D0
unlalop MOVE.L (A1),D1
MOVE.L (A0),(A1)+
MOVE.L D1,(A0)+
DBRA D0,unlalop
JMP RedrawPattern
SaveUndo
MOVEM.L D0/A0/A1,-(SP)
MOVEQ #0,D0
BSR.W GetPositionPtr
LEA UndoBuffer,A1
MOVE.W #256-1,D0
saunlop MOVE.L (A0)+,(A1)+
DBRA D0,saunlop
MOVEM.L (SP)+,D0/A0/A1
RTS
;---- Check Function Keys F1-F2 ----
CheckF1_F2
CMP.B #80,RawKeyCode
BEQ.B SetOctaveLow
CMP.B #81,RawKeyCode
BEQ.B SetOctaveHigh
RTS
SetOctaveLow
MOVE.L #KbdTransTable1,KeyTransTabPtr
CLR.B RawKeyCode
RTS
SetOctaveHigh
MOVE.L #KbdTransTable2,KeyTransTabPtr
CLR.B RawKeyCode
RTS
;---- Get Hex Key ----
GetHexNybble
MOVE.W #1,AbortHexFlag
BSR.W StorePtrCol
BSR.W SetWaitPtrCol
MOVEQ #0,D0
MOVE.W TextOffset,D0
DIVU.W #40,D0
ADDQ.W #5,D0
MOVE.W D0,LineCurY
SWAP D0
LSL.W #3,D0
ADDQ.W #4,D0
MOVE.W D0,LineCurX
BSR.W UpdateLineCurPos
BSR.W GetHexKey
CMP.B #128,D1
BEQ.W ghbdone
MOVE.L D1,D0
MOVE.B D1,D6
JSR PrintHexDigit
CLR.W AbortHexFlag
ghndone
CLR.W LineCurX
MOVE.W #270,LineCurY
BSR.W UpdateLineCurPos
BSR.W RestorePtrCol
MOVE.B D6,D0
RTS
GetHexByte
MOVE.W #1,AbortHexFlag
BSR.W StorePtrCol
BSR.W SetWaitPtrCol
MOVEQ #0,D0
MOVE.W TextOffset,D0
DIVU.W #40,D0
ADDQ.W #5,D0 ; --PT2.3D bug fix: text marker one y pixel too much
MOVE.W D0,LineCurY
SWAP D0
LSL.W #3,D0
ADDQ.W #4,D0
MOVE.W D0,LineCurX
BSR.W UpdateLineCurPos
BSR.B GetHexKey
CMP.B #128,D1
BEQ.B ghbdone
MOVE.L D1,D0
MOVE.B D1,D6
LSL.B #4,D6
JSR PrintHexDigit
ADDQ.W #8,LineCurX
BSR.W UpdateLineCurPos
BSR.B GetHexKey
CMP.B #128,D1
BEQ.B ghbdone
MOVE.L D1,D0
OR.B D1,D6
JSR PrintHexDigit
CLR.W AbortHexFlag
ghbdone
CLR.W LineCurX
MOVE.W #270,LineCurY
BSR.W UpdateLineCurPos
BSR.W RestorePtrCol
MOVE.B D6,D0
RTS
GetHexKey
CLR.B MixChar
MOVE.B #128,D1
BTST #2,$DFF016 ; right mouse button
BEQ.B ghkreturn
BSR.W CheckPatternRedraw2
MOVEQ #0,D0
BSR.W DoKeyBuffer
MOVE.B RawKeyCode,D0
MOVE.B D0,MixChar
BEQ.B GetHexKey
MOVE.B #128,D1
CLR.B RawKeyCode
CMP.B #68,D0 ; CR
BEQ.B ghkreturn
CMP.B #69,D0 ; Esc
BEQ.B ghkreturn
CMP.B #79,D0 ; <--
BEQ.B ghkleft
CMP.B #78,D0 ; -->
BEQ.B ghkright
BSR.B CheckHexKey
CMP.B #16,D1
BEQ.B GetHexKey
ghkreturn
MOVEQ #0,D0
RTS
ghkleft MOVEQ #-1,D0
RTS
ghkright MOVEQ #1,D0
RTS
CheckHexKey
LEA RawKeyHexTable,A0
MOVEQ #0,D1
chxloop CMP.B (A0)+,D0
BEQ.W Return1
ADDQ.B #1,D1
CMP.B #16,D1
BNE.B chxloop
RTS
;---- Enter Edit Commands (effects) ----
EditCommand
TST.L EditMode
BEQ.W Return1
MOVEQ #0,D0
MOVE.B RawKeyCode,D0
BSR.B CheckHexKey
CMP.B #16,D1
BNE.B DoEditCommand
RTS
DoEditCommand
CMP.W #1,PattCurPos
BNE.B ChkPos2
CMP.W #1,D1
BHI.W Return1
MOVE.L #$FFF,D2
CLR.W CmdOffset
LSL.W #4,D1
LSL.W #8,D1
BRA.W UpdateCommand
ChkPos2 CMP.W #2,PattCurPos
BNE.B ChkPos3
MOVE.L #$FFF,D2
MOVE.W #2,CmdOffset
LSL.W #4,D1
LSL.W #8,D1
BRA.W UpdateCommand
ChkPos3 CMP.W #3,PattCurPos
BNE.B ChkPos4
MOVE.L #$F0FF,D2
MOVE.W #2,CmdOffset
LSL.W #8,D1
BRA.W UpdateCommand
ChkPos4 CMP.W #4,PattCurPos
BNE.B ChkPos5
MOVE.L #$FF0F,D2
MOVE.W #2,CmdOffset
LSL.W #4,D1
BRA.W UpdateCommand
ChkPos5 CMP.W #5,PattCurPos
BNE.B ChkPos7
MOVE.L #$FFF0,D2
MOVE.W #2,CmdOffset
BRA.W UpdateCommand
ChkPos7 CMP.W #7,PattCurPos
BNE.B ChkPos8
CMP.W #1,D1
BHI.W Return1
MOVE.L #$FFF,D2
MOVE.W #4,CmdOffset
LSL.W #4,D1
LSL.W #8,D1
BRA.W UpdateCommand
ChkPos8 CMP.W #8,PattCurPos
BNE.B ChkPos9
MOVE.L #$FFF,D2
MOVE.W #6,CmdOffset
LSL.W #4,D1
LSL.W #8,D1
BRA.W UpdateCommand
ChkPos9 CMP.W #9,PattCurPos
BNE.B ChkPos10
MOVE.L #$F0FF,D2
MOVE.W #6,CmdOffset
LSL.W #8,D1
BRA.W UpdateCommand
ChkPos10 CMP.W #10,PattCurPos
BNE.B ChkPos11
MOVE.L #$FF0F,D2
MOVE.W #6,CmdOffset
LSL.W #4,D1
BRA.W UpdateCommand
ChkPos11 CMP.W #11,PattCurPos
BNE.B ChkPos13
MOVE.L #$FFF0,D2
MOVE.W #6,CmdOffset
BRA.W UpdateCommand
ChkPos13 CMP.W #13,PattCurPos
BNE.B ChkPos14
CMP.W #1,D1
BHI.W Return1
MOVE.L #$FFF,D2
MOVE.W #8,CmdOffset
LSL.W #4,D1
LSL.W #8,D1
BRA.W UpdateCommand
ChkPos14 CMP.W #14,PattCurPos
BNE.B ChkPos15
MOVE.L #$FFF,D2
MOVE.W #10,CmdOffset
LSL.W #4,D1
LSL.W #8,D1
BRA.W UpdateCommand
ChkPos15 CMP.W #15,PattCurPos
BNE.B ChkPos16
MOVE.L #$F0FF,D2
MOVE.W #10,CmdOffset
LSL.W #8,D1
BRA.W UpdateCommand
ChkPos16 CMP.W #16,PattCurPos
BNE.B ChkPos17
MOVE.L #$FF0F,D2
MOVE.W #10,CmdOffset
LSL.W #4,D1
BRA.W UpdateCommand
ChkPos17 CMP.W #17,PattCurPos
BNE.B ChkPos19
MOVE.L #$FFF0,D2
MOVE.W #10,CmdOffset
BRA.W UpdateCommand
ChkPos19 CMP.W #19,PattCurPos
BNE.B ChkPos20
CMP.W #1,D1
BHI.W Return1
MOVE.L #$FFF,D2
MOVE.W #12,CmdOffset
LSL.W #4,D1
LSL.W #8,D1
BRA.B UpdateCommand
ChkPos20 CMP.W #20,PattCurPos
BNE.B ChkPos21
MOVE.L #$FFF,D2
MOVE.W #14,CmdOffset
LSL.W #4,D1
LSL.W #8,D1
BRA.B UpdateCommand
ChkPos21 CMP.W #21,PattCurPos
BNE.B ChkPos22
MOVE.L #$F0FF,D2
MOVE.W #14,CmdOffset
LSL.W #8,D1
BRA.B UpdateCommand
ChkPos22
CMP.W #22,PattCurPos
BNE.B MustBePos23
MOVE.L #$FF0F,D2
MOVE.W #14,CmdOffset
LSL.W #4,D1
BRA.B UpdateCommand
MustBePos23
MOVE.L #$FFF0,D2
MOVE.W #14,CmdOffset
UpdateCommand
MOVE.L SongDataPtr,A0
LEA sd_patterndata(A0),A0
MOVE.L PatternNumber,D0
LSL.L #8,D0
LSL.L #2,D0
ADD.L D0,A0
MOVEQ #0,D0
MOVE.W ScrPattPos,D0
LSL.W #4,D0
EXT.L D0
ADD.L D0,A0
ADD.W CmdOffset,A0
AND.W D2,(A0)
ADD.W D1,(A0)
MOVE.W (A0),WordNumber
MOVEQ #0,D0
MOVE.W ScrPattPos,D0
MULU.W #7*40,D0
MOVEQ #0,D1
MOVE.W PattCurPos,D1
DIVU.W #6,D1
MULU.W #9,D1
ADD.L D1,D0
ADD.W #7528,D0
MOVE.W D0,TextOffset
TST.W CmdOffset
BEQ.B ShowInstrNibble
CMP.W #4,CmdOffset
BEQ.B ShowInstrNibble
CMP.W #8,CmdOffset
BEQ.B ShowInstrNibble
CMP.W #12,CmdOffset
BEQ.B ShowInstrNibble
JSR PrintHexWord
dscend BSR.W EditMoveDown
CLR.B RawKeyCode
RTS
ShowInstrNibble
SUBQ.W #1,TextOffset
MOVE.W #1,TextLength
MOVEQ #0,D0
MOVE.W (A0),D0
AND.W #$F000,D0
BNE.B sinokok
TST.B BlankZeroFlag
BEQ.B sinokok
MOVE.L #BlankInsText,D0
BRA.B sinprt
sinokok LSR.W #4,D0
LSR.W #7,D0
ADD.L #FastHexTable+1,D0
sinprt MOVE.L D0,ShowTextPtr
JSR ShowText
BRA.B dscend
;---- Store/Insert Effect Commands ----
CheckStoreEffect
CMP.W #3,CurrScreen
BEQ.W Return1
CMP.W #6,CurrScreen
BEQ.W Return1
CMP.W #4,CurrScreen
BEQ.W Return1
MOVEQ #0,D0
MOVE.B RawKeyCode,D0
BEQ.W Return1
CMP.B #70,D0 ; Del
BEQ.W CheckKeyboard2
CMP.B #10,D0
BHI.W Return1
SUBQ.B #1,D0
ADD.B D0,D0
MOVE.L D0,D7
MOVE.W PattCurPos,D0
BSR.W GetPositionPtr
MOVE.W ScrPattPos,D0
LSL.W #4,D0
LEA (A0,D0.W),A0
MOVE.W 2(A0),D0
AND.W #$FFF,D0
LEA EffectMacros,A0
MOVE.W D0,(A0,D7.W)
LEA CommandStoredText(PC),A0
JSR ShowStatusText
BSR.W WaitALittle
JMP ShowAllRight
CommandStoredText dc.b 'command stored!',0
EVEN
CheckInsertEffect
CLR.W InsEfx
MOVEQ #0,D0
MOVE.B RawKeyCode,D0
BEQ.W Return1
CMP.B #70,D0 ; Del
BEQ.W CheckKeyboard2
CMP.B #11,D0 ; -
BEQ.W DecreaseEffect
CMP.B #12,D0 ; = (+)
BEQ.B IncreaseEffect
CMP.B #13,D0 ; \
BEQ.B CopyEffect
CMP.B #10,D0
BHI.W Return1
SUBQ.B #1,D0
ADD.B D0,D0
LEA EffectMacros,A0
MOVE.W (A0,D0.W),InsEfx
DoInsEffect
MOVE.B #70,RawKeyCode
BRA.W CheckNoteKeys
GetLastEffect
MOVE.W PattCurPos,D0
BSR.W GetPositionPtr
MOVE.W ScrPattPos,D0
SUBQ.W #1,D0
AND.W #$3F,D0
LSL.W #4,D0
LEA (A0,D0.W),A0
MOVE.W 2(A0),D0
AND.W #$0FFF,D0
RTS
CopyEffect
BSR.B GetLastEffect
MOVE.W D0,InsEfx
BRA.B DoInsEffect
IncreaseEffect
BSR.B GetLastEffect
MOVE.W D0,D1
AND.W #$0F00,D1
CMP.W #$0E00,D1
BEQ.B IncECom
ADDQ.B #1,D0
MOVE.W D0,InsEfx
BRA.B DoInsEffect
IncECom
MOVE.W D0,D1
ADDQ.B #1,D1
AND.B #$0F,D1
AND.W #$0FF0,D0
OR.B D1,D0
MOVE.W D0,InsEfx
BRA.B DoInsEffect
DecreaseEffect
BSR.B GetLastEffect
MOVE.W D0,D1
AND.W #$0F00,D1
CMP.W #$0E00,D1
BEQ.B DecECom
SUBQ.B #1,D0
MOVE.W D0,InsEfx
BRA.W DoInsEffect
DecECom MOVE.W D0,D1
SUBQ.B #1,D1
AND.B #$0F,D1
AND.W #$0FF0,D0
OR.B D1,D0
MOVE.W D0,InsEfx
BRA.W DoInsEffect
InsEfx dc.w 0
;---- Check Keyboard for notekeys ----
CheckKeyboard
TST.B RawKeyCode
BEQ.W Return1
; --PT2.3D change: DEL = sample data cut in sampler screen
TST.W SamScrEnable ; sampler screen shown?
BEQ.B ckskip ; no, don't check for DEL key
CMP.B #70,RawKeyCode ; DEL key pressed?
BEQ.W xSamCut ; yes, branch to sample cut routine
ckskip ; --------------------------------------------------------
TST.W LeftAmigaStatus
BNE.W Return1
TST.W CtrlKeyStatus
BNE.W Return1
TST.W ShiftKeyStatus
BNE.W CheckStoreEffect
TST.W AltKeyStatus
BNE.W CheckInsertEffect
CheckKeyboard2
MOVE.W PattCurPos,D0
BEQ.B CheckNoteKeys
CMP.W #6,D0
BEQ.B CheckNoteKeys
CMP.W #12,D0
BEQ.B CheckNoteKeys
CMP.W #18,D0
BEQ.B CheckNoteKeys
TST.L EditMode
BNE.W EditCommand
RTS
CheckNoteKeys
LEA RawKeyScaleTable,A0
MOVE.B RawKeyCode,D1
MOVEQ #39-1,D0
cnkloop CMP.B (A0,D0.W),D1
BEQ.B NoteKeyPressed
DBRA D0,cnkloop
RTS
UpdateChordNote
BSR.W CalculateChordLen
BRA.W DisplayChordNotes
NoteKeyPressed
CLR.W DidQuantize
CLR.B RawKeyCode
MOVE.L KeyTransTabPtr,A1
MOVE.B (A1,D0.W),D0
CMP.W #36,D0
BHS.B nkpskip
MOVE.L SplitAddress,D1
BEQ.B nkpskip
CLR.L SplitAddress
MOVE.L D1,A0
MOVE.B D0,(A0)
MOVE.W SamNoteType,D1
BEQ.W ShowSplit
CLR.W SamNoteType
AND.W #$FF,D0
MOVE.W D0,(A0)
CMP.W #1,D1
BEQ.B loclab1
CMP.W #3,D1
BEQ.W ShowS2TuneNote
CMP.W #4,D1
BEQ.B xShowAllRight
CMP.W #5,D1
BEQ.W UpdateChordNote
CMP.W #2,D1
BNE.B nkpskip
JMP ShowResamNote
loclab1 JMP ShowSamNote
xShowAllRight JMP ShowAllRight
nkpskip MOVE.W InsNum,PlayInsNum
TST.B SplitFlag
BEQ.B nkpskip2
LEA SplitInstrTable,A1
MOVE.B (A1,D0.W),D1
BEQ.B nkpskip3
MOVE.B D1,PlayInsNum+1
nkpskip3
LEA SplitTransTable,A1
MOVE.B (A1,D0.W),D0
nkpskip2
MOVEQ #0,D2
playtheinstr
LEA PeriodTable,A1 ; note in d0 here
MOVE.L D0,D4
ADD.W D0,D0
MOVEQ #0,D3
MOVE.W (A1,D0.W),D3
MOVE.L SongDataPtr,A0 ; This fixes finetune...
LEA 14(A0),A0
MOVE.W InsNum,D1
BNE.B nkpskipit
MOVE.W LastInsNum,D1
nkpskipit
MULU.W #30,D1
ADD.L D1,A0
MOVEQ #0,D1
MOVE.B (A0),D1 ; get finetune
AND.B #$0F,D1
LSL.B #2,D1
LEA ftunePerTab,A4
MOVE.L (A4,D1.W),A1
MOVE.W (A1,D0.W),CurrentPlayNote
TST.L D2
BEQ.B nkpnrml
CMP.B #2,pnoteflag
BNE.W antpskip
nkpnrml TST.L EditMode
BEQ.W antpskip
AddNoteToPattern
MOVE.L SongDataPtr,A0
LEA sd_patterndata(A0),A0 ; Find first pattern
MOVE.L PatternNumber,D0
LSL.L #8,D0
LSL.L #2,D0
ADD.L D0,A0 ; Find current pattern
MOVEQ #0,D0
MOVE.W ScrPattPos,D0
BSR.W QuantizeCheck
LSL.W #4,D0
EXT.L D0
ADD.L D0,A0 ; Find current pos
MOVEQ #0,D0
MOVE.W PattCurPos,D0
DIVU.W #6,D0
LSL.W #2,D0
EXT.L D0
ADD.L D0,A0 ; Find current channel
TST.W AltKeyStatus
BEQ.B antpsks
AND.L #$FFFFF000,(A0)
MOVE.W InsEfx(PC),D0
OR.W D0,2(A0)
BRA.B antp3
antpsks TST.W ShiftKeyStatus
BEQ.B antpskip2
CLR.L (A0)
antpskip2 MOVEQ #0,D0
MOVE.W D3,(A0) ; Put note into pattern
BEQ.B antp2
TST.B AutoInsFlag
BEQ.B antp4
MOVE.B AutoInsSlot,D0
ADD.B D0,D0
EXT.W D0
LEA EffectMacros,A1
MOVE.W (A1,D0.W),2(A0)
antp4 MOVE.W PlayInsNum,D0
LSL.W #4,D0
AND.B #$F,2(A0)
ADD.B D0,2(A0)
LSL.W #4,D0
AND.W #$F000,D0
OR.W D0,(A0)
BRA.B antp3
antp2 AND.W #$0FFF,2(A0)
antp3 MOVE.W 2(A0),CurrCmds
MOVE.L NoteNamesPtr,A0
LSL.W #2,D4
EXT.L D4
ADD.L D4,A0
MOVE.L A0,ShowTextPtr
MOVE.W #3,TextLength
MOVEQ #0,D0
MOVE.W ScrPattPos,D0
BSR.W QuantizeCheck
MULU.W #7*40,D0
MOVEQ #0,D1
MOVE.W PattCurPos,D1
DIVU.W #6,D1
MULU.W #9,D1
ADD.L D1,D0
ADD.W #7524,D0
MOVE.W D0,TextOffset
TST.W AltKeyStatus
BEQ.B antpnot
ADDQ.W #4,D0
MOVE.W D0,TextOffset
BRA.B antpalt
antpnot JSR ShowText ; Show notename
JSR PrintHiInstrNum
antpalt
MOVE.W CurrCmds,WordNumber
JSR PrintHexWord
BSR.W EditMoveDown
antpskip
; --PT2.3D bug fix: instant channel muting
LEA audchan1toggle(PC),A0
MOVEQ #0,D0
MOVE.W PattCurPos,D0
DIVU.W #6,D0
LSL.B #3,D0
MOVE.W (A0,D0.W),D0
BNE.B antpskip3
RTS
antpskip3
; ----------------------------------------
TST.W DidQuantize
BNE.B testmul
TST.W CurrentPlayNote
BNE.W PlayNote
testmul TST.B MultiFlag
BEQ.W Return1
GotoNextMulti
MOVEQ #0,D0
MOVE.W PattCurPos,D0
DIVU.W #6,D0
LEA MultiModeNext,A0
MOVE.B (A0,D0.W),D0
SUBQ.W #1,D0
AND.W #3,D0
MULU.W #6,D0
MOVE.W D0,PattCurPos
BRA.W UpdateCursorPos
QuantizeCheck
TST.L RunMode
BEQ.B qcend
MOVEQ #0,D1
MOVE.B QuantizeValue(PC),D1
BEQ.B qcend
CMP.W #1,D1
BEQ.B QuanOne
MOVE.W #1,DidQuantize
MOVE.L D1,D2
LSR.W #1,D2
ADD.W D0,D2
AND.W #$003F,D2
DIVU.W D1,D2
MULU.W D1,D2
CMP.W D0,D2
BHI.B qcskip
CLR.W DidQuantize
qcskip MOVE.W D2,D0
RTS
QuanOne MOVE.L CurrSpeed,D1
LSR.L #1,D1
CMP.L Counter,D1
BLS.B QuantToNextNote
qcend CLR.W DidQuantize
RTS
QuantToNextNote
ADDQ.W #1,D0
AND.W #$003F,D0
MOVE.W #1,DidQuantize
RTS
PlayNote
CMP.W #18,PattCurPos
BLO.B ChkChan3
LEA $DFF0D0,A5
LEA audchan4temp,A4
BRA.B DoPlayNote
ChkChan3
CMP.W #12,PattCurPos
BLO.B ChkChan2
LEA $DFF0C0,A5
LEA audchan3temp,A4
BRA.B DoPlayNote
ChkChan2
CMP.W #6,PattCurPos
BLO.B ChkChan1
LEA $DFF0B0,A5
LEA audchan2temp,A4
BRA.B DoPlayNote
ChkChan1
; it doesn't seem like this test is needed...
;TST.W PattCurPos
;BNE.W Return1
LEA $DFF0A0,A5
LEA audchan1temp,A4
DoPlayNote
MOVE.L A5,NoteAddr
LEA SampleInfo,A6
MOVE.W PlayInsNum,D0
BEQ.B dpnplay
LSL.L #2,D0
LEA SamplePtrs,A0
LEA SampleInfo2,A6
MOVE.L (A0,D0.W),si_pointer2
MOVE.L SongDataPtr,A0
LEA -10(A0),A0
MOVE.W PlayInsNum,D0
MOVE.B D0,PlayInsNum2
MULU.W #30,D0
ADD.L D0,A0
MOVE.L 22(A0),SampleInfo2
MOVE.L 26(A0),si_long2
dpnplay MOVE.B PlayInsNum2(PC),n_samplenum(A4)
MOVE.W 4(A6),D0 ; repeat
BNE.B dpn2
MOVE.W (A6),D0 ; length
BRA.B dpn3
dpn2 ADD.W 6(A6),D0 ; add replen
dpn3 MOVEQ #0,D1
MOVE.B 3(A6),D1
; --PT2.3D bug fix: limit sample volume to 64
CMP.B #64,D1
BLS.B dpnvolok
MOVEQ #64,D1
dpnvolok
; --END OF FIX--------------------------------
MOVE.W D1,8(A5) ; Set volume
MOVE.B D1,n_volumeout(A4) ; Set quadrascope volume
MOVE.B D1,n_volume(A4)
MOVE.W CurrentPlayNote,6(A5) ; Set period
MOVE.W CurrentPlayNote,n_periodout(A4) ; Set quadrascope period
MOVE.W CurrentPlayNote,n_period(A4)
MOVE.W n_dmabit(A4),$DFF096 ; Turn off all voice DMAs
MOVE.L 8(A6),D1
ADD.L StartOfs,D1
MOVE.L D1,(A5) ; Set sampledata pointer
CLR.L StartOfs
MOVE.L D1,n_start(A4)
MOVE.L D1,n_oldstart(A4) ; for quadrascope
MOVE.W D0,4(A5) ; Set length
MOVE.W D0,n_length(A4)
MOVE.W D0,n_oldlength(A4) ; for quadrascope
BNE.B dpnnz
MOVEQ #1,D0
MOVE.W D0,4(A5)
MOVE.W D0,n_length(A4)
dpnnz MOVE.W CurrentPlayNote,D0
BSR.W PlayNoteAnalyze
JSR WaitForPaulaLatch
MOVE.W n_dmabit(A4),D0
OR.W #$8000,D0 ; Set bits
MOVE.W D0,$DFF096 ; Turn DMAs back on
JSR WaitForPaulaLatch
MOVEQ #0,D1
MOVE.W 4(A6),D1 ; repeat*2
MOVE.W D1,n_repeat(A4)
ADD.L D1,D1
ADD.L 8(A6),D1 ; + startptr
MOVE.L D1,(A5) ; Set loop pointer
MOVE.L D1,n_loopstart(A4)
MOVE.W 6(A6),4(A5) ; Set loop length
MOVE.W 6(A6),n_replen(A4)
ST n_trigger(A4)
BRA.W testmul
PlayInsNum2 dc.b 0
EVEN
;---- Check Cursor Arrow Keys ----
ArrowKeys
CMP.B #4,EnterTextFlag
BEQ.W Return1
MOVE.B RawKeyCode,D0
TST.W GetLineFlag
BNE.B arkeskip
TST.W ShiftKeyStatus
BNE.B arkeskip
TST.W AltKeyStatus
BNE.B arkeskip
CMP.W #2,CurrScreen
BEQ.B arkeskip
CMP.B #78,D0
BEQ.W RightArrow
CMP.B #79,D0
BEQ.W LeftArrow
arkeskip
CMP.B #76,D0
BEQ.B UpArrow
CMP.B #77,D0
BEQ.W DownArrow
CLR.W ArrowPressed
RTS
ArrowPressed dc.w 0
ArrowRepCounter dc.w 0
UpArrow TST.L RunMode
BNE.W Return1
CMP.W #2,CurrScreen
BEQ.W Return1
CMP.W #3,CurrScreen
BEQ.W Return1
CMP.W #4,CurrScreen
BEQ.W Return1
CMP.W #6,CurrScreen
BEQ.W Return1
CMP.W #8,CurrScreen
BEQ.W Return1
TST.W ArrowPressed
BEQ.B MoveOneUp
ADDQ.W #1,ArrowRepCounter
TST.W AltKeyStatus
BNE.B AltUpArrow
TST.W ShiftKeyStatus
BNE.B ShiftUpArrow
CMP.W #6,ArrowRepCounter
BPL.B MoveOneUp
RTS
ShiftUpArrow
CMP.W #3,ArrowRepCounter
BPL.B MoveOneUp
RTS
AltUpArrow
CMP.W #1,ArrowRepCounter
BPL.B MoveOneUp
RTS
MoveOneUp
CLR.W ArrowRepCounter
MOVE.W #$FFFF,ArrowPressed
CMP.L #'patt',RunMode
BEQ.W Return1
SUBQ.W #1,ScrPattPos
AND.W #$003F,ScrPattPos
BRA.W SetScrPatternPos
DownArrow
TST.L RunMode
BNE.W Return1
CMP.W #2,CurrScreen
BEQ.W Return1
CMP.W #3,CurrScreen
BEQ.W Return1
CMP.W #4,CurrScreen
BEQ.W Return1
CMP.W #6,CurrScreen
BEQ.W Return1
CMP.W #8,CurrScreen
BEQ.W Return1
TST.W ArrowPressed
BEQ.B MoveOneDown
ADDQ.W #1,ArrowRepCounter
TST.W AltKeyStatus
BNE.B AltDownArrow
TST.W ShiftKeyStatus
BNE.B ShiftDownArrow
CMP.W #6,ArrowRepCounter
BPL.B MoveOneDown
RTS
ShiftDownArrow
CMP.W #3,ArrowRepCounter
BPL.B MoveOneDown
RTS
AltDownArrow
CMP.W #1,ArrowRepCounter
BPL.B MoveOneDown
RTS
MoveOneDown
CLR.W ArrowRepCounter
MOVE.W #$FFFF,ArrowPressed
TST.L RunMode
BNE.W Return1
ADDQ.W #1,ScrPattPos
AND.W #$003F,ScrPattPos
BRA.W SetScrPatternPos
EditMoveDown
TST.L RunMode
BNE.W Return1
MOVE.W EditMoveAdd(PC),D0
ADD.W D0,ScrPattPos
AND.W #$003F,ScrPattPos
BRA.W SetScrPatternPos
EditMoveAdd dc.w 1
RightArrow
TST.W ArrowPressed
BEQ.B MoveOneRight
ADDQ.W #1,ArrowRepCounter
CMP.W #6,ArrowRepCounter
BPL.B MoveOneRight
RTS
PatternOneUp
ADDQ.L #1,PatternNumber
MOVE.L PatternNumber,D0
CMP.L MaxPattern(PC),D0
BLE.B pouskip
CLR.L PatternNumber
pouskip
;BSR.W Wait_4000
JMP RedrawPattern
MoveOneRight
CLR.W ArrowRepCounter
MOVE.W #$FFFF,ArrowPressed
ADDQ.W #1,PattCurPos
CMP.W #24,PattCurPos
BMI.B morskip
CLR.W PattCurPos
morskip BRA.B UpdateCursorPos
LeftArrow
TST.W ArrowPressed
BEQ.B MoveOneLeft
ADDQ.W #1,ArrowRepCounter
CMP.W #6,ArrowRepCounter
BPL.B MoveOneLeft
RTS
PatternOneDown
SUBQ.L #1,PatternNumber
TST.L PatternNumber
BPL.B podskip
MOVE.L MaxPattern(PC),PatternNumber
podskip
;BSR.W Wait_4000
JMP RedrawPattern
MoveOneLeft
CLR.W ArrowRepCounter
MOVE.W #$FFFF,ArrowPressed
SUBQ.W #1,PattCurPos
TST.W PattCurPos
BPL.B UpdateCursorPos
MOVE.W #23,PattCurPos
UpdateCursorPos
TST.W SamScrEnable
BNE.W Return1
MOVE.W PattCurPos,D0
LEA CursorPosTable,A0
MOVE.B (A0,D0.W),D0
LSL.W #3,D0
ADD.W #9,D0
MOVE.W #$BD,D1
MOVEQ #14,D2 ; 14 lines
LEA CursorSpriteData,A0
JMP SetSpritePos
ArrowKeys2
MOVE.B RawKeyCode,D0
CMP.B #76,D0
BEQ.B UpArrow2
CMP.B #77,D0
BEQ.B DownArrow2
CMP.B #79,D0
BEQ.W LeftArrow2
CMP.B #78,D0
BEQ.W RightArrow2
RTS
UpArrow2
CMP.W #2,CurrScreen
BEQ.W HelpUp
CMP.W #3,CurrScreen
BEQ.W FilenameOneUp
CMP.W #4,CurrScreen
BEQ.B PED_OneUp2
CMP.W #6,CurrScreen
BEQ.B PLSTOneUp2
CMP.W #8,CurrScreen
BEQ.W POSED_OneUp
RTS
PED_OneUp2 JMP PED_OneUp
PLSTOneUp2 JMP PLSTOneUp
DownArrow2
CMP.W #2,CurrScreen
BEQ.W HelpDown
CMP.W #3,CurrScreen
BEQ.W FilenameOneDown
CMP.W #4,CurrScreen
BEQ.B PED_OneDown2
CMP.W #6,CurrScreen
BEQ.B PLSTOneDown2
CMP.W #8,CurrScreen
BEQ.W POSED_OneDown
RTS
PED_OneDown2 JMP PED_OneDown
PLSTOneDown2 JMP PLSTOneDown
LeftArrow2
TST.W ShiftKeyStatus
BNE.W PositionDown
TST.W AltKeyStatus
BNE.W PatternOneDown
TST.W CtrlKeyStatus
BNE.W SampleNumDown
CMP.W #2,CurrScreen
BEQ.W HelpLeft
RTS
RightArrow2 TST.W ShiftKeyStatus
BNE.W PositionUp
TST.W AltKeyStatus
BNE.W PatternOneUp
TST.W CtrlKeyStatus
BNE.W SampleNumUp
CMP.W #2,CurrScreen
BEQ.W HelpRight
RTS
;---- Update Line Cursor Position ----
UpdateLineCurPos
MOVE.W LineCurX,D0
MOVE.W LineCurY,D1
SUBQ.W #1,D0
MOVEQ #2,D2
LEA LineCurSpriteData,A0
JMP SetSpritePos
;---- Scope Muting (with right mouse button) ----
CheckScopeMuting
CMP.W #1,CurrScreen
BNE.B csmRTS ; was not main screen
TST.B EdEnable
BNE.B csmRTS ; edit op. was shown
TST.B AboutScreenShown
BNE.B csmRTS ; about screen was shown
TST.B AnaScopFlag
BEQ.B csmRTS ; spectrum analyzer was shown
TST.B DisableScopeMuting
BNE.B csmRTS ; kludge/hack (hard to explain)
MOVE.W MouseY(PC),D0
CMP.W #56,D0
BLO.B csmRTS
CMP.W #88,D0
BHI.B csmRTS
MOVE.W MouseX(PC),D1
csmcheck4
CMP.W #264,D1
BLO.B csmcheck3
MOVEQ #35,D0 ; channel #4
MOVEQ #0,D6 ; don't wait for mouse button up
BSR.W DoToggleMute
BRA.B csmRTS
csmcheck3
CMP.W #216,D1
BLO.B csmcheck2
MOVEQ #25,D0 ; channel #3
MOVEQ #0,D6 ; don't wait for mouse button up
BSR.W DoToggleMute
BRA.B csmRTS
csmcheck2
CMP.W #168,D1
BLO.B csmcheck1
MOVEQ #15,D0 ; channel #2
MOVEQ #0,D6 ; don't wait for mouse button up
BSR.W DoToggleMute
BRA.B csmRTS
csmcheck1
CMP.W #120,D1
BLO.B csmRTS
MOVEQ #0,D0 ; channel #1
MOVEQ #0,D6 ; don't wait for mouse button up
BSR.W DoToggleMute
csmRTS
RTS
;---- Check Gadgets ----
CheckGadgets
;BSR.W UpdatePointerPos
BSR.B CheckGadgets2
TST.B GadgRepeat
BNE.B CgRepeat
MOVEQ #0,D0
cgloop ADDQ.L #1,D0
CMP.L #8,D0
BEQ.B CgRepeat
BSR.W Wait_4000
BTST #6,$BFE001 ; left mouse button
BEQ.B cgloop
CLR.W UpOrDown
BRA.W StopInputLoop
CgRepeat
ST GadgRepeat
BTST #6,$BFE001 ; left mouse button
BEQ.B CheckGadgets
SF GadgRepeat
CLR.W UpOrDown
BRA.W StopInputLoop
CheckGadgets2
MOVE.W MouseX(PC),MouseX2
BNE.B cgskip
TST.W MouseY
BNE.B cgskip
ChkQuit LEA QuitPTText,A0
BSR.W AreYouSure
BEQ.W ExitCleanup ; Quit PT!
RTS
cgskip
MOVE.W MouseY(PC),MouseY2
CMP.W #4,CurrScreen
BEQ.W xCheckPresEdGadgs
DoCheckGadgets2
MOVE.W MouseX2,D0
MOVE.W MouseY2,D1
CMP.W #122,D1
BHS.W WantedPattGadg
CMP.W #111,D1
BHS.W CheckSmplNamOrLoad
CMP.W #100,D1
BHS.W TypeInSongName
CMP.W #120,D0
BLO.B cgskip2
CMP.W #6,CurrScreen
BEQ.W xCheckPLSTGadgs
CMP.W #8,CurrScreen
BEQ.W CheckPosEdGadgs
cgskip2 CMP.W #2,CurrScreen
BEQ.W Return1
CMP.W #3,CurrScreen ; Screen 3 is DirScreen...
BEQ.W CheckDirGadgets
CMP.W #5,CurrScreen
BEQ.W CheckSetupGadgs
CMP.W #7,CurrScreen
BEQ.W CheckSetup2Gadgs
CMP.W #45,D1
BHS.B cgskip3
CMP.W #306,D0
BHS.W CheckToggle
CMP.W #244,D0
BHS.B MainMenu3
CMP.W #181,D0
BHS.B MainMenu2
CMP.W #120,D0
BHS.W MainMenu1
cgskip3 CMP.W #120,D0
BHS.B cgskip4
CMP.W #109,D0
BHS.W DownGadgets
CMP.W #98,D0
BHS.W UpGadgets
CMP.W #62,D0
BHS.W EnterNumGadg
CMP.W #54,D0 ; The new 17-bit hex gadgets are wider and
BHS.W EnterNumGadgWide ; they need an extra check for the leftmost bit.
BRA.W PosInsDelGadgs
cgskip4 TST.B EdEnable
BNE.W CheckEditOpGadgs
BRA.W ToggleAnaScope
xCheckPLSTGadgs JMP CheckPLSTGadgs
MainMenu3
MOVE.W MouseY2,D0
CMP.W #34,D0
BHS.B DPMGFIH
CMP.W #23,D0
BHS.W Setup
CMP.W #12,D0
BHS.B xPresetEditor
TST.W D0
BHS.B xPLST
RTS
xPLST JMP PLST
xPresetEditor JMP PresetEditor
xCheckPresEdGadgs JMP CheckPresEdGadgs
DPMGFIH JMP SamplerScreen
MainMenu2
MOVE.W MouseY2,D0
CMP.W #3,CurrScreen
BNE.B mm2skip
CMP.W #44,D0
BHS.W CheckDirGadgets2
mm2skip CMP.W #45,D0
BHS.W Return1
CMP.W #34,D0
BHS.W ShowDirScreen
CMP.W #23,D0
BHS.W DoEditOp
CMP.W #12,D0
BHS.W ClearAll
TST.W D0
BHS.W StopIt
RTS
MainMenu1
MOVE.W MouseY2,D0
CMP.W #3,CurrScreen
BNE.B mm1skip
CMP.W #44,D0
BHS.W CheckDirGadgets2
mm1skip CMP.W #45,D0
BHS.W Return1
CMP.W #34,D0
BHS.W RecordPattern
CMP.W #23,D0
BHS.W Edit
CMP.W #12,D0
BHS.W PlayPattern
TST.W D0
BHS.W PlaySong
RTS
;---- Disk Format ----
DiskFormatGadg
BSR.W WaitForButtonUp
BSR.W Wait_4000
BSR.W ClearFileNames
BSR.B SwapFormatBox
BSR.W WaitForButtonUp
LEA AreYouSureText,A0
JSR ShowStatusText
fmtbuttonchk
BSR.W DoKeyBuffer
MOVE.B RawKeyCode,D0
CMP.B #69,D0 ; ESC
BEQ.B fmtbend
BSR.W CheckPatternRedraw2
BTST #6,$BFE001 ; left mouse button
BNE.B fmtbuttonchk
MOVE.W MouseX(PC),D0
MOVE.W MouseY(PC),D1
CMP.W #89,D0
BLO.B fmtbuttonchk
CMP.W #212,D0
BHI.B fmtbuttonchk
CMP.W #72,D1
BLO.B fmtbuttonchk
CMP.W #82,D1
BHI.B fmtbuttonchk
CMP.W #136,D0
BLO.B DiskFormat
CMP.W #166,D0
BLO.B fmtbuttonchk
fmtbend BSR.B SwapFormatBox
BRA.W SetErrorPtrCol
SwapFormatBox
LEA FormatBoxPos,A0
LEA FormatBoxData,A1
DoSwapBox
MOVEQ #39-1,D0
sfbloop1
MOVEQ #18-1,D1
sfbloop2
MOVE.B 10240(A0),D2
MOVE.B 702(A1),10240(A0)
MOVE.B D2,702(A1)
MOVE.B (A0),D2
MOVE.B (A1),(A0)+
MOVE.B D2,(A1)+
DBRA D1,sfbloop2
LEA $0016(A0),A0
DBRA D0,sfbloop1
RTS
DiskFormat
BSR.B SwapFormatBox
JSR ShowAllRight
BSR.W ClearFileNames
LEA PlsEntNamText,A0
MOVE.W #2570,D1
MOVEQ #17,D0
JSR ShowText3
LEA OfVolumeText,A0
MOVE.B #'_',15(A0)
MOVE.B #'_',16(A0)
MOVE.W #2810,D1
MOVEQ #17,D0
JSR ShowText3
BSR.W SetWaitPtrCol
MOVE.W #2825,TextOffset
BSR.W GetHexByte
TST.W AbortHexFlag
BNE.W df_skip2
MOVE.W D0,D1
LSR.W #4,D0
AND.W #15,D1
LEA HexTable,A0
MOVE.B (A0,D0.W),DiskNumText1
MOVE.B (A0,D0.W),FormatDiskNum1
MOVE.B (A0,D1.W),DiskNumText2
MOVE.B (A0,D1.W),FormatDiskNum2
BSR.W ClearFileNames
LEA FormatAsText(PC),A0
BSR.W AreYouSure
BNE.W df_skip2
MOVE.L #5632,D0
MOVEQ #MEMF_CHIP,D1
JSR PTAllocMem
MOVE.L D0,FormatDataPtr
BEQ.W df_memerr
BSR.W DoShowFreeMem
SUB.L A1,A1
MOVE.L 4.W,A6
JSR _LVOFindTask(A6)
MOVE.L D0,ProcessPtr
LEA TrackdiskPort,A1
JSR _LVOAddPort(A6)
LEA TrackdiskIOExtTD,A1
MOVEQ #0,D0
MOVEQ #0,D1
LEA TrackdiskName,A0
JSR _LVOOpenDevice(A6)
MOVE.L #TrackdiskPort,TDPortPtr
CLR.W CylinderNumber
LEA TrackdiskIOExtTD,A1
MOVE.W #TD_CHANGESTATE,IO_COMMAND(A1)
JSR _LVODoIO(A6) ; Check if disk in drive
TST.L IO_ACTUAL(A1)
BEQ.B df_indrive
LEA NoDiskInDriveText,A0
JSR ShowStatusText
MOVE.W #ERR_WAIT_TIME,WaitTime
BSR.W SetErrorPtrCol
BRA.W df_cleanup
df_indrive
LEA TrackdiskIOExtTD,A1
MOVE.W #TD_PROTSTATUS,IO_COMMAND(A1)
JSR _LVODoIO(A6) ; Check write protect
TST.L IO_ACTUAL(A1)
BEQ.B df_noprot
LEA WriteProtectedText,A0
JSR ShowStatusText
MOVE.W #ERR_WAIT_TIME,WaitTime
BSR.W SetErrorPtrCol
BRA.W df_cleanup
df_noprot
LEA DiskFormatText,A0
MOVE.W #2581-7,D1
MOVEQ #11,D0
JSR ShowText3
LEA InProgressText,A0
MOVE.W #2821-7,D1
MOVEQ #11,D0
JSR ShowText3
CLR.L FmtDiskOffset
MOVE.L FormatDataPtr,FmtDataPtr
MOVE.L #$00001600,FmtDataSize
BSR.W ClearCylinder
BSR.W SetDiskPtrCol
df_formatloop
LEA FormattingCylText,A0
JSR ShowStatusText
MOVE.W CylinderNumber,D0
LSR.W #1,D0
MOVE.W D0,WordNumber
JSR Print2DecDigits
MOVE.L 4.W,A6
LEA TrackdiskIOExtTD,A1
MOVE.W #TD_FORMAT,IO_COMMAND(A1)
JSR _LVODoIO(A6) ; Format cylinder
LEA VerifyingText,A0
JSR ShowStatusText
MOVE.W CylinderNumber,D0
LSR.W #1,D0
MOVE.W D0,WordNumber
JSR Print2DecDigits
MOVE.L 4.W,A6
LEA TrackdiskIOExtTD,A1
MOVE.W #CMD_READ,IO_COMMAND(A1)
JSR _LVODoIO(A6) ; Read cylinder to verify
TST.B Fmt_hmmm
BEQ.B df_verifyok
LEA VerifyErrText(PC),A0
JSR ShowStatusText
MOVE.W #ERR_WAIT_TIME,WaitTime
BSR.W SetErrorPtrCol
BRA.W df_cleanup
VerifyErrText dc.b "Verify error!",0
EVEN
df_verifyok
ADD.L #$1600,FmtDiskOffset
ADDQ.W #1,CylinderNumber
CMP.W #160,CylinderNumber
BNE.W df_formatloop
LEA InitDiskText,A0
JSR ShowStatusText
BSR.W ClearCylinder
LEA TrackdiskIOExtTD,A1
CLR.L IO_OFFSET(A1)
MOVE.L FormatDataPtr,A2
MOVE.L #$444F5300,(A2) ; DOS\0
MOVE.W #$0370,10(A2)
MOVE.L #512,IO_LENGTH(A1)
MOVE.W #CMD_WRITE,IO_COMMAND(A1)
MOVE.L 4.W,A6
JSR _LVODoIO(A6) ; Write bootblock
MOVE.L #DateStamp,D1
MOVE.L DOSBase,A6
JSR _LVODateStamp(A6)
MOVE.L FormatDataPtr,A2
CLR.W 10(A2)
MOVE.L #2,(A2)
MOVE.W #$0048,14(A2)
MOVE.L #$FFFFFFFF,$0138(A2)
MOVE.L #$0553542D,$01B0(A2)
MOVE.W DiskNumText1,$01B4(A2)
MOVE.W #1,$01FE(A2)
LEA DateStamp,A0
MOVE.L (A0),D0
MOVE.L D0,$01A4(A2)
MOVE.L D0,$01E4(A2)
MOVE.L 4(A0),D1
MOVE.L D1,$01A8(A2)
MOVE.L D1,$01E8(A2)
MOVE.L 8(A0),D2
MOVE.L D2,$01AC(A2)
MOVE.L D2,$01EC(A2)
MOVE.L #$C00,D6
MOVE.W #$371,$013E(A2)
MOVE.L #$C000C037,$0200(A2)
LEA $0204(A2),A3
MOVEQ #55-1,D0
df_loop2
MOVE.L #$FFFFFFFF,(A3)+
DBRA D0,df_loop2
MOVE.W #$3FFF,$0272(A2)
MOVE.W #$3FFF,$02DC(A2)
MOVE.L A2,A3
MOVE.L A3,A4
MOVEQ #1,D7
df_loop3
MOVEQ #128-1,D1
MOVEQ #0,D0
MOVE.L D0,$0014(A4)
df_loop4
SUB.L (A3)+,D0
DBRA D1,df_loop4
MOVE.L D0,$0014(A4)
LEA $200(A4),A4
DBRA D7,df_loop3
LEA TrackdiskIOExtTD,A1
MOVE.L #$0006E000,IO_OFFSET(A1)
MOVE.W #CMD_WRITE,IO_COMMAND(A1)
MOVE.L #1024,IO_LENGTH(A1)
MOVE.L 4.W,A6
JSR _LVODoIO(A6)
LEA TrackdiskIOExtTD,A1
MOVE.W #CMD_UPDATE,IO_COMMAND(A1)
JSR _LVODoIO(A6) ; Flush write buffer
df_cleanup
LEA TrackdiskIOExtTD,A1
MOVE.W #TD_MOTOR,IO_COMMAND(A1)
CLR.L IO_LENGTH(A1)
JSR _LVODoIO(A6) ; Turn off the motor
MOVE.L Fmt_tja,A0
MOVE.L $0024(A0),A0
OR.B #2,$0040(A0)
LEA TrackdiskIOExtTD,A1
MOVE.L 4.W,A6
JSR _LVOCloseDevice(A6)
LEA TrackdiskPort,A1
JSR _LVORemPort(A6)
MOVE.L FormatDataPtr,A1
MOVE.L #5632,D0
JSR PTFreeMem
CMP.W #160,CylinderNumber
BNE.W df_skip2
CMP.W #'00',DiskNumText1
BNE.W df_skip2
MOVE.L DOSBase,A6
MOVE.L #150,D1 ; Wait 3 sec
JSR _LVODelay(A6)
MOVE.L #LockNameDF0,D1
MOVEQ #-2,D2
JSR _LVOLock(A6)
MOVE.L D0,D6
BEQ.B df_skip2
MOVE.L D0,D1
JSR _LVOCurrentDir(A6)
MOVE.L D0,D7
MOVE.L #ModulesText,D1
JSR _LVOCreateDir(A6)
MOVE.L D0,D1
JSR _LVOUnLock(A6)
MOVE.L #SongsText,D1
JSR _LVOCreateDir(A6)
MOVE.L D0,D1
JSR _LVOUnLock(A6)
MOVE.L #SamplesText,D1
JSR _LVOCreateDir(A6)
MOVE.L D0,D1
JSR _LVOUnLock(A6)
MOVE.L #TracksText,D1
JSR _LVOCreateDir(A6)
MOVE.L D0,D1
JSR _LVOUnLock(A6)
MOVE.L #PatternsText,D1
JSR _LVOCreateDir(A6)
MOVE.L D0,D1
JSR _LVOUnLock(A6)
MOVE.L D7,D1
JSR _LVOCurrentDir(A6)
MOVE.L D6,D1
JSR _LVOUnLock(A6)
df_skip2
BSR.W SetNormalPtrCol
JSR ShowAllRight
BSR.W ClearFileNames
ST UpdateFreeMem
RTS
df_memerr
BSR.W OutOfMemErr
BRA.B df_skip2
ClearCylinder
MOVE.L FormatDataPtr,A0
MOVE.W #1408-1,D0
MOVEQ #0,D1
ccloop MOVE.L D1,(A0)+
DBRA D0,ccloop
RTS
FormatAsText dc.b 'Format as ST-'
FormatDiskNum1 dc.b $30
FormatDiskNum2 dc.b $30
dc.b $3F
dc.b 0
dc.b 0
LockNameDF0 dc.b "df0:",0
EVEN
;---- Clear All Data ----
ClearAll
ST DisableScopeMuting
ADDQ.L #1,LaHeTx
MOVE.B DisableAnalyzer,SaveDA
MOVE.B ScopeEnable(PC),SaveScope
SF ScopeEnable
LEA PleaseSelectText,A0
JSR ShowStatusText
BSR.W StorePtrCol
BSR.W SetWaitPtrCol
BSR.W Wait_4000
CMP.W #1,CurrScreen
BNE.B clbskip
TST.B DisableAnalyzer
BNE.B clbskip
ST DisableAnalyzer
BSR.W ClearAnaHeights
BSR.W ClearRightArea
clbskip LEA ClearBoxData,A1
BSR.W SwapBoxMem
BSR.W WaitForButtonUp
BSR.W Wait_4000
clearbuttoncheck
BTST #2,$DFF016 ; right mouse button
BEQ.W ClrCancel
BSR.W CheckPatternRedraw2
BSR.W DoKeyBuffer
MOVE.B RawKeyCode,D0
CMP.B #33,D0 ; Pressed S
BEQ.W ClrSamples
CMP.B #24,D0 ; Pressed O
BEQ.W ClrSong
CMP.B #32,D0 ; Pressed A
BEQ.W ClrAll
CMP.B #51,D0 ; Pressed C
BEQ.W ClrCancel
CMP.B #69,D0 ; Pressed Esc
BEQ.W ClrCancel
BTST #6,$BFE001 ; left mouse button
BNE.B clearbuttoncheck
MOVE.W MouseX(PC),D0
MOVE.W MouseY(PC),D1
CMP.W #166,D0
BLO.B clearbuttoncheck
CMP.W #257,D0
BHI.B clearbuttoncheck
CMP.W #58,D1
BLO.B clearbuttoncheck
CMP.W #84,D1
BHI.B clearbuttoncheck
CMP.W #204,D0
BHS.B samporcancel
CMP.W #198,D0
BLS.B songorall
BRA.B clearbuttoncheck
songorall
CMP.W #74,D1
BHS.B ClrAll
CMP.W #68,D1
BLS.W ClrSong
BRA.W clearbuttoncheck
samporcancel
CMP.W #74,D1
BHS.B ClrCancel
CMP.W #68,D1
BLS.B ClrSamples
BRA.W clearbuttoncheck
RemoveClearBox
LEA ClearBoxData,A1
BSR.W SwapBoxMem
JSR ShowAllRight
BSR.W ClearAnaHeights
MOVE.B SaveDA,DisableAnalyzer
MOVE.B SaveScope,ScopeEnable
BSR.W RestorePtrCol
CLR.B RawKeyCode
RTS
ClrCancel
BSR.B RemoveClearBox
BRA.W SetErrorPtrCol
ClrAll BSR.B RemoveClearBox
BSR.W ClearPosEdNames
BSR.W DoClearSong
BSR.W StopIt
BSR.B ClrSampleInfo
BSR.W SetNormalPtrCol
SF EdEnable
MOVE.W #1,InsNum
SF DisableScopeMuting
BRA.W DisplayMainAll
ClrSamples
BSR.B RemoveClearBox
BSR.W StopIt
BSR.B ClrSampleInfo
BSR.W SetNormalPtrCol
SF EdEnable
MOVE.W #1,InsNum
SF DisableScopeMuting
BRA.W DisplayMainAll
ClrSong BSR.W RemoveClearBox
BSR.W ClearPosEdNames
BSR.B DoClearSong
BSR.W SetNormalPtrCol
SF DisableScopeMuting
BRA.W DisplayMainAll
ClrSampleInfo
MOVE.L D1,-(SP)
BSR.W GiveBackInstrMem
MOVE.L SongDataPtr,A0
LEA sd_sampleinfo(A0),A0
MOVE.W #(31*30)-1,D0
csiloop CLR.B (A0)+
DBRA D0,csiloop
MOVE.L SongDataPtr,A1
LEA sd_sampleinfo(A1),A1
MOVEQ #31-1,D0
MOVEQ #1,D1
caloop2 MOVE.W D1,28(A1)
LEA 30(A1),A1
DBRA D0,caloop2
LEA SampleLengthAdd(PC),A3
MOVEQ #33-1,D0
MOVEQ #0,D1
csilop2 MOVE.W D1,(A3)+
DBRA D0,csilop2
MOVE.L (SP)+,D1
JMP RedrawSample
DoClearSong
BSR.W StopIt
CLR.B RawKeyCode
MOVE.L SongDataPtr,A0
MOVE.L A0,A1
MOVEQ #20-1,D0
docla2x CLR.B (A0)+
DBRA D0,docla2x
MOVE.L A1,A2
ADD.L SongAllocSize(PC),A2
LEA 950(A1),A1
MOVEQ #0,D0
caloop MOVE.W D0,(A1)+
CMP.L A1,A2
BNE.B caloop
MOVE.L SongDataPtr,A0
MOVE.W #$17F,sd_numofpatt(A0)
MOVE.L #'M.K.',sd_magicid(A0) ; M.K. all the way...
SF EdEnable
CLR.L CurrPos
CLR.L SongPosition
CLR.L PatternPosition
CLR.L PlaybackSecs
CLR.W BlockMarkFlag
CLR.B MetroFlag
MOVE.W #1,EditMoveAdd
MOVEQ #0,D0
MOVE.W DefaultSpeed,D0
MOVE.L D0,CurrSpeed
MOVE.W Tempo,RealTempo
BSR.W SetTempo
BSR.W RestoreEffects2
BSR.W RestoreFKeyPos2
BSR.B UnmuteAll
MOVE.W #1,InsNum
MOVE.L #6,CurrSpeed
CLR.L PatternNumber
CLR.W ScrPattPos
BSR.W SetScrPatternPos
JMP RedrawPattern
UnmuteAll
MOVE.W #1,audchan1toggle
MOVE.W #1,audchan2toggle
MOVE.W #1,audchan3toggle
MOVE.W #1,audchan4toggle
SF n_muted+audchan1temp
SF n_muted+audchan2temp
SF n_muted+audchan3temp
SF n_muted+audchan4temp
TST.L RunMode
BEQ.B uaskip ; don't set back volumes if song is not playing
BSR.W SetBackCh1Vol
BSR.W SetBackCh2Vol
BSR.W SetBackCh3Vol
BSR.W SetBackCh4Vol
uaskip
BRA.W RedrawToggles
ToggleMute
CLR.B RawKeyCode
TST.W ShiftKeyStatus
BEQ.B tomuskp
CLR.W audchan1toggle
CLR.W audchan2toggle
CLR.W audchan3toggle
CLR.W audchan4toggle
ST n_muted+audchan1temp
ST n_muted+audchan2temp
ST n_muted+audchan3temp
ST n_muted+audchan4temp
CLR.W $DFF0A8
CLR.W $DFF0B8
CLR.W $DFF0C8
CLR.W $DFF0D8
tomuskp MOVEQ #0,D0
MOVE.W PattCurPos,D0
DIVU.W #6,D0
MULU.W #11,D0
ADDQ.W #4,D0
MOVE.L D6,-(SP)
MOVEQ #1,D6
BSR.W DoToggleMute
MOVE.L (SP)+,D6
RTS
SetBackCh1Vol
MOVE.L A0,-(SP)
MOVE.L D0,-(SP)
LEA audchan1temp,A0
MOVEQ #0,D0
MOVE.B n_volume(A0),D0
MOVE.W D0,$DFF0A8
MOVE.L (SP)+,D0
MOVE.L (SP)+,A0
RTS
SetBackCh2Vol
MOVE.L A0,-(SP)
MOVE.L D0,-(SP)
LEA audchan2temp,A0
MOVEQ #0,D0
MOVE.B n_volume(A0),D0
MOVE.W D0,$DFF0B8
MOVE.L (SP)+,D0
MOVE.L (SP)+,A0
RTS
SetBackCh3Vol
MOVE.L A0,-(SP)
MOVE.L D0,-(SP)
LEA audchan3temp,A0
MOVEQ #0,D0
MOVE.B n_volume(A0),D0
MOVE.W D0,$DFF0C8
MOVE.L (SP)+,D0
MOVE.L (SP)+,A0
RTS
SetBackCh4Vol
MOVE.L A0,-(SP)
MOVE.L D0,-(SP)
LEA audchan4temp,A0
MOVEQ #0,D0
MOVE.B n_volume(A0),D0
MOVE.W D0,$DFF0D8
MOVE.L (SP)+,D0
MOVE.L (SP)+,A0
RTS
RestoreEffects
MOVEQ #0,D0
MOVE.W DefaultSpeed,D0
MOVE.L D0,CurrSpeed
MOVE.W Tempo,RealTempo
BSR.W SetTempo
BSR.B RestoreEffects2
CLR.B RawKeyCode
LEA EfxRestoredText(PC),A0
JSR ShowStatusText
BSR.W WaitALittle
JMP ShowAllRight
RestoreEffects2
LEA audchan1temp,A0
BSR.B reefsub
LEA audchan2temp,A0
BSR.B reefsub
LEA audchan3temp,A0
BSR.B reefsub
LEA audchan4temp,A0
reefsub CLR.B n_wavecontrol(A0)
CLR.B n_glissfunk(A0)
CLR.B n_finetune(A0)
CLR.B n_loopcount(A0)
CLR.B n_sampleoffset2(A0) ; used for quadrascope/sample pos line
RTS
RestoreFKeyPos
CLR.B RawKeyCode
LEA PosRestoredText(PC),A0
JSR ShowStatusText
BSR.W WaitALittle
JSR ShowAllRight
RestoreFKeyPos2
CLR.W F6pos
MOVE.W #16,F7pos
MOVE.W #32,F8pos
MOVE.W #48,F9pos
MOVE.W #63,F10pos
RTS
EfxRestoredText dc.b 'efx restored !',0
PosRestoredText dc.b 'pos restored !',0
EVEN
GiveBackInstrMem
MOVEQ #1,D7
gbimloop
MOVE.W D7,D2
LSL.W #2,D2
LEA SamplePtrs,A0
MOVE.L (A0,D2.W),D1
BEQ.B gbimskip
MOVE.L 124(A0,D2.W),D0
CLR.L (A0,D2.W)
CLR.L 124(A0,D2.W)
MOVE.L D1,A1
JSR PTFreeMem
gbimskip
ADDQ.W #1,D7
CMP.W #32,D7
BNE.B gbimloop
ST UpdateFreeMem
JMP FreeCopyBuf
;---- Setup ----
Setup CMP.W #7,LastSetupScreen
BEQ.W Setup2
CLR.W LastSetupScreen
BSR.W WaitForButtonUp
MOVE.W #5,CurrScreen
ST DisableAnalyzer
ST NoSampleInfo
BSR.W Clear100Lines
BSR.W ShowSetupScreen
BEQ.W ExitSetup
RefreshSetup
BSR.B AdjustVuSprites
BSR.W UpdateCursorPos
BSR.W UpdateSysReq
BSR.W SetScreenColors
BSR.W Show_MS
CMP.W #5,CurrScreen
BNE.W Return1
BSR.W MarkColor
BSR.W ShowSetupToggles
BSR.W ShowSplit
BSR.W ShowPrintPath
BSR.W ShowKeyRepeat
BSR.W ShowExtCommand
BSR.W ShowMultiSetup
BSR.W ShowConfigNumber
BRA.W ShowAccidental ; Always last (redraws pattern) !
AdjustVuSprites
LEA CopperList1+2,A0
TST.B ScreenAdjustFlag
BEQ.B avusskip
MOVE.W #$2C71,(A0)
MOVE.W #$2CB1,4(A0)
MOVE.W #$0030,8(A0)
MOVE.W #$00C8,12(A0)
MOVE.W #$E953,VUSpriteData1
MOVE.W #$E977,VUSpriteData2
MOVE.W #$E99B,VUSpriteData3
MOVE.W #$E9BF,VUSpriteData4
RTS
avusskip
MOVE.W #$2C81,(A0)
MOVE.W #$2CC1,4(A0)
MOVE.W #$0038,8(A0)
MOVE.W #$00D0,12(A0)
MOVE.W #$E95B,VUSpriteData1
MOVE.W #$E97F,VUSpriteData2
MOVE.W #$E9A3,VUSpriteData3
MOVE.W #$E9C7,VUSpriteData4
RTS
ShowSetupScreen
MOVE.L SetupMemPtr(PC),D0
BNE.W DecompactSetup
BSR.B SaveMainPic
TST.L SetupMemPtr
BEQ.W Return1
BRA.W DecompactSetup
SaveMainPic
MOVE.L #8000,D0
MOVEQ #MEMF_PUBLIC,D1
JSR PTAllocMem
MOVE.L D0,SetupMemPtr
BEQ.W OutOfMemErr
MOVE.L D0,A1
LEA BitplaneData,A0
MOVEQ #2-1,D2 ; two bitplanes
sssloop1
MOVE.W #1000-1,D0 ; 100 scanlines
sssloop2
MOVE.L (A0)+,(A1)+
DBRA D0,sssloop2
LEA 6240(A0),A0
DBRA D2,sssloop1
RTS
RestoreMainPic
MOVE.L SetupMemPtr(PC),D0
BEQ.B ssxexit
MOVE.L D0,A1
LEA BitplaneData,A0
MOVEQ #2-1,D2 ; two bitplanes
ssxloop1
MOVE.W #1000-1,D0 ; 100 scanlines
ssxloop2
MOVE.L (A1)+,(A0)+
DBRA D0,ssxloop2
LEA 6240(A0),A0
DBRA D2,ssxloop1
ssxfree
MOVE.L SetupMemPtr(PC),A1
CLR.L SetupMemPtr
MOVE.L #8000,D0
JSR PTFreeMem
ssxexit RTS
CNOP 0,4
SetupMemPtr dc.l 0
DecompactSetup2
LEA Setup2Data+4,A0
MOVE.L #Setup2Size-4-8,D0
BRA.B decoset
DecompactSetup
LEA SetupScreenData+4,A0
MOVE.L #SetupScreenSize-4-8,D0
decoset LEA BitplaneData,A1
MOVE.L A1,A2
LEA 4000(A2),A2
MOVEM.L D3/D4,-(SP)
MOVEQ #-75,D3 ; 181 signed (compactor code)
MOVEQ #-1,D4
dcsloop MOVE.B (A0)+,D1
CMP.B D3,D1
BEQ.B DecodeIt2
MOVE.B D1,(A1)+
CMP.L A2,A1
BLO.B dcslop2
LEA 6240(A1),A1
MOVE.L D4,A2
dcslop2
SUBQ.L #1,D0
BGT.B dcsloop
MOVEM.L (SP)+,D3/D4
MOVEQ #-1,D0
RTS
DecodeIt2
MOVEQ #0,D1
MOVE.B (A0)+,D1
MOVE.B (A0)+,D2
dcdlop2 MOVE.B D2,(A1)+
CMP.L A2,A1
BLO.B dcdskp2
LEA 6240(A1),A1
MOVE.L D3,A2
dcdskp2 DBRA D1,dcdlop2
SUBQ.L #2,D0
BRA.B dcslop2
; Gadgets
CheckSetupGadgs
TST.L SplitAddress
BEQ.B csgskip
CLR.L SplitAddress
BSR.W ShowSplit
csgskip
MOVE.W MouseX2,D0
MOVE.W MouseY2,D1
CMP.W #210,D0
BHS.W SetupMenu3
CMP.W #108,D0
BHS.B SetupMenu2
;---- Menu 1 ----
CMP.W #11,D1
BLS.W LoadConfig
CMP.W #22,D1
BLS.W SaveConfig
CMP.W #33,D1
BLS.W ResetAll
CMP.W #44,D1
BLS.W ExtCommand
CMP.W #55,D1
BLS.W MultiSetup
CMP.W #66,D1
BLS.W SetRed
CMP.W #77,D1
BLS.W SetGreen
CMP.W #88,D1
BLS.W SetBlue
CMP.W #99,D1
BLS.W ColorGadgets
RTS
SetupMenu2
CMP.W #11,D1
BLS.B sm2exit
CMP.W #55,D1
BLS.W SetSplit
CMP.W #66,D1
BLS.W SetKeyRepeat
CMP.W #77,D1
BLS.W ToggleAccidental
CMP.W #88,D1
BLS.W PrintSong
CMP.W #99,D1
BLS.W EnterPrintPath
sm2exit RTS
SetupMenu3
CMP.W #11,D1
BLS.B ExitOrClear
CMP.W #22,D1
BLS.W ToggleSplit
CMP.W #33,D1
BLS.W ToggleFilter
CMP.W #44,D1
BLS.W ToggleTransDel
CMP.W #55,D1
BLS.W ToggleShowDec
CMP.W #66,D1
BLS.W ToggleAutoDir
CMP.W #77,D1
BLS.W ToggleAutoExit
CMP.W #88,D1
BLS.W ToggleModOnly
CMP.W #99,D1
BLS.W ToggleMIDI
RTS
ExitOrClear
CMP.W #263,D0
BLS.W ClearSplit
CMP.W #306,D0
BHS.W Setup2
ExitSetup
BSR.W WaitForButtonUp
CMP.W #7,CurrScreen
BNE.B exsetupskip
TST.B SwitchTogglesFlag
BEQ.B exsetupskip
BSR.W Setup2SwitchToggles
exsetupskip
MOVE.W CurrScreen,LastSetupScreen
CLR.B RawKeyCode
CLR.L SplitAddress
BSR.W RestoreMainPic
SF NoSampleInfo
BSR.W SetupVUCols
BSR.W SetupAnaCols
BSR.W Clear100Lines
BRA.W DisplayMainAll
LastSetupScreen dc.w 0
ToggleSplit
EOR.B #1,SplitFlag
BRA.W ShowSetupToggles
ToggleFilter
BCHG #1,$BFE001
BRA.W ShowSetupToggles
ToggleTransDel
EOR.B #1,TransDelFlag
BRA.B ShowSetupToggles
ToggleShowDec
EOR.B #1,ShowDecFlag
ST UpdateFreeMem
BRA.B ShowSetupToggles
ToggleAutoDir
EOR.B #1,AutoDirFlag
BRA.B ShowSetupToggles
ToggleAutoExit
EOR.B #1,AutoExitFlag
BRA.B ShowSetupToggles
ToggleModOnly
EOR.B #1,ModOnlyFlag
LEA FileNamesPtr(PC),A0
CLR.L 4(A0)
BRA.B ShowSetupToggles
ToggleMIDI
EOR.B #1,MIDIFlag
BSR.B ShowSetupToggles
tstmidi TST.B MIDIFlag
BNE.B xOpenMidi
JMP CloseMIDI
xOpenMidi JMP OpenMIDI
ClearSplit
BSR.W WaitForButtonUp
LEA ClearSplitText,A0
BSR.W AreYouSure
BNE.B clspexit
LEA SplitData,A0
MOVEQ #16-1,D0
clsploop
CLR.B (A0)+
DBRA D0,clsploop
BRA.B ShowSplit
clspexit RTS
ShowSetupToggles
CLR.B RawKeyCode
BSR.W Show_MS
CMP.W #5,CurrScreen
BNE.B clspexit
MOVE.B $BFE001,D0
LSR.B #1,D0
AND.B #1,D0
EOR.B #1,D0
MOVE.B D0,FilterFlag
LEA SplitFlag,A4
MOVE.W #3,TextLength
MOVEQ #8-1,D7
MOVE.W #636,D6
sstloop
MOVE.W D6,TextOffset
LEA ToggleOFFText(PC),A0
TST.B (A4)+
BEQ.B sstskip
LEA ToggleONText(PC),A0
sstskip
JSR ShowText2
ADD.W #440,D6
DBRA D7,sstloop
BRA.W WaitForButtonUp
ToggleONText2 dc.b ' '
ToggleONText dc.b 'on '
ToggleOFFText dc.b 'off '
ToggleCURText dc.b 'cur '
ToggleBUFText dc.b 'buf '
EVEN
ShowSplit
BSR.B CalculateSplit
CMP.W #5,CurrScreen
BNE.B shspexit
LEA SplitData,A3
MOVE.L NoteNamesPtr,A4
MOVEQ #0,D5
MOVE.W #614,D6
CLR.W WordNumber
shsploop
MOVE.W D6,TextOffset
MOVE.B (A3,D5.W),WordNumber+1 ; instr
JSR PrintHexByte
ADDQ.W #4,D6
MOVE.W D6,D1
MOVEQ #0,D0
MOVE.B 1(A3,D5.W),D0 ; note
LSL.W #2,D0
LEA (A4,D0.W),A0
MOVEQ #4,D0
JSR ShowText3
ADDQ.L #5,D6
MOVE.W D6,D1
MOVEQ #0,D0
MOVE.B 2(A3,D5.W),D0 ; trans
LSL.W #2,D0
LEA (A4,D0.W),A0
MOVEQ #4,D0
JSR ShowText3
ADD.W #431,D6
ADDQ.W #4,D5
CMP.W #16,D5
BNE.B shsploop
shspexit
RTS
CalculateSplit
LEA SplitTransTable,A0
LEA SplitInstrTable,A1
LEA SplitData,A2
MOVEQ #0,D0
casploop
MOVE.B D0,(A0,D0.W)
CLR.B (A1,D0.W)
ADDQ.W #1,D0
CMP.W #37,D0
BLS.B casploop
MOVE.B 1(A2),-(SP)
MOVE.B 1+4(A2),-(SP)
MOVE.B 1+8(A2),-(SP)
MOVE.B 1+12(A2),-(SP) ; note
MOVEQ #4-1,D4
caspbigloop
MOVEQ #127,D0
MOVEQ #0,D1
MOVEQ #0,D2
casploop2
CMP.B 1(A2,D1.W),D0 ; note
BLS.B caspskip
MOVE.L D1,D2
MOVE.B 1(A2,D1.W),D0 ; note
caspskip
ADDQ.W #4,D1
CMP.W #16,D1
BNE.B casploop2
MOVEQ #0,D0
MOVE.B 1(A2,D2.W),D0 ; note
MOVE.B #127,1(A2,D2.W) ; note
MOVE.B 2(A2,D2.W),D1 ; trans
casploop3
MOVE.B D1,(A0,D0.W)
MOVE.B (A2,D2.W),(A1,D0.W) ; instr
ADDQ.W #1,D1
CMP.W #36,D1
BLO.B caspskip2
MOVEQ #35,D1
caspskip2
ADDQ.W #1,D0
CMP.W #36,D0
BLO.B casploop3
DBRA D4,caspbigloop
MOVE.B (SP)+,1+12(A2)
MOVE.B (SP)+,1+8(A2)
MOVE.B (SP)+,1+4(A2)
MOVE.B (SP)+,1(A2) ; note
RTS
SetSplit
LEA SplitData,A2
AND.L #$FFFF,D1
SUBQ.W #1,D1
DIVU.W #11,D1
SUBQ.W #1,D1
MOVE.W D1,D7
LSL.W #2,D7
MULU.W #440,D1
ADD.W #600,D1
CMP.W #176,D0
BHS.B SetSplitTranspose
CMP.W #136,D0
BHS.B SetSplitNote
ADD.W #14,D1
MOVE.W D1,TextOffset
BSR.W GetHexByte
TST.W AbortHexFlag
BNE.W ShowSplit
CMP.B #$1F,D0
BLS.B setskip
MOVEQ #$1F,D0
setskip MOVE.B D0,(A2,D7.W) ; instr
BRA.W ShowSplit
SetSplitNote
MOVE.L D1,-(SP)
BSR.W ShowSplit
MOVE.L (SP)+,D1
ADD.W #18,D1
MOVEQ #3,D0
LEA SpcNoteText,A0
JSR ShowText3
LEA 1(A2,D7.W),A0 ; note
MOVE.L A0,SplitAddress
BRA.W WaitForButtonUp
SetSplitTranspose
MOVE.L D1,-(SP)
BSR.W ShowSplit
MOVE.L (SP)+,D1
ADD.W #$17,D1
MOVEQ #3,D0
LEA SpcNoteText,A0
JSR ShowText3
LEA 2(A2,D7.W),A0 ; trans
MOVE.L A0,SplitAddress
BRA.W WaitForButtonUp
SetKeyRepeat
CMP.W #188,D0
BHS.B skrep2
MOVE.W #2381,TextOffset
BSR.W GetHexByte
TST.W AbortHexFlag
BNE.B ShowKeyRepeat
MOVE.B D0,KeyRepDelay+1
BRA.B ShowKeyRepeat
skrep2 MOVE.W #2384,TextOffset
BSR.W GetHexByte
TST.W AbortHexFlag
BNE.B ShowKeyRepeat
MOVE.B D0,KeyRepSpeed+1
ShowKeyRepeat
MOVE.W #2381,TextOffset
MOVE.W KeyRepDelay,WordNumber
JSR PrintHexByte
ADDQ.W #1,TextOffset
MOVE.W KeyRepSpeed,WordNumber
JMP PrintHexByte
ToggleAccidental
MOVE.L #NoteNames1,NoteNamesPtr
EOR.B #1,Accidental
BEQ.B ShowAccidental
MOVE.L #NoteNames2,NoteNamesPtr
ShowAccidental
LEA AccidentalText(PC),A0
TST.B Accidental
BEQ.B shacskp
LEA AccidentalText+1(PC),A0
shacskp MOVEQ #1,D0
MOVE.W #2824,D1
JSR ShowText3
BRA RedrawPattern
AccidentalText dc.b '#'
EVEN
Return5
RTS
LoadConfigOnStartup
BRA.W DoLoadConfig
LoadConfig
CMP.W #84,D0
BHS.W SetConfigNumber
LEA LoadConfigText,A0
BSR.W AreYouSure
BNE.B Return5
BSR.W WaitForButtonUp
LEA LoadingCfgText(PC),A0
BSR.W ShowStatusText
DoLoadConfig
BSR.W StorePtrCol
BSR.W PutConfigNumber
MOVE.L #ConfigName,D1
MOVE.L #1005,D2
MOVE.L DOSBase,A6
JSR _LVOOpen(A6)
MOVE.L D0,D7
BNE.B cfgopok
LEA PTPath,A0
BSR.W CopyPath
LEA ConfigName(PC),A0
MOVEQ #13-1,D0
cfgnlop MOVE.B (A0)+,(A1)+
DBRA D0,cfgnlop
MOVE.L #FileName,D1
MOVE.L #1005,D2
MOVE.L DOSBase,A6
JSR _LVOOpen(A6)
MOVE.L D0,D7
BEQ.W ConfigErr
cfgopok BSR.W SetDiskPtrCol
MOVE.L D7,D1
CLR.L ConfigID
CLR.L ConfigID2
MOVE.L #ConfigID,D2
MOVEQ #8,D3
JSR _LVORead(A6)
CMP.L #"PT2.",ConfigID
BNE.B cfgerr2
CMP.L #"3 Co",ConfigID2
BNE.B cfgerr2
LEA SetupData+8,A0
MOVE.L D7,D1
MOVE.L A0,D2
MOVE.L #ConfigFileSize-8,D3
JSR _LVORead(A6)
lcfgend MOVE.L D7,D1
JSR _LVOClose(A6)
BSR.W ShowAllRight
BSR.W RestorePtrCol
cfgupda
BSR.W CopyCfgData
BSR.W tstmidi
JSR ChangeCopList
MOVE.L #NoteNames1,NoteNamesPtr
TST.B Accidental
BEQ.B cfgoskip
MOVE.L #NoteNames2,NoteNamesPtr
cfgoskip
BSR.W RedrawPattern
BRA.W RefreshSetup
ConfigErr
BSET #2,InitError
LEA FileNotFoundText(PC),A0
cferr BSR ShowStatusText
MOVE.W #ERR_WAIT_TIME,WaitTime
BRA ErrorRestoreCol
cfgerr2 BSR.B ConfigErr2
BRA.B lcfgend
ConfigErr2
BSET #3,InitError
LEA NotAConfFileText(PC),A0
BRA.B cferr
ConfigErr3
LEA CantCreateFiText(PC),A0
BRA.B cferr
FileNotFoundText dc.b "config not found!",0
NotAConfFileText dc.b "not a config file",0
CantCreateFiText dc.b "can't create file",0
EVEN
SaveConfig
CMP.W #84,D0
BHS.W SetConfigNumber
LEA SaveConfigText,A0
BSR.W AreYouSure
BNE.W cfglrts
BSR.W StorePtrCol
BSR.W SetDiskPtrCol
BSR.W PutConfigNumber
LEA SavingCfgText(PC),A0
BSR.W ShowStatusText
MOVE.L DOSBase,A6
LEA PTPath,A0
BSR.W CopyPath
LEA TrackPath2,A0
LEA TrackPath,A2
MOVEQ #8-1,D0
cfgllop1 MOVE.L (A0)+,(A2)+
DBRA D0,cfgllop1
LEA PattPath2,A0
LEA PattPath,A2
MOVEQ #8-1,D0
cfgllop2 MOVE.L (A0)+,(A2)+
DBRA D0,cfgllop2
LEA ConfigName(PC),A0
MOVEQ #13-1,D0
cfgllop3 MOVE.B (A0)+,(A1)+
DBRA D0,cfgllop3
MOVE.L #FileName,D1
MOVE.L #1006,D2
JSR _LVOOpen(A6)
MOVE.L D0,D7
BEQ.W ConfigErr3
MOVE.L D0,D1
MOVE.L #SetupData,D2
MOVE.W #ConfigFileSize,D3
JSR _LVOWrite(A6)
CMP.L #ConfigFileSize,D3
BEQ.B cfglskip
JSR CantSaveFile
cfglskip
MOVE.L D7,D1
JSR _LVOClose(A6)
BSR.W ShowAllRight
BRA.W RestorePtrCol
cfglrts
RTS
SetConfigNumber
MOVE.W #611,TextOffset
BSR.W GetHexByte
TST.W AbortHexFlag
BNE.B ShowConfigNumber
MOVE.W D0,ConfigNumber
ShowConfigNumber
MOVE.W #611,TextOffset
MOVE.W ConfigNumber(PC),WordNumber
BRA.W PrintHexByte
PutConfigNumber
MOVE.W ConfigNumber(PC),D0
LEA ConfigName+12(PC),A0
JMP IntToHex2
CNOP 0,4
ConfigNumber dc.w 0
ConfigID dc.l 0
ConfigID2 dc.l 0
ConfigName dc.b 'PT.Config-00',0
LoadingCfgText dc.b 'loading config',0
SavingCfgText dc.b 'saving config',0
EVEN
ResetAll
LEA ResetAllText,A0
BSR.W AreYouSure
BNE.W Return2
DoResetAll
LEA DefaultSetupData,A0
LEA SetupData,A1
MOVE.W #ConfigFileSize-1,D0
rsaloop MOVE.B (A0)+,(A1)+
DBRA D0,rsaloop
BRA.W cfgupda
ExtCommand
CMP.W #11,D0
BLO.B excolab
BSR.W StorePtrCol
BSR.W SetWaitPtrCol
LEA ExtCommands,A6
MOVEQ #0,D1
MOVE.B ExtCmdNumber(PC),D1
LSL.B #5,D1
ADD.L D1,A6
MOVE.L A6,ShowTextPtr
MOVE.L A6,TextEndPtr
ADD.L #31,TextEndPtr
MOVE.W #11,TextLength
MOVE.W #1482,A4
BSR.W GetTextLine
BRA.W RestorePtrCol
ShowExtCommand
LEA ExtCommands,A0
MOVEQ #0,D1
MOVE.B ExtCmdNumber(PC),D1
LSL.B #5,D1
ADD.L D1,A0
MOVEQ #11,D0
MOVE.W #1482,D1
BRA.W ShowText3
excolab BTST #2,$DFF016 ; right mouse button
BEQ.B excorun
ADDQ.B #1,ExtCmdNumber
AND.B #7,ExtCmdNumber
BSR.B ShowExtCommand
BSR.W Wait_4000
BSR.W Wait_4000
BRA.W Wait_4000
excorun LEA ExtCommands,A0
MOVEQ #0,D1
MOVE.B ExtCmdNumber(PC),D1
LSL.B #5,D1
ADD.L D1,A0
TST.B (A0)
BEQ.W Return2
MOVE.L A0,ExtCmdAddress
MOVE.L IntuitionBase,A6
JSR _LVOOpenWorkbench(A6)
JSR _LVOWBenchToFront(A6)
MOVE.L #ExtCmdConsole,D1
MOVE.L #1005,D2
MOVE.L DOSBase,A6
JSR _LVOOpen(A6)
MOVE.L D0,ExtCmdWindow
BEQ.B winderr
LSL.L #2,D0
MOVE.L D0,A0
MOVE.L PTProcess,A1
MOVE.L 8(A0),$A4(A1)
BSR.W GotoCLI
MOVE.L ExtCmdWindow(PC),D1
BEQ.W Return2
MOVE.L DOSBase,A6
JSR _LVOClose(A6)
CLR.L ExtCmdWindow
RTS
winderr LEA ConsoleErrText(PC),A0
BSR.W ShowStatusText
BRA.W SetErrorPtrCol
CNOP 0,4
ExtCmdAddress dc.l 0
ExtCmdWindow dc.l 0
ExtCmdConsole dc.b "CON:0/0/640/150/ProTracker Output Window",0
ConsoleErrText dc.b "Can't open window",0
ExtCmdNumber dc.b 0
EVEN
MultiSetup
CMP.W #44,D0
BLO.W Return2
BSR.W StorePtrCol
BSR.W SetWaitPtrCol
MOVE.W #1,GetLineFlag
SUB.W #44,D0
LSR.W #4,D0
MOVE.B D0,musepos
museset MOVEQ #0,D0
MOVE.B musepos(PC),D0
MOVE.L D0,D1
LSL.W #4,D1
MOVE.W #52,LineCurX
MOVE.W #53,LineCurY
ADD.W D1,LineCurX
LEA MultiModeNext,A1
LEA (A1,D0.W),A1
BSR.W UpdateLineCurPos
muselop BSR.W GetHexKey
CMP.B #128,D1
BEQ.B musenul
TST.B D1
BEQ.B musenul
CMP.B #4,D1
BHI.B muselop
MOVE.B D1,(A1)
BSR.B ShowMultiSetup
MOVEQ #1,D0
musenul TST.B D0
BEQ.B museabo
ADD.B D0,musepos
AND.B #3,musepos
BSR.W Wait_4000
BSR.W Wait_4000
BSR.W Wait_4000
BRA.B museset
museabo BSR.W RestorePtrCol
CLR.W GetLineFlag
CLR.W LineCurX
MOVE.W #270,LineCurY
BSR.W UpdateLineCurPos
ShowMultiSetup
MOVE.W #1926,TextOffset
MOVE.B MultiModeNext,D0
BSR.W PrintHexDigit
MOVE.W #1928,TextOffset
MOVE.B MultiModeNext+1,D0
BSR.W PrintHexDigit
MOVE.W #1930,TextOffset
MOVE.B MultiModeNext+2,D0
BSR.W PrintHexDigit
MOVE.W #1932,TextOffset
MOVE.B MultiModeNext+3,D0
BRA.W PrintHexDigit
musepos dc.b 0
EVEN
SetRed CMP.W #82,D0
BHS.W SelectColor
setr2 BSR.W GetColPos
AND.W #$0F00,D2
LSR.W #8,D2
CMP.B D2,D0
BEQ.B setrskp
AND.W #$00FF,D1
LSL.W #8,D0
OR.W D0,D1
MOVE.W D1,(A0)
BSR.W ShowColSliders
BSR.W SetScreenColors
setrskp BTST #6,$BFE001 ; left mouse button
BEQ.B setr2
RTS
SetGreen CMP.W #82,D0
BHS.W SelectColor
setg2 BSR.B GetColPos
AND.W #$00F0,D2
LSR.W #4,D2
CMP.B D2,D0
BEQ.B setgskp
AND.W #$0F0F,D1
LSL.W #4,D0
OR.W D0,D1
MOVE.W D1,(A0)
BSR.W ShowColSliders
BSR.W SetScreenColors
setgskp BTST #6,$BFE001 ; left mouse button
BEQ.B setg2
RTS
SetBlue CMP.W #82,D0
BHS.W SelectColor
setb2 BSR.B GetColPos
AND.W #$000F,D2
CMP.B D2,D0
BEQ.B setbskp
AND.W #$0FF0,D1
OR.W D0,D1
MOVE.W D1,(A0)
BSR.B ShowColSliders
BSR.W SetScreenColors
setbskp BTST #6,$BFE001 ; left mouse button
BEQ.B setb2
RTS
GetColPos
MOVEQ #0,D0
MOVE.W MouseX(PC),D0
CMP.W #26,D0
BHS.B gcpskp2
MOVEQ #0,D0
BRA.B gcpskip
gcpskp2 SUB.W #26,D0
AND.L #$FFFF,D0
DIVU.W #3,D0
AND.L #$FF,D0
CMP.W #15,D0
BLS.B gcpskip
MOVEQ #15,D0
gcpskip CMP.W #7,CurrScreen
BEQ.W GetColAddr
LEA ColorTable,A0
MOVE.W CurrColor(PC),D1
ADD.W D1,D1
LEA (A0,D1.W),A0
MOVE.W (A0),D1
MOVE.W D1,D2
RTS
ShowColSliders
LEA ColSliders(PC),A2
LEA TextBitplane+3282,A1
BSR.B gcpskip
AND.W #$000F,D1
BSR.B ShowOneSlider
LEA TextBitplane+2842,A1
BSR.B gcpskip
AND.W #$00F0,D1
LSR.W #4,D1
BSR.B ShowOneSlider
LEA TextBitplane+2402,A1
BSR.B gcpskip
AND.W #$0F00,D1
LSR.W #8,D1
ShowOneSlider
CLR.L (A1)
CLR.L 4(A1)
CLR.L 40(A1)
CLR.L 44(A1)
CLR.L 80(A1)
CLR.L 84(A1)
MOVE.W D1,D3
ADD.W D3,D3
ADD.W D3,D3
MOVE.W 2(A2,D3.W),D4
MOVE.B (A2,D3.W),(A1,D4.W)
MOVE.B 1(A2,D3.W),1(A1,D4.W)
MOVE.B (A2,D3.W),40(A1,D4.W)
MOVE.B 1(A2,D3.W),41(A1,D4.W)
MOVE.B (A2,D3.W),80(A1,D4.W)
MOVE.B 1(A2,D3.W),81(A1,D4.W)
ColorRTS
RTS
ColSliders
dc.w %0000000001111100,0
dc.w %0000111110000000,1
dc.w %0000000111110000,1
dc.w %0000000000111110,1
dc.w %0000011111000000,2
dc.w %0000000011111000,2
dc.w %0000000000011111,2
dc.w %0000001111100000,3
dc.w %0000000001111100,3
dc.w %0000111110000000,4
dc.w %0000000111110000,4
dc.w %0000000000111110,4
dc.w %0000011111000000,5
dc.w %0000000011111000,5
dc.w %0000000000011111,5
dc.w %0000001111100000,6
SelectColor
CMP.W #84,D1
BHS.B ColorRTS
LEA TextBitplane+2410,A0
MOVEQ #25-1,D2
slcloop CLR.L (A0)
LEA 40(A0),A0
DBRA D2,slcloop
AND.L #$FFFF,D0
AND.L #$FFFF,D1
SUB.W #82,D0
DIVU.W #13,D0
SUB.W #60,D1
DIVU.W #6,D1
MOVE.W D0,D2
LSL.W #2,D2
ADD.W D1,D2
MOVE.W D2,CurrColor
MarkColor
BSR.W gcpskip
MOVE.L A0,UndoColAddr
MOVE.W D1,UndoCol
BSR.W ShowColSliders
BSR.B BlockColors
MOVE.W CurrColor(PC),D0
MOVE.W D0,D1
AND.W #$0003,D1
MULU.W #6*40,D1
LEA TextBitplane,A0
ADD.W D1,A0
LEA 2410(A0),A0
BTST #2,D0
BNE.B slcskip
MOVE.W #$3FF0,(A0)
MOVE.W #$3FF0,240(A0)
MOVEQ #5-1,D0
slclop2 LEA 40(A0),A0
MOVE.W #$2010,(A0)
DBRA D0,slclop2
BRA.W WaitForButtonUp
slcskip MOVE.L #$0001FF80,(A0)
MOVE.L #$0001FF80,240(A0)
MOVEQ #5-1,D0
slclop3 LEA 40(A0),A0
MOVE.L #$0001FF80,(A0)
DBRA D0,slclop3
BRA.W WaitForButtonUp
BlockColors
LEA TextBitplane+2452,A0
MOVEQ #4-1,D1
suploop2
MOVEQ #5-1,D0
suploop3
MOVE.B #$FF,(A0)
LEA 40(A0),A0
DBRA D0,suploop3
LEA 40(A0),A0
DBRA D1,suploop2
RTS
ColorGadgets
CMP.W #79,D0
BHS.W SetDefaultCol
CMP.W #33,D0
BHS.B CancelCol
MOVE.L UndoColAddr(PC),A0
MOVE.W UndoCol(PC),D0
MOVE.W (A0),UndoCol
MOVE.W D0,(A0)
BSR.W ShowColSliders
BRA.W SetScreenColors
CancelCol
LEA CanCols(PC),A0
LEA ColorTable,A1
MOVEQ #8-1,D0
cacolop MOVE.W (A0)+,(A1)+
DBRA D0,cacolop
BSR.W ShowColSliders
BRA.W SetScreenColors
CopyCfgData
LEA ColorTable,A0
LEA CanCols(PC),A1
MOVEQ #8-1,D0
cocclop MOVE.W (A0)+,(A1)+
DBRA D0,cocclop
LEA TrackPath2,A0
MOVE.W #128-1,D0
cocclp2 CLR.B (A0)+
DBRA D0,cocclp2
LEA ModulesPath2,A0
MOVE.W #196-1,D0
cocclp3 CLR.B (A0)+
DBRA D0,cocclp3
LEA ModulesPath,A0
LEA ModulesPath2,A1
BSR.B cocclp4
LEA SongsPath,A0
LEA SongsPath2,A1
BSR.B cocclp4
LEA TrackPath,A0
LEA TrackPath2,A1
BSR.B cocclp4
LEA PattPath,A0
LEA PattPath2,A1
BSR.B cocclp4
LEA SamplePath,A0
LEA SamplePath2,A1
cocclp4 MOVE.B (A0)+,(A1)+
BNE.B cocclp4
LEA VUmeterColors,A0
LEA SaveColors,A1
MOVEQ #(40+48)-1,D0
cocclp5 MOVE.W (A0)+,(A1)+
DBRA D0,cocclp5
RTS
CNOP 0,4
UndoColAddr dc.l 0
CanCols dc.w 0,0,0,0,0,0,0,0
UndoCol dc.w 0
SetDefaultCol
LEA DefCol,A0
LEA ColorTable,A1
MOVEQ #8-1,D0
sdcloop MOVE.W (A0)+,(A1)+
DBRA D0,sdcloop
BSR.W ShowColSliders
SetScreenColors
JSR SetupAnaCols
SetScreenColors2
LEA ColorTable,A0
LEA CopCol0,A1
MOVE.W (A0),(A1)
MOVE.W 2(A0),4(A1)
MOVE.W 4(A0),8(A1)
MOVE.W 6(A0),12(A1)
MOVE.W 8(A0),16(A1)
MOVE.W 10(A0),20(A1)
MOVE.W 12(A0),24(A1)
MOVE.W 14(A0),28(A1)
MOVE.W 14(A0),D0
TST.W SamScrEnable
BEQ.B sscnosc
MOVE.W 8(A0),D0
sscnosc MOVE.W D0,NoteCol
MOVE.W 10(A0),D0
MOVE.W D0,D4
MOVE.W #3,FadeX
BSR.B FadeCol
MOVE.W D0,56(A1)
MOVE.W D4,48(A1)
MOVE.W D4,D0
MOVE.W #-3,FadeX
BSR.B FadeCol
MOVE.W D0,52(A1)
RTS
FadeCol MOVE.W D0,D1
MOVE.W D0,D2
MOVE.W D0,D3
LSR.W #8,D1
ADD.W FadeX(PC),D1
BPL.B redskp
MOVEQ #0,D1
redskp CMP.W #15,D1
BLS.B redskp2
MOVEQ #15,D1
redskp2 AND.W #$00F0,D2
LSR.W #4,D2
ADD.W FadeX(PC),D2
BPL.B grnskp
MOVEQ #0,D2
grnskp CMP.W #15,D2
BLS.B grnskp2
MOVEQ #15,D2
grnskp2 AND.W #$000F,D3
ADD.W FadeX(PC),D3
BPL.B bluskp
MOVEQ #0,D3
bluskp CMP.W #15,D3
BLS.B bluskp2
MOVEQ #15,D3
bluskp2 MOVE.W D3,D0
LSL.W #4,D2
OR.W D2,D0
LSL.W #8,D1
OR.W D1,D0
RTS
CurrColor dc.w 0
FadeX dc.w -3
EnterPrintPath
BSR.W StorePtrCol
BSR.W SetWaitPtrCol
LEA PrintPath,A6
MOVE.L A6,ShowTextPtr
MOVE.L A6,TextEndPtr
ADD.L #31,TextEndPtr
MOVE.W #12,TextLength
MOVE.W #3694,A4
BSR.W GetTextLine
BRA.W RestorePtrCol
ShowPrintPath
LEA PrintPath,A0
MOVE.W #3694,D1
MOVEQ #12,D0
BRA.W ShowText3
; Print Song
PrintSong
LEA PrintSongText,A0
BSR.W AreYouSure
BNE.W PrintSongRTS
BSR.W StorePtrCol
MOVE.L #PrintPath,D1
MOVE.L #1006,D2
MOVE.L DOSBase,A6
JSR _LVOOpen(A6)
MOVE.L D0,FileHandle
BEQ.W CantOpenFile
BSR.W SetDiskPtrCol
LEA PrintingSongText,A0
BSR.W ShowStatusText
MOVE.L FileHandle,D1
MOVE.L #SongDumpText,D2
MOVEQ #68,D3
MOVE.L DOSBase,A6
JSR _LVOWrite(A6)
MOVE.L FileHandle,D1
MOVE.L SongDataPtr,D2
MOVEQ #20,D3
JSR _LVOWrite(A6)
BSR.W PrintCRLF
BSR.W PrintCRLF
BSR.B PrintSong2
BSR.W PrintCRLF
BSR.W PrintSong4
BSR.W PrintFormFeed
MOVE.L SongDataPtr,A0
MOVEQ #0,D0
MOVE.B sd_numofpatt(A0),D0
LEA sd_pattpos(A0),A0
MOVEQ #0,D7
ps_loop CMP.B (A0,D0.W),D7
BGT.B ps_skip
MOVE.B (A0,D0.W),D7
ps_skip SUBQ.W #1,D0
BPL.B ps_loop
MOVEQ #0,D1
ps_loop2
MOVEM.L D1-D7/A0-A6,-(SP)
BSR.W PrintPattern
MOVEM.L (SP)+,D1-D7/A0-A6
TST.L D0
BNE.B ps_skip2
MOVEM.L D1/D7,-(SP)
BSR.W PrintFormFeed
MOVEM.L (SP)+,D1/D7
ADDQ.W #1,D1
CMP.W D7,D1
BLE.B ps_loop2
ps_skip2
MOVE.L DOSBase,A6
MOVE.L FileHandle,D1
JSR _LVOClose(A6)
BSR.W ShowAllRight
BRA.W RestorePtrCol
PrintSong2
MOVEQ #1,D7
ps2_2 MOVE.L D7,D0
LSR.B #4,D0
CMP.B #9,D0
BLS.B spujk
ADDQ.B #7,D0
spujk ADD.B #'0',D0
MOVE.B D0,PattXText1
MOVE.B D7,D0
AND.B #$0F,D0
CMP.B #9,D0
BLS.B spujk2
ADDQ.B #7,D0
spujk2 ADD.B #'0',D0
MOVE.B D0,PattXText2
MOVE.L SongDataPtr,A0
MOVE.W D7,D0
MULU.W #30,D0
LEA -10(A0,D0.W),A0
LEA PpText,A1
MOVEQ #22-1,D0
ps2_loop
MOVE.B #' ',(A1)+
DBRA D0,ps2_loop
LEA PpText,A1
MOVE.L A0,SavIt
ps2_loop2
MOVE.B (A0)+,D0
BEQ.B PrintSong3
MOVE.B D0,(A1)+
BRA.B ps2_loop2
CNOP 0,4
SavIt dc.l 0
PrintSong3
MOVE.L D7,-(SP) ; pattnum
MOVE.L SavIt(PC),A0
MOVE.W 22(A0),D0
ADD.W D0,D0
LEA ascii.MSG4,A0
JSR IntToHexASCII
MOVE.L SavIt(PC),A0
MOVE.W 26(A0),D0
ADD.W D0,D0
LEA ascii.MSG5,A0
JSR IntToHexASCII
MOVE.L SavIt(PC),A0
MOVE.W 28(A0),D0
ADD.W D0,D0
LEA ascii.MSG6,A0
JSR IntToHexASCII
MOVE.L DOSBase,A6
MOVE.L FileHandle,D1
MOVE.L #PtotText,D2
MOVEQ #$34,D3
JSR _LVOWrite(A6)
MOVE.L (SP)+,D7
ADDQ.W #1,D7
CMP.W #$20,D7
BNE.W ps2_2
PrintSongRTS
RTS
PrintSong4
MOVE.L SongDataPtr,A0
MOVEQ #0,D7
MOVE.B sd_numofpatt(A0),D7
LEA sd_pattpos(A0),A0
MOVEQ #0,D5
ps4_loop1
MOVEQ #0,D6
ps4_loop2
MOVEQ #0,D0
MOVE.B (A0)+,D0
MOVE.L D0,D6
DIVU.W #10,D6
ADD.B #$30,D6
MOVE.B D6,D1
SWAP D6
ADD.B #$30,D6
MOVE.B D6,D0
LEA PnText,A1
MOVE.B D1,(A1)+
MOVE.B D0,(A1)
MOVEM.L D5-D7/A0,-(SP)
MOVE.L DOSBase,A6
MOVE.L FileHandle,D1
MOVE.L #PnText,D2
MOVEQ #4,D3
JSR _LVOWrite(A6)
MOVEM.L (SP)+,D5-D7/A0
ADDQ.W #1,D5
CMP.W D5,D7
BEQ.W Return2
ADDQ.W #1,D6
CMP.W #$0010,D6
BNE.B ps4_loop2
MOVEM.L D5-D7/A0,-(SP)
BSR.B PrintCRLF
MOVEM.L (SP)+,D5-D7/A0
BRA.B ps4_loop1
PrintCRLF
MOVE.L DOSBase,A6
MOVE.L FileHandle,D1
MOVE.L #CRLF_Text,D2
MOVEQ #2,D3
JSR _LVOWrite(A6)
RTS
PrintFormFeed
MOVE.L DOSBase,A6
MOVE.L FileHandle,D1
MOVE.L #FF_Text,D2
MOVEQ #1,D3
JSR _LVOWrite(A6)
RTS
PrintPattern
MOVE.L D1,D6 ; D1=pattern number
DIVU.W #10,D6
ADD.B #'0',D6
MOVE.B D6,PattNumText1
SWAP D6
ADD.B #'0',D6
MOVE.B D6,PattNumText2
MOVEM.L D0-D7/A0-A6,-(SP)
MOVE.L FileHandle,D1
MOVE.L #PatternNumText,D2
MOVEQ #18,D3
MOVE.L DOSBase,A6
JSR _LVOWrite(A6)
MOVEM.L (SP)+,D0-D7/A0-A6
MOVE.L D1,D6
MOVE.L SongDataPtr,A6
LEA sd_patterndata(A6),A6
LSL.L #8,D6
LSL.L #2,D6
ADD.L D6,A6
CLR.W PPattPos
MOVEQ #0,D6
pp_posloop
MOVEQ #0,D7
MOVE.W #2,TextLength
MOVEQ #0,D1
MOVE.W PPattPos,D1
LEA PattPosText,A5
DIVU.W #10,D1
ADD.B #'0',D1
MOVE.B D1,(A5)+
CLR.W D1
SWAP D1
ADD.B #'0',D1
MOVE.B D1,(A5)+
ADDQ #5,A5
pp_noteloop
MOVEQ #0,D0
MOVEQ #0,D1
MOVE.W #3,TextLength
MOVE.W (A6),D1
AND.W #$0FFF,D1
LEA PeriodTable,A0
pp_findloop
CMP.W (A0,D0.L),D1
BEQ.B PrintNote
ADDQ.L #2,D0
BRA.B pp_findloop
PrintNote
ADD.L D0,D0
ADD.L NoteNamesPtr,D0
MOVE.L D0,A0
MOVE.L (A0),(A5)+
CMP.B #'',-3(A5)
BNE.B prnoxyz
MOVE.B #'b',-3(A5)
prnoxyz ADDQ #1,A5
MOVEQ #0,D0
MOVE.W (A6),D0
AND.W #$F000,D0
LSR.W #8,D0
LSL.L #1,D0
LEA FastHexTable,A0
ADD.L D0,A0
MOVE.B (A0),(A5)+
MOVEQ #0,D0
MOVE.B 2(A6),D0
ADD.L D0,D0
LEA FastHexTable,A0
ADD.L D0,A0
MOVE.W (A0),(A5)+
MOVEQ #0,D0
MOVE.B 3(A6),D0
ADD.L D0,D0
LEA FastHexTable,A0
ADD.L D0,A0
MOVE.W (A0),(A5)+
ADDQ #4,A5
ADDQ #4,A6
ADDQ.W #1,D7
CMP.L #4,D7
BNE.W pp_noteloop
ADDQ.W #1,PPattPos
MOVEM.L D0-D7/A0-A6,-(SP)
MOVE.L DOSBase,A6
MOVE.L FileHandle,D1
MOVE.L #PnText2,D2
MOVEQ #68,D3
JSR _LVOWrite(A6)
BSR.W PrintCRLF
MOVEM.L (SP)+,D0-D7/A0-A6
BTST #2,$DFF016 ; right mouse button
BEQ.B NegativeReturn
ADDQ.L #1,D6
CMP.L #64,D6
BNE.W pp_posloop
MOVEQ #0,D0
RTS
NegativeReturn
MOVEQ #-1,D0
RTS
;---- Setup2 ----
Setup2 BSR.W WaitForButtonUp
MOVE.W #7,CurrScreen
CLR.W LastSetupScreen
ST DisableAnalyzer
ST NoSampleInfo
BSR.W Clear100Lines
MOVE.L SetupMemPtr(PC),D0
BNE.B set2skp
BSR.W SaveMainPic
BEQ.W ExitSetup
set2skp BSR.W DecompactSetup2
BSR.W SetScreenColors
refrsh2 BSR.W ShowIntMode
JSR ShowTempo
BSR.W ShowSpeed
BSR.W ShowColEdit
BSR.W ShowRainbow
BSR.W GetColPos
BSR.W ShowColSliders
BSR.W ShowS2Modules
BSR.W ShowS2Songs
BSR.W ShowS2Samples
BSR.W ShowS2PTPath
BSR.W ShowS2MaxPLST
BSR.W ShowS2TuneNote
BSR.W ShowS2VUStyle
BRA.W ShowS2T
CheckSetup2Gadgs
MOVE.W MouseX2,D0
MOVE.W MouseY2,D1
CMP.W #210,D0
BHS.W Setup2Menu3
CMP.W #108,D0
BHS.B Setup2Menu2
;---- Menu 1 ----
CMP.W #11,D1
BLS.W ToggleIntMode
CMP.W #22,D1
BLS.B xChangeTempo
CMP.W #33,D1
BLS.W ChangeSpeed
CMP.W #44,D1
BLS.W ToggleColEdit
CMP.W #55,D1
BLS.W RotOrSpread
CMP.W #66,D1
BLS.W SetRed2
CMP.W #77,D1
BLS.W SetGreen2
CMP.W #88,D1
BLS.W SetBlue2
CMP.W #99,D1
BLS.W ColorGadgets2
RTS
xChangeTempo JMP ChangeTempo
Setup2Menu2
CMP.W #11,D1
BLS.W Set2ModPath
CMP.W #22,D1
BLS.W Set2SongPath
CMP.W #33,D1
BLS.W Set2SamPath
CMP.W #44,D1
BLS.W Set2PTPath
CMP.W #55,D1
BLS.W SetS2MaxPLST
CMP.W #66,D1
BLS.W SetS2TuneNote
CMP.W #77,D1
BLS.W SetS2VUStyle
;CMP.W #88,D1
;BLS.W Setup2NotImpl
CMP.W #99,D1
BLS.B Setup2SwitchToggles
RTS
SwitchTogglesFlag dc.b 0
EVEN
Setup2SwitchToggles
EOR.B #1,SwitchTogglesFlag
LEA Setup2Menus,A0
LEA Setup2ToggleData,A1
MOVEQ #1,D3
s2stloop1 MOVEQ #88-1,D2
s2stloop2 MOVE.W #7-1,D0
s2stloop3 MOVE.W (A0),D4
MOVE.W (A1),(A0)+
MOVE.W D4,(A1)+
DBRA D0,s2stloop3
LEA 26(A0),A0
DBRA D2,s2stloop2
LEA 6720(A0),A0
DBRA D3,s2stloop1
BSR.W ShowS2T
RTS
Setup2Menu3
TST.B SwitchTogglesFlag
BNE.B Setup2Menu4
CMP.W #11,D1
BLS.W ExitOrDefault
CMP.W #22,D1
BLS.W ToggleOverride
CMP.W #33,D1
BLS.W ToggleNosamples
CMP.W #44,D1
BLS.W ToggleBlankZero
CMP.W #55,D1
BLS.W ToggleShowDirs
CMP.W #66,D1
BLS.W ToggleShowPublic
CMP.W #77,D1
BLS.W ToggleCutToBuf
CMP.W #88,D1
BLS.W ToggleIFFLoop
CMP.W #99,D1
BLS.W ToggleSysReq
RTS
Setup2Menu4
CMP.W #11,D1
BLS.B ExitOrDefault
CMP.W #22,D1
BLS.W ToggleSalvage
CMP.W #33,D1
BLS.W Toggle100Patts
CMP.W #44,D1
BLS.W ToggleSaveIcons
CMP.W #55,D1
BLS.W ToggleLoadNames
CMP.W #66,D1
BLS.W ToggleSaveNames
CMP.W #77,D1
BLS.W ToggleLoadPLST
CMP.W #88,D1
BLS.W ToggleScreenAdjust
CMP.W #99,D1
BLS.W ToggleSamplePack
RTS
ExitOrDefault
CMP.W #263,D0
BLS.B SetS2Default
CMP.W #306,D0
BHS.B eodskip
BRA.W ExitSetup
eodskip
TST.B SwitchTogglesFlag
BEQ.B eodskip2
BSR.W Setup2SwitchToggles
eodskip2
BRA.W Setup
SetS2Default
LEA SetDefaultsText(PC),A0
BSR.W AreYouSure
BNE.W Return2
LEA DefaultSetupData,A0
LEA SongsPath-SetupData(A0),A2
LEA SongsPath,A1
MOVEQ #96-1,D0
ss2dela MOVE.B (A2)+,(A1)+
DBRA D0,ss2dela
LEA PTPath-SetupData(A0),A2
LEA PTPath,A1
MOVEQ #32-1,D0
ss2delb MOVE.B (A2)+,(A1)+
DBRA D0,ss2delb
LEA MaxPLSTEntries-SetupData(A0),A2
MOVE.W (A2),MaxPLSTEntries
LEA DMAWait-SetupData(A0),A2
MOVE.W (A2),DMAWait
LEA TuneNote-SetupData(A0),A2
MOVE.L (A2),TuneNote
LEA SalvageAddress-SetupData(A0),A2
LEA SalvageAddress,A1
MOVE.L (A2)+,(A1)+
MOVE.L (A2),(A1)
BRA.W refrsh2
SetDefaultsText dc.b 'Set defaults?',0
EVEN
ToggleIntMode
JSR ResetMusicInt
EOR.B #1,IntMode
JSR SetMusicInt
JSR SetTempo
BSR.W WaitForButtonUp
ShowIntMode
LEA VBlankText(PC),A0
TST.B IntMode
BEQ.B simskip
LEA CIAText(PC),A0
simskip MOVEQ #6,D0
MOVE.W #167,D1
BRA.W ShowText3
VBlankText dc.b "VBLANK"
CIAText dc.b " CIA "
EVEN
ChangeSpeed
MOVEQ #0,D1
CMP.W #97,D0
BHS.B SpeedDown
CMP.W #86,D0
BHS.B SpeedUp
RTS
SpeedUp MOVE.W DefaultSpeed,D1
ADDQ.B #1,D1
CMP.B #$FF,D1
BLS.B spedup2
MOVE.W #$FF,D1
spedup2 MOVE.W D1,DefaultSpeed
MOVE.L D1,CurrSpeed
BSR.B ShowSpeed
BSR.W Wait_4000
BRA.W Wait_4000
ShowSpeed
MOVE.W #608+440,TextOffset
MOVE.W DefaultSpeed,WordNumber
BRA.W PrintHexByte
SpeedDown
MOVE.W DefaultSpeed,D1
SUBQ.B #1,D1
CMP.B #1,D1
BHS.B spedup2
MOVEQ #1,D1
BRA.B spedup2
ToggleOverride
EOR.B #1,OverrideFlag
BRA.B ShowS2T
ToggleNosamples
EOR.B #1,NosamplesFlag
BRA.B ShowS2T
ToggleBlankZero
EOR.B #1,BlankZeroFlag
BSR.B ShowS2T
BRA.W RedrawPattern
ToggleShowDirs
EOR.B #1,ShowDirsFlag
BRA.B ShowS2T
ToggleShowPublic
EOR.B #1,ShowPublicFlag
ST UpdateFreeMem
BRA.B ShowS2T
ToggleCutToBuf
EOR.B #1,CutToBufFlag
BRA.B ShowS2T
ToggleIFFLoop
EOR.B #1,IFFLoopFlag
BRA.B ShowS2T
ToggleSysReq
EOR.B #1,SysReqFlag
BSR.W UpdateSysReq
ShowS2T CLR.B RawKeyCode
CMP.W #7,CurrScreen
BNE.W Return2
LEA OverrideFlag,A4
TST.B SwitchTogglesFlag
BEQ.B sstskip4
LEA SalvageFlag,A4
MOVE.W #3,TextLength
MOVEQ #7-1,D7
MOVE.W #636,D6
sstloop2
MOVE.W D6,TextOffset
LEA ToggleOFFText(PC),A0
TST.B (A4)+
BEQ.B sstskip2
LEA ToggleONText(PC),A0
sstskip2
BSR.W ShowText2
ADD.W #440,D6
DBRA D7,sstloop2
MOVE.W D6,TextOffset
LEA RAWText(PC),A0
TST.B (A4)+
BEQ.B sstskip3
LEA IFFText(PC),A0
sstskip3
BSR.W ShowText2
ADD.W #440,D6
BRA.W WaitForButtonUp
sstskip4
MOVE.W #3,TextLength
MOVEQ #8-1,D7
MOVE.W #636,D6
sstloop3
MOVE.W D6,TextOffset
LEA ToggleOFFText(PC),A0
TST.B (A4)+
BEQ.B sstskip5
LEA ToggleONText(PC),A0
sstskip5
BSR.W ShowText2
ADD.W #440,D6
DBRA D7,sstloop3
BRA.W WaitForButtonUp
CNOP 0,4
SongAllocSize dc.l SONG_SIZE_64PAT
MaxPattern dc.l 64-1
ToggleSalvage
BRA.W ShowNotImpl
Toggle100Patts
BSR.W WaitForButtonUp
LEA AreYouSureText,A0
BSR.W AreYouSure
BNE.W Return2
t100ploop
MOVE.L SongDataPtr,D1
BEQ.B t100pskip
MOVE.L D1,A1
MOVE.L SongAllocSize(PC),D0
JSR PTFreeMem
t100pskip
BSR.W ClrSampleInfo
EOR.B #1,OneHundredPattFlag
MOVE.L #SONG_SIZE_64PAT,SongAllocSize
MOVE.L #64-1,MaxPattern
TST.B OneHundredPattFlag
BEQ.B t100pskip2
MOVE.L #SONG_SIZE_100PAT,SongAllocSize
MOVE.L #100-1,MaxPattern
t100pskip2
MOVE.L SongAllocSize(PC),D0
MOVE.L #MEMF_CLEAR!MEMF_PUBLIC,D1
JSR PTAllocMem
MOVE.L D0,SongDataPtr
BNE.B t100pskip3
BSR.W OutOfMemErr
BRA.B t100ploop
t100pskip3
BSR.W DoClearSong
BSR.W ShowSampleInfo
BSR.W ShowSongName
BRA.W ShowS2T
ToggleSaveIcons
EOR.B #1,SaveIconsFlag
BRA.W ShowS2T
ToggleLoadNames
EOR.B #1,LoadNamesFlag
BRA.W ShowS2T
ToggleSaveNames
EOR.B #1,SaveNamesFlag
BRA.W ShowS2T
ToggleLoadPLST
EOR.B #1,LoadPLSTFlag
BRA.W ShowS2T
ToggleScreenAdjust
EOR.B #1,ScreenAdjustFlag
BSR.W ShowS2T
BSR.W AdjustVuSprites
BSR.W UpdateCursorPos
JSR SetLoopSprites
BSR.W RedrawPattern
BRA.W WaitForButtonUp
ToggleSamplePack
EOR.B #1,SamplePackFlag
BRA.W ShowS2T
UpdateSysReq
MOVE.L PTProcess,A0
TST.B SysReqFlag
BEQ.B lbC00956E
MOVE.L PTProcessTmp,184(A0)
RTS
lbC00956E
MOVE.L #$FFFFFFFF,184(A0)
RTS
ShowS2Modules
MOVE.W #177,D1
LEA ModulesPath,A0
s2path MOVEQ #9,D0
BRA.W ShowText3
ShowS2Songs
MOVE.W #177+440,D1
LEA SongsPath,A0
BRA.B s2path
ShowS2Samples
MOVE.W #177+880,D1
LEA SamplePath,A0
BRA.B s2path
ShowS2PTPath
MOVE.W #177+1320,D1
LEA PTPath,A0
BRA.B s2path
Set2ModPath
BSR.W StorePtrCol
BSR.W SetWaitPtrCol
LEA ModulesPath,A6
MOVE.L A6,ShowTextPtr
MOVE.L A6,TextEndPtr
ADD.L #31,TextEndPtr
MOVE.W #9,TextLength
MOVE.W #177,A4
BSR.W GetTextLine
BRA.W RestorePtrCol
Set2SongPath
BSR.W StorePtrCol
BSR.W SetWaitPtrCol
LEA SongsPath,A6
MOVE.L A6,ShowTextPtr
MOVE.L A6,TextEndPtr
ADD.L #31,TextEndPtr
MOVE.W #9,TextLength
MOVE.W #177+440,A4
BSR.W GetTextLine
BRA.W RestorePtrCol
Set2SamPath
BSR.W StorePtrCol
BSR.W SetWaitPtrCol
LEA SamplePath,A6
MOVE.L A6,ShowTextPtr
MOVE.L A6,TextEndPtr
ADD.L #31,TextEndPtr
MOVE.W #9,TextLength
MOVE.W #177+880,A4
BSR.W GetTextLine
BRA.W RestorePtrCol
Set2PTPath
BSR.W StorePtrCol
BSR.W SetWaitPtrCol
LEA PTPath,A6
MOVE.L A6,ShowTextPtr
MOVE.L A6,TextEndPtr
ADD.L #31,TextEndPtr
MOVE.W #9,TextLength
MOVE.W #177+1320,A4
BSR.W GetTextLine
BRA.W RestorePtrCol
SetS2MaxPLST
CMP.W #199,D0
BHS.B S2PLSTd
CMP.W #188,D0
BHS.B S2PLSTu
RTS
S2PLSTu MOVE.W MaxPLSTEntries,D0
ADD.W #100,D0
CMP.W #9999,D0
BLS.B s2pu
MOVE.W #9999,D0
s2pu MOVE.W D0,MaxPLSTEntries
BSR.B ShowS2MaxPLST
BRA.W Wait_4000
S2PLSTd MOVEQ #0,D0
MOVE.W MaxPLSTEntries,D0
ADDQ.W #1,D0
DIVU.W #100,D0
SUBQ.W #1,D0
BPL.B s2pd
MOVEQ #0,D0
BRA.B s2pu
s2pd MULU.W #100,D0
BRA.B s2pu
ShowS2MaxPLST
MOVE.W MaxPLSTEntries,WordNumber
MOVE.W #1939,TextOffset
BRA.W Print4DecDigits
SetS2TuneNote
CMP.W #187,D0
BHS.B ss2tvol
MOVE.W #2380,D1
MOVEQ #3,D0
LEA SpcNoteText,A0
BSR.W ShowText3
MOVE.W #3,SamNoteType
MOVE.L #TuneNote,SplitAddress
BRA.W WaitForButtonUp
ShowS2TuneNote
CMP.W #7,CurrScreen
BNE.W Return2
MOVE.L NoteNamesPtr,A4
MOVE.W TuneNote,D0
LSL.W #2,D0
LEA (A4,D0.W),A0
MOVEQ #4,D0
MOVE.W #2380,D1
BSR.W ShowText3
MOVE.W TToneVol,WordNumber
MOVE.W #2384,TextOffset
BRA.W PrintHexByte
ss2tvol MOVE.W #2384,TextOffset
BSR.W GetHexByte
TST.W AbortHexFlag
BNE.B ShowS2TuneNote
CMP.B #64,D0
BLS.B ss2tvolset
MOVE.B #64,D0
ss2tvolset MOVE.W D0,TToneVol
BRA.B ShowS2TuneNote
SetS2VUStyle
EOR.B #1,RealVUMetersFlag
BSR.W WaitForButtonUp
ShowS2VUStyle
CMP.W #7,CurrScreen
BNE.W Return2
TST.B RealVUMetersFlag
BNE.B ss2vureal
LEA VUStyleFakeText(PC),A0
BRA.B sst2vushow
ss2vureal
LEA VUStyleRealText(PC),A0
sst2vushow
MOVEQ #4,D0
MOVE.W #2382+440,D1
BRA.W ShowText3
VUStyleFakeText dc.b "FAKE",0
VUStyleRealText dc.b "REAL",0
EVEN
Setup2NotImpl BRA.W ShowNotImpl
ToggleColEdit
CMP.W #79,D0
BHS.W SelectColor2
CLR.W SpreadFlag
LEA VUmeterColors,A0
MOVEQ #48,D0
CMP.L TheRightColors(PC),A0
BNE.B tced2
LEA AnalyzerColors,A0
MOVEQ #36,D0
tced2 MOVE.L A0,TheRightColors
MOVE.W D0,ColorsMax
CMP.W RainbowPos(PC),D0
BHI.B tced3
CLR.W RainbowPos
tced3 BSR.W ShowRainbow
BSR.W ShowColSliders ; PT2.3D bugfix: update sliders
BSR.B ShowColEdit
BRA.W WaitForButtonUp
ShowColEdit
LEA cedtxt1(PC),A0
LEA VUmeterColors,A1
CMP.L TheRightColors(PC),A1
BEQ.B shcoed
LEA cedtxt2(PC),A0
shcoed MOVEQ #6,D0
MOVE.W #1483,D1
BRA.W ShowText3
cedtxt1 dc.b "VU-MTR"
cedtxt2 dc.b "ANALYZ"
EVEN
RotOrSpread
CMP.W #16,D0
BLO.B RotColUp
CMP.W #32,D0
BLO.B RotColDown
CMP.W #79,D0
BHS.W SelectColor2
BRA.B SpreadColors
RotColUp
CLR.W SpreadFlag
MOVE.L TheRightColors(PC),A0
MOVE.W (A0),D0
MOVE.W ColorsMax(PC),D1
SUBQ.W #2,D1
rocoup1 MOVE.W 2(A0),(A0)+
DBRA D1,rocoup1
MOVE.W D0,(A0)
rocoup2
BSR.W Wait_4000
BSR.W GetColPos
BSR.W ShowColSliders
BSR.W ShowRainbow
JMP SetupVUCols
RotColDown
CLR.W SpreadFlag
MOVE.L TheRightColors(PC),A0
MOVE.W ColorsMax(PC),D1
ADD.W D1,A0
ADD.W D1,A0
MOVE.W -(A0),D0
SUBQ.W #2,D1
rocodn1 MOVE.W -2(A0),(A0)
SUBQ.L #2,A0
DBRA D1,rocodn1
MOVE.W D0,(A0)
BRA.B rocoup2
SpreadColors
MOVE.W RainbowPos(PC),SpreadFrom
MOVE.W #1,SpreadFlag
RTS
SpreadFrom dc.w 0
SpreadFlag dc.w 0
ColorGadgets2
CLR.W SpreadFlag
CMP.W #79,D0
BHS.B SetDefaultCol2
CMP.W #33,D0
BHS.B CancelCol2
MOVE.L UndoColAddr(PC),A0
MOVE.W UndoCol(PC),D1
MOVE.W (A0),UndoCol
MOVE.W D1,(A0)
BRA.B rocoup2
SetDefaultCol2
MOVE.L TheRightColors(PC),A0
MOVE.L A0,A1
SUB.L #SetupData,A1
ADD.L #DefaultSetupData,A1
sedeco4 MOVE.W ColorsMax(PC),D0
BRA.B sedeco3
sedeco2 MOVE.W (A1)+,(A0)+
sedeco3 DBRA D0,sedeco2
BRA.W rocoup2
CancelCol2
MOVE.L TheRightColors(PC),A0
MOVE.L A0,A1
SUB.L #VUmeterColors,A1
ADD.L #SaveColors,A1
BRA.B sedeco4
GetColAddr
MOVE.L TheRightColors(PC),A0
MOVE.W RainbowPos(PC),D1
ADD.W D1,D1
LEA (A0,D1.W),A0
MOVE.W (A0),D1
MOVE.W D1,D2
RTS
SetRed2 CMP.W #79,D0
BHS.W SelectColor2
set2r2 BSR.W GetColPos
AND.W #$0F00,D2
LSR.W #8,D2
CMP.B D2,D0
BEQ.B setrsk2
AND.W #$00FF,D1
LSL.W #8,D0
OR.W D0,D1
MOVE.W D1,(A0)
BSR.W ShowColSliders
BSR.W ShowRainbow
JSR SetupVUCols
setrsk2 BTST #6,$BFE001 ; left mouse button
BEQ.B set2r2
RTS
SetGreen2
CMP.W #79,D0
BHS.B SelectColor2
set2g2 BSR.W GetColPos
AND.W #$00F0,D2
LSR.W #4,D2
CMP.B D2,D0
BEQ.B setgsk2
AND.W #$0F0F,D1
LSL.W #4,D0
OR.W D0,D1
MOVE.W D1,(A0)
BSR.W ShowColSliders
BSR.W ShowRainbow
JSR SetupVUCols
setgsk2 BTST #6,$BFE001 ; left mouse button
BEQ.B set2g2
RTS
SetBlue2
CMP.W #79,D0
BHS.B SelectColor2
set2b2 BSR.W GetColPos
AND.W #$000F,D2
CMP.B D2,D0
BEQ.B setbsk2
AND.W #$0FF0,D1
OR.W D0,D1
MOVE.W D1,(A0)
BSR.W ShowColSliders
BSR.W ShowRainbow
JSR SetupVUCols
setbsk2 BTST #6,$BFE001 ; left mouse button
BEQ.B set2b2
RTS
SelectColor2
MOVEQ #0,D7
setcolp BTST #6,$BFE001 ; left mouse button
BNE.B ChkSpread
MOVE.W ColorsMax(PC),D0
MOVE.W MouseY(PC),D1
CMP.W D7,D1
BEQ.B setcolp
MOVE.W D1,D7
CMP.W #37,D1
BHS.B setcoly
MOVEQ #37,D1
setcoly SUB.W #37,D1
CMP.W D0,D1
BLT.B setcol2
MOVE.W D0,D1
SUBQ.W #1,D1
setcol2 MOVE.W D1,RainbowPos
BSR.W ShowRainbow
BSR.W GetColPos
MOVE.L A0,UndoColAddr
MOVE.W D1,UndoCol
BSR.W ShowColSliders
BRA.B setcolp
ChkSpread
TST.W SpreadFlag
BEQ.W Return2
CLR.W SpreadFlag
BSR.W GetColPos
MOVE.W SpreadFrom(PC),D0
MOVE.W RainbowPos(PC),D1
CMP.W D1,D0
BLO.B chkspr2
EXG D0,D1
chkspr2 MOVE.W D1,D4
SUB.W D0,D4
CMP.W #1,D4
BLS.W Return2
MOVE.L D4,A2
ADD.W D4,D4
MOVE.L TheRightColors(PC),A0
MOVE.L A0,A1
ADD.W D0,D0
ADD.W D1,D1
LEA (A0,D0.W),A0 ; 1st col
MOVE.W (A0),D2
LEA (A1,D1.W),A1 ; 2nd col
MOVE.W (A1),D3
MOVEQ #0,D5
sprdlop MOVE.W D2,D0 ; red
LSR.W #8,D0
MOVE.W D3,D1
LSR.W #8,D1
BSR.B ColCrossfade
LSL.W #8,D0
MOVE.W D0,D7
MOVE.W D2,D0 ; green
LSR.W #4,D0
AND.W #$000F,D0
MOVE.W D3,D1
LSR.W #4,D1
AND.W #$000F,D1
BSR.B ColCrossfade
LSL.W #4,D0
OR.W D0,D7
MOVE.W D2,D0 ; blue
AND.W #$000F,D0
MOVE.W D3,D1
AND.W #$000F,D1
BSR.B ColCrossfade
OR.W D0,D7
ADDQ.W #2,D5
MOVE.W D7,(A0)+
CMP.L A1,A0
BLO.B sprdlop
BRA.W rocoup2
ColCrossfade
MOVE.W D4,D6
SUB.W D5,D6
MULU.W D6,D0
ADD.L A2,D0
MULU.W D5,D1
ADD.W D1,D0
DIVU.W D4,D0
CMP.W #15,D0
BLS.W Return2
MOVEQ #15,D0
RTS
ShowRainbow
LEA.L TextBitplane+1490,A0
MOVEQ #0,D1
MOVE.L #$00FFE000,D2
MOVE.W RainbowPos(PC),D3
rainlop MOVE.L D2,D0
CMP.W D3,D1
BNE.S rainsk1
MOVE.L #$1EFFEF00,D0
rainsk1 MOVE.L D0,(A0)
LEA 40(A0),A0
ADDQ.W #1,D1
CMP.W #48,D1
BLO.S rainlop
LEA CopListAnalyzer,A0
MOVE.L TheRightColors(PC),A1
MOVE.W #$5107,D0
MOVEQ #48-1,D1
MOVEQ #0,D2
rainlp2 MOVE.W D0,(A0)+
MOVE.W #$FFFE,(A0)+
MOVE.W #$018E,(A0)+
CMP.W ColorsMax(PC),D2
BLO.S rainsk2
CLR.W (A0)+
BRA.S rainsk3
rainsk2 MOVE.W (A1)+,(A0)+
rainsk3 ADD.W #$0100,D0
ADDQ.W #1,D2
DBRA D1,rainlp2
MOVEQ #64-1,D0
rainlp3 MOVE.L #$01B80000,(A0)+
DBRA D0,rainlp3
RTS
CNOP 0,4
TheRightColors dc.l 0
RainbowPos dc.w 0
ColorsMax dc.w 48
;---- PT Decompacter ----
Decompact
MOVE.L A0,CompPtr
MOVE.L D0,CompLen
BSR.B FreeDecompMem
MOVE.L CompPtr(PC),A0
MOVE.L (A0),D0
MOVE.L D0,DecompMemSize
MOVEQ #MEMF_PUBLIC,D1
JSR PTAllocMem
MOVE.L D0,DecompMemPtr
BEQ.W OutOfMemErr
MOVE.L D0,A1
MOVE.L CompPtr(PC),A0
MOVE.L CompLen(PC),D0
ADDQ #4,A0
SUBQ.L #4,D0
MOVE.L D3,-(SP)
MOVEQ #-75,D3 ; 181 signed (compactor code)
dcmloop MOVE.B (A0)+,D1
CMP.B D3,D1
BEQ.B DecodeIt
MOVE.B D1,(A1)+
decom2 SUBQ.L #1,D0
BGT.B dcmloop
MOVE.L (SP)+,D3
MOVE.L DecompMemPtr,A1
MOVEQ #-1,D0
RTS
DecodeIt
MOVEQ #0,D1
MOVE.B (A0)+,D1
MOVE.B (A0)+,D2
dcdloop MOVE.B D2,(A1)+
DBRA D1,dcdloop
SUBQ.L #2,D0
BRA.S decom2
FreeDecompMem
MOVE.L DecompMemPtr,D0
BEQ.W Return2
MOVE.L D0,A1
MOVE.L DecompMemSize,D0
JSR PTFreeMem
CLR.L DecompMemPtr
RTS
CNOP 0,4
CompPtr dc.l 0
CompLen dc.l 0
;---- Position Insert/Delete Gadgets ----
PosInsDelGadgs
MOVE.W MouseY2,D0
CMP.W #11,D0
BHS.W Return2
MOVE.W MouseX2,D0
CMP.W #62,D0
BHS.W Return2
CMP.W #51,D0
BHS.W PosDelete
CMP.W #40,D0
BHS.W PosInsert
BRA.B PosEd
RTS
;---- Position Editor (POSED) ----
PosEd
CMP.W #8,CurrScreen
BEQ.W ExitPLST
CMP.W #1,CurrScreen
BNE.W Return2
BSR.W WaitForButtonUp
MOVE.W #8,CurrScreen
BSR.W ClearRightArea
JSR ClearAnalyzerColors
BSR.B DrawPosEdScreen
BEQ.W ExitPLST
BSR.B RefreshPosEd
RTS
DrawPosEdScreen
LEA PosEdData,A0
MOVE.L #PosEdSize,D0
BRA.W DecompactPLST
RefreshPosEd
CMP.W #8,CurrScreen
BNE.W Return2
TST.B AskBoxShown ; --PT2.3D bug fix: don't update posed if ask dialog shown
BNE.W Return2 ; --
MOVE.L CurrPos,D7
MOVE.L SongDataPtr,A0
CMP.B sd_numofpatt(A0),D7
BLO.B rpedskip
MOVE.B sd_numofpatt(A0),D7
SUBQ.L #1,D7
rpedskip
MOVE.L D7,PosEdCurrPos
MOVE.W #976,A5
MOVEQ #11,D6
MOVEQ #5,D5
CMP.L #5,D7
BGE.B rpedskip2
NEG.L D7
ADDQ.L #4,D7
rpedloop1
LEA 240(A5),A5
SUBQ.L #1,D6
SUBQ.L #1,D5
DBRA D7,rpedloop1
rpedskip2
MOVE.L PosEdCurrPos,D7
SUB.L D5,D7
MOVE.L SongDataPtr,A1
MOVEQ #0,D4
MOVE.B sd_numofpatt(A1),D4
LEA sd_pattpos(A1),A1
MOVE.W #145,D0
BSR.W WaitForVBlank
BSR.W ClearRightArea
rpedloop2
MOVE.L D7,D0
MOVEQ #0,D1
MOVE.B (A1,D0.W),D1
MOVE.L D1,D2
LSL.W #4,D2
LEA PosEdNames,A2
ADD.L D2,A2
MOVEM.L D0-D7/A0-A6,-(SP)
MOVE.W A5,TextOffset
MOVE.W D0,WordNumber
BSR.W Print3DecDigits
MOVEM.L (SP)+,D0-D7/A0-A6
ADDQ.W #1,TextOffset
MOVE.W D1,WordNumber
MOVEM.L D0-D7/A0-A6,-(SP)
BSR.W Print2DecDigits
MOVEM.L (SP)+,D0-D7/A0-A6
ADDQ.W #1,TextOffset
MOVE.L A2,ShowTextPtr
MOVE.W #15,TextLength
MOVEM.L D0-D7/A0-A6,-(SP)
BSR.W ShowText
MOVEM.L (SP)+,D0-D7/A0-A6
ADDQ.L #1,D7
CMP.L D4,D7
BEQ.B PosEdRTS
LEA 240(A5),A5
DBRA D6,rpedloop2
PosEdRTS
RTS
CheckPosEdGadgs
MOVE.W MouseX2,D0
MOVE.W MouseY2,D1
CMP.W #$78,D0
BLO.W Return2
CMP.W #$17,D1
BHS.B lbC009DAF
CMP.W #12,D1
BHS.B lbC009DAA
CMP.W #$10C,D0
BHS.W PlaySong
CMP.W #$AC,D0
BHS.W StopIt
BRA.W PosInsert
lbC009DAA
CMP.W #$10C,D0
BHS.W lbC009F6C
CMP.W #$AC,D0
BHS.W StopIt
BRA.W PosDelete
lbC009DAF
CMP.W #$18,D1
BLO.W Return2
CMP.W #$134,D0
BHS.W lbC009EAC
CMP.W #$5F,D1
BHI.W Return2
TST.L RunMode
BNE.W Return2
CMP.W #$B4,D0
BHS.B lbC009E30
MOVE.W #$A4,LineCurX
MOVE.W #$3B,LineCurY
MOVE.W #$884,TextOffset
BSR.W GetDecByte
TST.W AbortDecFlag
BNE.W POSED_Update
CMP.B MaxPattern+3(PC),D0
BLS.B lbC009E1A
MOVE.L MaxPattern(PC),D0
lbC009E1A
MOVE.L SongDataPtr,A0
LEA sd_pattpos(A0),A0
ADD.L CurrPos,A0
MOVE.B D0,(A0)
BRA.W POSED_Update
lbC009E30
BSR.W WaitForButtonUp
BSR.W StorePtrCol
BSR.W SetWaitPtrCol
CLR.L EditMode
MOVE.L SongDataPtr,A1
LEA sd_pattpos(A1),A1
MOVE.L PosEdCurrPos,D0
MOVEQ #0,D1
MOVE.B (A1,D0.W),D1
LSL.W #4,D1
LEA PosEdNames,A6
ADD.L D1,A6
MOVE.L A6,-(SP)
MOVE.L A6,TextEndPtr
MOVE.L A6,ShowTextPtr
ADD.L #15,TextEndPtr
MOVE.W #15,TextLength
MOVE.W #$887,A4
BSR.W GetTextLine
CLR.L TextEndPtr
BSR.W RestorePtrCol
MOVE.L (SP)+,A0
MOVEQ #16-1,D0
lbC009E9C
TST.B (A0)+
BNE.B lbC009EA6
MOVE.B #' ',-1(A0)
lbC009EA6
DBRA D0,lbC009E9C
BRA.B POSED_Update
lbC009EAC
CMP.W #$63,D1
BHI.W Return2
CMP.W #$59,D1
BHS.B POSED_Bottom
CMP.W #$4E,D1
BHS.B POSED_OneDown
CMP.W #$2D,D1
BHS.W ExitPLST
CMP.W #$22,D1
BHS.B POSED_OneUp
POSED_Top
CLR.L SongPosition
POSED_Update
MOVE.L SongPosition,CurrPos
BSR.W ShowPosition
BRA.W RefreshPosEd
POSED_OneUp
ST SetSignalFlag
MOVE.L SongPosition,D0
SUBQ.L #1,D0
BTST #2,$DFF016 ; right mouse button
BNE.B peouskip
SUBQ.L #3,D0 ; reduced from 9 to 3 in PT2.3E
peouskip
TST.L D0
BPL.B peouskip2
MOVEQ #0,D0
peouskip2
MOVE.L D0,SongPosition
BSR.B POSED_ScrollDelay
BRA.B POSED_Update
POSED_Bottom
MOVE.L SongDataPtr,A0
MOVEQ #0,D7
MOVE.B sd_numofpatt(A0),D7
SUBQ.B #1,D7
MOVE.L D7,SongPosition
BRA.B POSED_Update
POSED_OneDown ; --PT2.3D bug fix: could overflow
ST SetSignalFlag
MOVE.L D1,-(SP)
MOVEQ #0,D1
MOVE.L SongDataPtr,A0
MOVE.B sd_numofpatt(A0),D1
MOVE.L SongPosition,D0
ADDQ.W #1,D0
BTST #2,$DFF016 ; right mouse button
BNE.B peodskip
ADDQ.W #3,D0 ; reduced from 9 to 3 in PT2.3E
peodskip
CMP.W D1,D0
BLT.B peodok
MOVE.W D1,D0
SUBQ.W #1,D0
peodok
MOVE.L D0,SongPosition
MOVE.L (SP)+,D1
BSR.B POSED_ScrollDelay
BRA.W POSED_Update
; added in PT2.3E to prevent insanely fast scroll on faster Amigas
POSED_ScrollDelay
MOVEM.L A0/D0-D1,-(SP)
LEA $DFF006,A0
MOVE.W #(255*3)-1,D0
.L0 MOVE.B (A0),D1
.L1 CMP.B (A0),D1
BEQ.B .L1
DBRA D0,.L0
MOVEM.L (SP)+,A0/D0-D1
RTS
lbC009F6C
MOVE.L SongDataPtr,A1
LEA sd_pattpos(A1),A1
MOVE.L PosEdCurrPos,D0
MOVE.B (A1,D0.W),PatternNumber+3
BSR.W RedrawPattern
BRA.W ppskip
PosInsert
TST.L RunMode
BNE.W Return2
MOVE.L SongDataPtr,A0
LEA sd_pattpos+126(A0),A0
MOVEQ #127,D0
MOVE.L CurrPos,D1
AND.L #127,D1
piloop MOVE.B (A0),1(A0)
SUBQ.L #1,A0
SUBQ.B #1,D0
CMP.B D1,D0
BHI.B piloop
CLR.B 1(A0)
BSR.W ShowPosition
CLR.W UpOrDown
BSR.W SongLengthGadg
BRA.W WaitForButtonUp
PosDelete
TST.L RunMode
BNE.W Return2
MOVE.L SongDataPtr,A0
LEA sd_pattpos(A0),A0
MOVE.L CurrPos,D0
AND.L #127,D0
ADD.L D0,A0
pdloop MOVE.B 1(A0),(A0)
ADDQ #1,A0
ADDQ.B #1,D0
CMP.B #127,D0
BLS.B pdloop
CLR.B -1(A0)
BSR.W ShowPosition
MOVE.W #$FFFF,UpOrDown
BSR.W SongLengthGadg
BRA.W WaitForButtonUp
EnterNumGadgWide
MOVE.W MouseY2,D1
CMP.W #66,D1
BLS.B engwend
CMP.W #77,D1
BLS.W EnterSLengthGadg
CMP.W #88,D1
BLS.W EnterSRepeatGadg
CMP.W #99,D1
BLS.W EnterSReplenGadg
engwend BRA.W PosInsDelGadgs ; yes, also test these
RTS
EnterNumGadg
MOVE.W MouseY2,D1
CMP.W #11,D1
BLS.B EnterSongPos
CMP.W #22,D1
BLS.W EnterPattGadg
CMP.W #33,D1
BLS.W EnterLenGadg
CMP.W #55,D1
BLS.B engrts
CMP.W #66,D1
BLS.W EnterSVolGadg
CMP.W #77,D1
BLS.W EnterSLengthGadg
CMP.W #88,D1
BLS.W EnterSRepeatGadg
CMP.W #99,D1
BLS.W EnterSReplenGadg
engrts RTS
EnterSongPos
TST.L RunMode
BNE.W Return2
CLR.B RawKeyCode
MOVEQ #0,D0
BTST #2,$DFF016 ; right mouse button
BNE.B espxskip
BRA.B espok
espxskip
MOVE.W #$4C,LineCurX
MOVE.W #9,LineCurY
MOVE.W #$A9,TextOffset
BSR.W GetDec3Dig
TST.W AbortDecFlag
BNE.W pogskip
CMP.W #$7F,D0
BLS.B espok
MOVEQ #$7F,D0
espok MOVE.L D0,CurrPos
BRA.W pogskip
EnterPattGadg
TST.L RunMode
BNE.W Return2
CLR.B RawKeyCode
MOVEQ #0,D0
BTST #2,$DFF016 ; right mouse button
BNE.B epgskip
BRA.B epgok
epgskip MOVE.W #84,LineCurX
MOVE.W #20,LineCurY
MOVE.W #610,TextOffset
BSR.W GetDecByte
TST.W AbortDecFlag
BNE.W pogskip
CMP.B MaxPattern+3(PC),D0
BLS.B epgok
MOVE.L MaxPattern(PC),D0
epgok MOVE.L SongDataPtr,A0
LEA sd_pattpos(A0),A0
ADD.L CurrPos,A0
MOVE.B D0,(A0)
BRA.W pogskip
EnterLenGadg
TST.L RunMode
BNE.W Return2
CLR.B RawKeyCode
MOVEQ #0,D0
BTST #2,$DFF016 ; right mouse button
BNE.B elengskip
BRA.B elengok
elengskip
MOVE.W #76,LineCurX
MOVE.W #31,LineCurY
MOVE.W #1049,TextOffset
BSR.W GetDec3Dig
TST.W AbortDecFlag
BNE.W ShowSongLength
CMP.W #127,D0 ; --PT2.3D bug fix: 127 instead of 128--
BLS.B elengok
MOVE.B #127,D0 ; --PT2.3D bug fix: 127 instead of 128--
elengok TST.B D0
BNE.B elengskip2
MOVE.B #1,D0
elengskip2
MOVE.L SongDataPtr,A0
LEA sd_numofpatt(A0),A0
MOVE.B D0,(A0)
BSR.W RefreshPosEd ; --PT2.3D bug fix: update Pos-Ed--
BRA.W ShowSongLength
EnterSVolGadg
CLR.B RawKeyCode
MOVE.W InsNum,D1
BEQ.W NotSampleNull
MOVEQ #0,D0
BTST #2,$DFF016 ; right mouse button
BNE.B esvolgskip
BRA.B esvolsgok
esvolgskip
MOVE.W #2370,TextOffset
BSR.W GetHexByte
TST.W AbortHexFlag
BNE.W ftuskip
CMP.B #$40,D0
BLS.B esvolsgok
MOVEQ #$40,D0
esvolsgok
MOVE.L SongDataPtr,A0
LEA 12(A0),A0
MOVE.W InsNum,D1
BEQ.W Return2
MULU.W #30,D1
ADD.L D1,A0
MOVE.B D0,3(A0)
BRA.W ftuskip
EnterSLengthGadg
CLR.B RawKeyCode
MOVE.W InsNum,D1
BEQ.W NotSampleNull
MOVEQ #0,D7
BTST #2,$DFF016 ; right mouse button
BNE.B eslengskip
BRA.B eslengskip2
eslengskip
MOVE.W #2807,TextOffset
BSR.W GetHexNybble
TST.W AbortHexFlag
BNE.W eslengok
SWAP D0
AND.L #$10000,D0
MOVE.L D0,D7
MOVE.W #2808,TextOffset
BSR.W GetHexByte
TST.W AbortHexFlag
BNE.B eslengok
LSL.W #8,D0
OR.W D0,D7
MOVE.W #2810,TextOffset
BSR.W GetHexByte
TST.W AbortHexFlag
BNE.B eslengok
OR.B D0,D7
CMP.L #$1FFFF,D7
BLS.B eslengskip4
MOVE.L #$1FFFF,D7
eslengskip4
LSR.L #1,D7
eslengskip2
MOVE.W #1,SampleLengthFlag
MOVE.L SongDataPtr,A0
LEA 12(A0),A0
MOVEQ #0,D0
MOVE.W InsNum,D0
BEQ.W ShowSampleInfo
MULU.W #30,D0
ADD.L D0,A0
MOVE.W 4(A0),D1
ADD.W 6(A0),D1
MOVE.W D7,(A0)
CMP.W #$FFFF,(A0)
BLO.B eslengskip3
MOVE.W #$FFFF,(A0)
eslengskip3
CMP.W D7,D1
BLS.B eslengok
CLR.W (A0)
CMP.W #1,D1
BEQ.B eslengok
MOVE.W D1,(A0)
eslengok
BRA.W ShowSampleInfo
EnterSRepeatGadg
CLR.B RawKeyCode
MOVE.W InsNum,D1
BEQ.W NotSampleNull
MOVEQ #0,D7
BTST #2,$DFF016 ; right mouse button
BNE.B esrepegskip
BRA.B esrepegskip2
esrepegskip
MOVE.W #3247,TextOffset
BSR.W GetHexNybble
TST.W AbortHexFlag
BNE.B esrepegok
SWAP D0
AND.L #$10000,D0
MOVE.L D0,D7
MOVE.W #3248,TextOffset
BSR.W GetHexByte
TST.W AbortHexFlag
BNE.B esrepegok
LSL.W #8,D0
OR.W D0,D7
MOVE.W #3250,TextOffset
BSR.W GetHexByte
TST.W AbortHexFlag
BNE.B esrepegok
OR.B D0,D7
CMP.L #$1FFFF,D7
BLS.B esrepegskip3
MOVE.L #$1FFFF,D7
esrepegskip3
LSR.L #1,D7
esrepegskip2
MOVE.L SongDataPtr,A0
LEA 12(A0),A0
MOVEQ #0,D0
MOVE.W InsNum,D0
BEQ.W ShowSampleInfo
MULU.W #30,D0
ADD.L D0,A0
MOVE.W (A0),D0
BEQ.B esrepegok
SUB.W 6(A0),D0
MOVE.W D0,4(A0)
CMP.W D7,D0
BLO.B esrepegok
MOVE.W D7,4(A0)
esrepegok
BSR.W ShowSampleInfo
BSR.W UpdateRepeats
JMP SetLoopSprites2
EnterSReplenGadg
CLR.B RawKeyCode
MOVE.W InsNum,D1
BEQ.W NotSampleNull
MOVEQ #0,D7
BTST #2,$DFF016 ; right mouse button
BNE.B esreplgskip
BRA.B esreplgskip2
esreplgskip
MOVE.W #3687,TextOffset
BSR.W GetHexNybble
TST.W AbortHexFlag
BNE.W esreplgok
SWAP D0
AND.L #$10000,D0
MOVE.L D0,D7
MOVE.W #3688,TextOffset
BSR.W GetHexByte
TST.W AbortHexFlag
BNE.B esreplgok
LSL.W #8,D0
OR.W D0,D7
MOVE.W #3690,TextOffset
BSR.W GetHexByte
TST.W AbortHexFlag
BNE.B esreplgok
OR.B D0,D7
CMP.L #$1FFFF,D7
BLS.B esreplgskip3
MOVE.L #$1FFFF,D7
esreplgskip3
LSR.L #1,D7
esreplgskip2
MOVE.L SongDataPtr,A0
LEA 12(A0),A0
MOVEQ #0,D0
MOVE.W InsNum,D0
BEQ.W ShowSampleInfo
MULU.W #30,D0
ADD.L D0,A0
MOVE.W (A0),D0
BEQ.B esreplgok
SUB.W 4(A0),D0
MOVE.W D0,6(A0)
CMP.W D7,D0
BLO.B esreplgok
MOVE.W #1,6(A0)
TST.W D7
BEQ.B esreplgok
MOVE.W D7,6(A0)
esreplgok
BSR.W ShowSampleInfo
BSR.W UpdateRepeats
JMP SetLoopSprites2
GetDec3Dig
MOVE.W #1,AbortDecFlag
BSR.W StorePtrCol
BSR.W SetWaitPtrCol
BSR.W UpdateLineCurPos
BSR.W GetKey0_9
CMP.W #68,D1
BEQ.B gd3exit
MOVE.W D1,D0
MULU.W #100,D0
MOVE.W D0,gd3temp
BSR.W ShowOneDigit
ADDQ.W #8,LineCurX
BSR.W UpdateLineCurPos
BSR.W GetKey0_9
CMP.B #68,D1
BEQ.B gd3exit
MOVE.W D1,D0
MULU.W #10,D0
ADD.W D0,gd3temp
BSR.W ShowOneDigit
ADDQ.W #8,LineCurX
BSR.W UpdateLineCurPos
BSR.W GetKey0_9
CMP.B #68,D1
BEQ.B gd3exit
ADD.W D1,gd3temp
CLR.W AbortDecFlag
gd3exit CLR.W LineCurX
MOVE.W #270,LineCurY
BSR.W UpdateLineCurPos
BSR.W RestorePtrCol
MOVEQ #0,D0
MOVE.W gd3temp(PC),D0
RTS
gd3temp dc.w 0
;---- Up/Down Gadgets ----
DownGadgets
ST UpdateFreeMem
MOVE.W #-1,UpOrDown
BRA.B ug2
UpGadgets
ST UpdateFreeMem
CLR.W UpOrDown
ug2 MOVE.W MouseY2,D0
CMP.W #100,D0
BHS.W Return2
CMP.W #89,D0
BHS.W RepLenGadg
CMP.W #78,D0
BHS.W RepeatGadg
CMP.W #67,D0
BHS.W SampleLengthGadg
CMP.W #56,D0
BHS.W VolumeGadg
CMP.W #45,D0
BHS.W SampleNumGadg
CMP.W #34,D0
BHS.W FineTuneGadg
CMP.W #23,D0
BHS.W SongLengthGadg
CMP.W #12,D0
BHS.W PatternGadg
TST.W MouseY2
BHS.B PositionGadg
RTS
PositionGadg
TST.W UpOrDown
BMI.B PositionDown
PositionUp
ADDQ.L #1,CurrPos
BTST #2,$DFF016 ; right mouse button
BNE.B pogskp2
ADD.L #9,CurrPos
pogskp2 CMP.L #127,CurrPos
BLS.B pogskip
MOVE.L #127,CurrPos
pogskip MOVE.L CurrPos,SongPosition
BSR.W ShowPosition
BSR.W RefreshPosEd
BSR.W Wait_4000
BSR.W Wait_4000
BRA.W Wait_4000
PositionDown
SUBQ.L #1,CurrPos
BTST #2,$DFF016 ; right mouse button
BNE.B pogskp3
SUB.L #9,CurrPos
pogskp3 TST.L CurrPos
BPL.B pogskip
CLR.L CurrPos
BRA.B pogskip
PatternGadg
MOVE.L SongDataPtr,A0
LEA sd_pattpos(A0),A0
TST.W UpOrDown
BMI.B PatternDown
PatternUp
ADD.L CurrPos,A0
ADDQ.B #1,(A0)
BTST #2,$DFF016 ; right mouse button
BNE.B pagaskp
ADD.B #9,(A0)
pagaskp MOVE.B (A0),D0
CMP.B MaxPattern+3(PC),D0
BLS.B pogskip
MOVE.B MaxPattern+3(PC),(A0)
BRA.W pogskip
PatternDown
ADD.L CurrPos,A0
SUBQ.B #1,(A0)
BTST #2,$DFF016 ; right mouse button
BNE.B padoskp
SUB.B #9,(A0)
padoskp TST.B (A0)
BPL.W pogskip
CLR.B (A0)
BRA.W pogskip
SongLengthGadg
MOVE.L SongDataPtr,A0
LEA sd_numofpatt(A0),A0
TST.W UpOrDown
BMI.B SongLengthDown
SongLengthUp
ADDQ.B #1,(A0)
BTST #2,$DFF016 ; right mouse button
BNE.B slupskp
ADD.B #9,(A0)
slupskp CMP.B #128,(A0) ; --PT2.3D bugfix: was 127
BMI.B solgskip
MOVE.B #128,(A0) ; --PT2.3D bugfix: was 127
solgskip BSR.W ShowSongLength
BSR.W RefreshPosEd
BSR.W Wait_4000
BSR.W Wait_4000
BRA.W Wait_4000
SongLengthDown
SUBQ.B #1,(A0)
BTST #2,$DFF016 ; right mouse button
BNE.B sldoskp
SUB.B #9,(A0)
sldoskp CMP.B #1,(A0)
BGE.B solgskip
MOVE.B #1,(A0)
BRA.B solgskip
SampleNumGadg
BTST #2,$DFF016 ; right mouse button
BNE.B SampleNum2
TST.W InsNum
BEQ.W ShowSampleInfo
MOVE.W InsNum,LastInsNum
CLR.W InsNum
BRA.W ShowSampleInfo
SampleNum2
TST.W UpOrDown
BMI.B SampleNumDown
SampleNumUp
ADDQ.W #1,InsNum
CMP.W #31,InsNum
BMI.B snuskip
MOVE.W #31,InsNum
snuskip BSR.W redrsam
BSR.W Wait_4000
BRA.W Wait_4000
RTS
SampleNumDown
TST.W InsNum
BEQ.B snuskip
SUBQ.W #1,InsNum
CMP.W #1,InsNum
BPL.B snuskip
MOVE.W #1,InsNum
BRA.B snuskip
FineTuneGadg
MOVE.L SongDataPtr,A0
LEA 12(A0),A0
MOVE.W InsNum,D0
BEQ.W Return2
MULU.W #30,D0
ADD.L D0,A0
BTST #2,$DFF016 ; right mouse button
BNE.B ftgskip
CLR.B 2(A0)
BRA.B ftuskip
ftgskip TST.W UpOrDown
BMI.B FineTuneDown
AND.B #15,2(A0)
CMP.B #7,2(A0)
BEQ.B ftuskip
ADDQ.B #1,2(A0)
AND.B #15,2(A0)
ftuskip BSR.W ShowSampleInfo
BSR.W Wait_4000
BRA.W Wait_4000
FineTuneDown
AND.B #$0F,2(A0)
CMP.B #8,2(A0)
BEQ.B ftuskip
SUBQ.B #1,2(A0)
AND.B #$0F,2(A0)
BRA.B ftuskip
VolumeGadg
MOVE.L SongDataPtr,A0
LEA 12(A0),A0
MOVE.W InsNum,D0
BEQ.W Return2
MULU.W #30,D0
ADD.L D0,A0
TST.W UpOrDown
BMI.B VolumeDown
VolumeUp
ADDQ.B #1,3(A0)
BTST #2,$DFF016 ; right mouse button
BNE.B voupskp
ADD.B #15,3(A0)
voupskp CMP.B #$40,3(A0)
BLS.B ftuskip
MOVE.B #$40,3(A0)
BRA.B ftuskip
VolumeDown
SUBQ.B #1,3(A0)
BTST #2,$DFF016 ; right mouse button
BNE.B vodoskp
SUB.B #15,3(A0)
vodoskp TST.B 3(A0)
BPL.W ftuskip
CLR.B 3(A0)
BRA.W ftuskip
SampleLengthGadg
MOVE.W #1,SampleLengthFlag
MOVE.L SongDataPtr,A0
LEA 12(A0),A0
MOVEQ #0,D0
MOVE.W InsNum,D0
BEQ.W ShowSampleInfo
MULU.W #30,D0
ADD.L D0,A0
MOVEQ #0,D0
MOVE.W (A0),D0
TST.W UpOrDown
BMI.B SampleLengthDown
SampleLengthUp
ADDQ.L #1,D0
BTST #2,$DFF016 ; right mouse button
BNE.B sluskip
CMP.L #$0000FFF0,D0
BHS.B sluskip
ADDQ.L #7,D0
sluskip JSR GUIDelay
sluskip2
CMP.L #$FFFF,D0
BLS.W sluskip3
MOVE.L #$FFFF,D0
BRA.W ShowSampleInfo
sluskip3
MOVE.W D0,(A0)
BRA.W ShowSampleInfo
SampleLengthDown
MOVEQ #0,D0
MOVEQ #0,D1
MOVE.W 4(A0),D0
ADD.W 6(A0),D0
MOVE.W (A0),D1
SUBQ.L #1,D1
BTST #2,$DFF016 ; right mouse button
BNE.B sldskip
SUBQ.L #7,D1
sldskip
BMI.B sldskip2
CMP.L D1,D0
BLS.W sldskip3
MOVE.W D0,(A0)
CMP.L #1,D0
BEQ.B sldskip2
BRA.B sldskip5
sldskip2
CLR.W (A0)
BRA.B sldskip5
sldskip3
MOVE.W D1,(A0)
sldskip5
JSR GUIDelay
sldskip4
BRA.W ShowSampleInfo
SampleLengthFlag dc.w 0
CheckSampleLength
TST.W SampleLengthFlag
BEQ.W Return2
CLR.W SampleLengthFlag
MOVEQ #0,D0
MOVE.W InsNum,D0
BEQ.W Return2
MOVE.L SongDataPtr,A0
LEA 12(A0),A0
MOVE.L D0,D1
LSL.W #2,D1
MULU.W #30,D0
ADD.L D0,A0
LEA SongDataPtr,A1
LEA (A1,D1.W),A1
MOVE.L A0,PlaySamPtr
MOVE.L A1,RealSamPtr
MOVE.L 124(A1),D0
LSR.L #1,D0
MOVE.W (A0),D1
CMP.W D0,D1
BHI.B ItsTooMuch
RTS
ItsTooMuch
LEA AddWorkSpaceText(PC),A0
BSR.W AreYouSure
BNE.B RestoreLength
BSR.W TurnOffVoices
MOVE.L PlaySamPtr(PC),A0
MOVEQ #0,D0
MOVE.W (A0),D0
ADD.L D0,D0
MOVE.L D0,SamAllocLen
MOVE.L #MEMF_CHIP!MEMF_CLEAR,D1
JSR PTAllocMem
MOVE.L D0,SamAllocPtr
BEQ.B RestoreLength
MOVE.L D0,A1
MOVE.L RealSamPtr(PC),A0
MOVE.L (A0),D0
BEQ.B nosamth
MOVE.L D0,A2
MOVE.L 124(A0),D1
BEQ.B nosamth
SUBQ.L #1,D1
cpsalop MOVE.B (A2)+,(A1)+
DBRA D1,cpsalop
MOVE.L (A0),A1
MOVE.L 124(A0),D0
JSR PTFreeMem
nosamth MOVE.L RealSamPtr(PC),A0
MOVE.L SamAllocPtr(PC),(A0)
MOVE.L SamAllocLen(PC),124(A0)
BSR.W ShowSampleInfo
JSR RedrawSample
JSR DoShowFreeMem
BRA.W WaitForButtonUp
RestoreLength
MOVE.L PlaySamPtr(PC),A0
MOVE.L RealSamPtr(PC),A1
MOVE.L 124(A1),D0
LSR.L #1,D0
MOVE.W D0,(A0)
BRA.W ShowSampleInfo
CNOP 0,4
PlaySamPtr dc.l 0
RealSamPtr dc.l 0
SamAllocPtr dc.l 0
SamAllocLen dc.l 0
AddWorkSpaceText dc.b 'add workspace ?',0
EVEN
RepeatGadg
MOVE.L SongDataPtr,A0
LEA 12(A0),A0
MOVEQ #0,D0
MOVEQ #0,D1
MOVEQ #0,D2
MOVE.W InsNum,D0
BEQ.W ShowSampleInfo
MULU.W #30,D0
ADD.L D0,A0
MOVE.W 4(A0),D2
TST.W UpOrDown
BMI.B RepeatDown
RepeatUp
ADDQ.L #1,D2
BTST #2,$DFF016 ; right mouse button
BNE.B ruskip
ADDQ.L #7,D2
ruskip
MOVE.W (A0),D0 ; Length
BEQ.B ruskip4
MOVE.W 6(A0),D1 ; RepLen
SUB.L D1,D0 ; Length - RepLen
CMP.L D2,D0
BHI.B ruskip2
MOVE.W D0,4(A0)
BRA.B repdone
ruskip2
MOVE.W D2,4(A0)
repdone JSR GUIDelay
ruskip3
BSR.W ShowSampleInfo
BSR.W UpdateRepeats
JMP SetLoopSprites2
ruskip4
CLR.W 4(A0)
BRA.B repdone
RepeatDown
SUBQ.L #1,D2
BTST #2,$DFF016 ; right mouse button
BNE.B rdskip
SUBQ.L #7,D2
rdskip TST.L D2
BPL.B ruskip2
MOVEQ #0,D2
BRA.B ruskip2
RepLenGadg
MOVE.L SongDataPtr,A0
LEA 12(A0),A0
MOVEQ #0,D0
MOVEQ #0,D1
MOVEQ #0,D2
MOVE.W InsNum,D0
BEQ.W ShowSampleInfo
MULU.W #30,D0
ADD.L D0,A0
MOVE.W 6(A0),D2
TST.W UpOrDown
BMI.B RepLenDown
RepLenUp
ADDQ.L #1,D2
BTST #2,$DFF016 ; right mouse button
BNE.B rluskip
ADDQ.L #7,D2
rluskip
MOVE.W (A0),D0 ; Length
BEQ.B rlupskip4
MOVE.W 4(A0),D1
SUB.L D1,D0
CMP.L D2,D0
BHI.W rlupskip3
CMP.L #1,D0
BGE.B rlupskip2
MOVEQ #1,D0
rlupskip2
MOVE.W D0,6(A0)
BRA.W repdone
rlupskip3
MOVE.W D2,6(A0)
BRA.W repdone
rlupskip4
MOVE.W #$0001,6(A0)
BRA.W repdone
RepLenDown
MOVEQ #0,D0
MOVE.W 6(A0),D0
SUBQ.L #1,D0
BTST #2,$DFF016 ; right mouse button
BNE.B rldskip
SUBQ.L #7,D0
rldskip CMP.L #1,D0
BGE.B rldskp2
MOVEQ #1,D0
rldskp2 MOVE.W D0,6(A0)
BRA.W repdone
Wait_4000
MOVEM.L D0/D1/A0/A1/A6,-(SP)
MOVE.L DOSBase,A6
MOVEQ #1,D1
JSR _LVODelay(A6)
MOVEM.L (SP)+,D0/D1/A0/A1/A6
RTS
UpdateRepeats
; 8bitbubsy: just in case...
MOVE.L SongDataPtr,A0
MOVE.W InsNum,D0
BEQ.W upreRTS
MULU.W #30,D0
LEA 12(A0,D0.W),A0
; --------------------------
MOVE.L A4,-(SP)
LEA audchan1temp,A1
LEA $DFF0A0,A2
LEA ScopeInfo+(ScopeInfoSize*0),A3
BSR.B upre2
LEA audchan2temp,A1
LEA $DFF0B0,A2
LEA ScopeInfo+(ScopeInfoSize*1),A3
BSR.B upre2
LEA audchan3temp,A1
LEA $DFF0C0,A2
LEA ScopeInfo+(ScopeInfoSize*2),A3
BSR.B upre2
LEA audchan4temp,A1
LEA $DFF0D0,A2
LEA ScopeInfo+(ScopeInfoSize*3),A3
BSR.B upre2
MOVE.L (SP)+,A4
RTS
upre2 MOVE.W InsNum,D0
CMP.B n_samplenum(A1),D0 ; channel sample == selected GUI sample?
BNE.B upreRTS ; nope, don't update loops
MOVE.L n_start(A1),A4
CMP.L #0,A4 ; ch->n_start == NULL?
BEQ.B upreRTS ; yep, don't update loops
MOVEQ #0,D0
MOVE.W 4(A0),D0 ; repeat
ADD.L D0,A4
ADD.L D0,A4
MOVE.W 6(A0),D0 ; replen
; ----------------------------
; PT2.3D bugfix: also update replayer vars
MOVE.L A4,n_loopstart(A1)
MOVE.W D0,n_replen(A1)
MOVE.L A4,n_wavestart(A1)
; ----------------------------
MOVE.L A4,0(A2) ; set Paula DAT
MOVE.W D0,4(A2) ; set Paula LEN
; ----------------------------
MOVE.L A4,ns_repeatptr(A3) ; quadrascope
ADD.L D0,A4
ADD.L D0,A4
MOVE.L A4,ns_rependptr(A3)
upreRTS RTS
SetPatternPos
MOVE.L PatternPosition,D0
LSR.L #4,D0
BRA.B ssppskip
SetScrPatternPos
MOVE.W ScrPattPos,D0
ssppskip
TST.W SamScrEnable
BNE.B Return2
MOVE.W D0,PlayFromPos
MULU.W #7*40,D0
ADD.L #TextBitplane+5560,D0
MOVE.L CopListBpl4Ptr,A1
MOVE.W D0,6(A1)
SWAP D0
MOVE.W D0,2(A1)
Return2
RTS
PlayFromPos dc.w 0
xTempoGadg JMP TempoGadg
WantedPattGadg
TST.W SamScrEnable
BNE.W CheckSamGadgets
TypeInWantedPatt
CMP.W #138,D1
BHI.B tiwp2
CMP.W #25,D0
BHI.B xTempoGadg
tiwp2 CMP.L #'patp',RunMode ; not if a song is playing...
BEQ.B Return2
CLR.B RawKeyCode
MOVE.W #12,LineCurX
MOVE.W #$0085,LineCurY
MOVE.W #5121,TextOffset
BSR.W GetDecByte
TST.W AbortDecFlag
BNE.B twexit
MOVE.B D0,PatternNumber+3
MOVE.L PatternNumber,D0
CMP.L MaxPattern(PC),D0
BLS.B twexit
MOVE.L MaxPattern(PC),PatternNumber
twexit BRA.W RedrawPattern
GetKey0_9
BTST #2,$DFF016 ; right mouse button
BEQ.B gk_ret
JSR CheckPatternRedraw2
MOVEQ #0,D0
JSR DoKeyBuffer
MOVE.B RawKeyCode,D0
BEQ.B GetKey0_9
CLR.B RawKeyCode
CMP.B #68,D0
BEQ.B gk_ret
CMP.B #69,D0
BEQ.B gk_ret
CMP.B #10,D0
BEQ.B gk_end
BHI.B GetKey0_9
CMP.B #1,D0
BLO.B GetKey0_9
MOVE.L D0,D1
RTS
gk_end MOVEQ #0,D1
RTS
gk_ret MOVEQ #68,D1
RTS
ShowOneDigit
ADD.B #'0',D1
MOVE.B D1,NumberText
CLR.W D1
SWAP D1
MOVE.W #1,TextLength
MOVE.L #NumberText,ShowTextPtr
BSR.W ShowText
CLR.L NumberText
CLR.W WordNumber
RTS
;---- Get Text Line ----
GetTextLine
MOVEQ #0,D0
MOVE.W A4,D0
DIVU.W #40,D0
ADDQ.W #5,D0
MOVE.W D0,LineCurY
SWAP D0
LSL.W #3,D0
ADDQ.W #4,D0
MOVE.W D0,LineCurX
BSR.W UpdateLineCurPos
MOVE.L ShowTextPtr,DSTPtr
CLR.L DSTOffset
CLR.L DSTPos
MOVE.W #1,GetLineFlag
MOVE.W #0,AbortStrFlag
MOVE.L A4,A5
MOVE.W LineCurX,D5
CLR.B RawKeyCode
BSR.W UpdateText
WaitForKey
BTST #2,$DFF016 ; right mouse button
BEQ.W AbortGetLine
BTST #6,$BFE001 ; left mouse button
BEQ.W LineClicked
JSR CheckPatternRedraw2
JSR DoKeyBuffer
MOVEQ #0,D1
MOVE.B RawKeyCode,D1
BEQ.B WaitForKey
CMP.B #78,D1 ; Left
BEQ.W MoveCharRight
CMP.B #79,D1 ; Right
BEQ.W MoveCharLeft
CMP.B #70,D1 ; DEL
BEQ.W DeleteChar
CMP.B #65,D1 ; Backspace
BEQ.W BackspaceChar
CMP.B #68,D1 ; Return
BEQ.W GetLineReturn
CMP.B #69,D1 ; ESC
BEQ.W GetLineReturn
BTST #7,D1
BNE.B WaitForKey
LEA UnshiftedKeymap,A4
TST.W ShiftKeyStatus
BEQ.B gtlskip
LEA ShiftedKeymap,A4
gtlskip AND.W #$007F,D1
CMP.B #64,D1
BHI.W WaitForKey
MOVE.B (A4,D1.W),D1
BEQ.W WaitForKey
TST.B EnterTextFlag
BEQ.B TextLineKey
CMP.B #'0',D1
BLO.W WaitForKey
CMP.B #'f',D1
BHI.W WaitForKey
CMP.B #'a',D1
BHS.B TextLineKey
CMP.B #'9',D1
BHI.W WaitForKey
TextLineKey
CMP.L TextEndPtr,A6
BEQ.W WaitForKey
MOVE.L TextEndPtr,A4
tlkloop MOVE.B -(A4),1(A4)
CMP.L A4,A6
BNE.B tlkloop
MOVE.L TextEndPtr,A4
CLR.B (A4)
MOVE.B D1,(A6)+
BSR.B PosMoveRight
BSR.W UpdateText
CLR.B RawKeyCode
BRA.W WaitForKey
LineClicked
MOVE.W MouseY(PC),D1
SUB.W LineCurY,D1
CMP.W #2,D1
BGT.W GetLineReturn
CMP.W #-8,D1
BLT.W GetLineReturn
MOVE.W MouseX(PC),D1
SUB.W LineCurX,D1
ADDQ.W #4,D1
ASR.W #3,D1
BEQ.W WaitForKey
BPL.B linclri
CMP.L DSTPtr(PC),A6
BEQ.W WaitForKey
SUBQ.L #1,A6
BSR.B PosMoveLeft
upwake2 BSR.W UpdateText
BRA.W WaitForKey
linclri CMP.L TextEndPtr,A6
BEQ.W WaitForKey
TST.B (A6)
BEQ.W WaitForKey
ADDQ #1,A6
BSR.B PosMoveRight
BRA.B upwake2
PosMoveRight
MOVE.L DSTPos(PC),D0
MOVEQ #0,D1
MOVE.W TextLength,D1
TST.B EnterTextFlag
BNE.B pmrskip
SUBQ.W #1,D1
pmrskip CMP.L D1,D0
BLO.B posrok
ADDQ.L #1,DSTOffset
BRA.W UpdateLineCurPos
posrok ADDQ.L #1,DSTPos
ADDQ.W #8,LineCurX
BRA.W UpdateLineCurPos
PosMoveLeft
TST.L DSTPos
BNE.B poslok
SUBQ.L #1,DSTOffset
BRA.W UpdateLineCurPos
poslok SUBQ.L #1,DSTPos
SUBQ.W #8,LineCurX
BRA.W UpdateLineCurPos
BackspaceChar
CMP.L DSTPtr(PC),A6
BEQ.W WaitForKey
SUBQ.L #1,A6
MOVE.L A6,A4
dobaloop
MOVE.B 1(A4),(A4)+
CMP.L TextEndPtr,A4
BNE.B dobaloop
BSR.B PosMoveLeft
upwake BSR.W UpdateText
BSR.W Wait_4000
BSR.W Wait_4000
BSR.W Wait_4000
BRA.W WaitForKey
DeleteChar
MOVE.L A6,A4
dechloop
MOVE.B 1(A4),(A4)+
CMP.L TextEndPtr,A4
BLO.B dechloop
BRA.B upwake
MoveCharRight
CMP.L TextEndPtr,A6
BEQ.W WaitForKey
TST.B (A6)
BEQ.W WaitForKey
ADDQ #1,A6
BSR.W PosMoveRight
BRA.B upwake
MoveCharLeft
CMP.L DSTPtr(PC),A6
BEQ.W WaitForKey
SUBQ.L #1,A6
BSR.W PosMoveLeft
BRA.B upwake
GetLineReturn
MOVE.L DSTPtr(PC),A6
CMP.B #1,EnterTextFlag
BNE.B gtl_rskip
TST.B DiskNumText2
BEQ.W WaitForKey
gtl_rskip
CMP.B #3,EnterTextFlag
BNE.B gtl_rskip2
TST.B SndDiskNum1
BEQ.W WaitForKey
gtl_rskip2
MOVE.L A6,A4
dlrloop TST.B (A4)+
BNE.B dlrloop
SUBQ.L #1,A4
dlrloop2
CMP.L TextEndPtr,A4
BHS.B dlrexit
CLR.B (A4)+
BRA.B dlrloop2
dlrexit CLR.W LineCurX
MOVE.W #270,LineCurY
BSR.W UpdateLineCurPos
CLR.W GetLineFlag
MOVE.B RawKeyCode,MixChar
CLR.B RawKeyCode
CLR.L DSTOffset
BSR.B UpdateText
BRA.W WaitForButtonUp
AbortGetLine
MOVE.W #1,AbortStrFlag
MOVE.L DSTPtr(PC),A6
MOVE.L A6,A4
clliloop
CLR.B (A4)+
CMP.L TextEndPtr,A4
BNE.B clliloop
BSR.B UpdateText
BRA.W GetLineReturn
UpdateText
MOVE.W A5,TextOffset
MOVE.L DSTPtr(PC),A0
ADD.L DSTOffset(PC),A0
BRA.W ShowText2
CNOP 0,4
DSTPtr dc.l 0
DSTPos dc.l 0
DSTOffset dc.l 0
;----
TypeInSongName
BSR.W StorePtrCol
BSR.W SetWaitPtrCol
CLR.L EditMode
MOVE.L SongDataPtr,A6
MOVE.L A6,TextEndPtr
MOVE.L A6,ShowTextPtr
ADD.L #19,TextEndPtr
MOVE.W #20,TextLength
MOVE.W #4133,A4
BSR.W GetTextLine
CLR.L TextEndPtr
BRA.W RestorePtrCol
CheckSmplNamOrLoad
CMP.W #$11F,MouseX2
BHS.W LoadNamedSample
BSR.W StorePtrCol
TypeInSampleName
BSR.W SetWaitPtrCol
CLR.L EditMode
MOVE.L SongDataPtr,A6
LEA -10(A6),A6
MOVE.W InsNum,D7
BNE.B tisnskip
MOVE.W LastInsNum,D7
tisnskip
MULU.W #30,D7
ADD.L D7,A6
MOVE.L A6,TextEndPtr
MOVE.L A6,ShowTextPtr
ADD.L #21,TextEndPtr
MOVE.W #22,TextLength
MOVE.W #4573,A4
BSR.W GetTextLine
CLR.L TextEndPtr
BRA.W RestorePtrCol
LoadSample
TST.W InsNum
BEQ.W NotSampleNull
BSR.W StorePtrCol
LEA SamplePath2,A0
BSR.W CopyPath
LEA DirInputName,A0
MOVEQ #DirNameLength-1,D0
lsloop MOVE.B (A0)+,(A1)+
DBRA D0,lsloop
MOVE.L SongDataPtr,A0
MOVE.W InsNum,D0
MULU.W #30,D0
LEA -10(A0),A0
ADD.L D0,A0
LEA DirInputName,A1
MOVEQ #22-1,D0
lsloop2 MOVE.B (A1)+,(A0)+
DBRA D0,lsloop2
BSR.W SetDiskPtrCol
MOVE.L #FileName,D1
BSR.W ExamineAndAlloc
BEQ.W ErrorRestoreCol
MOVE.L #FileName,D1
BRA.W lnssec2
CheckForIFF2 ; load loop
MOVEQ #-1,D2
BRA.B ciff2
CheckForIFF
MOVEQ #0,D2
ciff2 MOVEQ #0,D1
CMP.L #'FORM',(A0)
BNE.B wiskip
CMP.L #'8SVX',8(A0)
BNE.B wiskip
MOVE.L A0,A2
MOVE.L A1,D0
ADD.L A0,A1
TST.L D2
BEQ.B cfiloop
BSR.W CheckIFFLoop
cfiloop CMP.L #'BODY',(A0)
BEQ.B WasIFF
ADDQ #2,A0
CMP.L A1,A0
BLS.B cfiloop
RTS
WasIFF ADDQ #8,A0
ADD.L A2,D0
SUB.L A0,D0
wiloop MOVE.B (A0)+,(A2)+
CMP.L A1,A0
BLS.B wiloop
MOVE.L SampleInstrSave(PC),A3
CMP.L #$1FFFE,D0 ; overflow fix
BLS.B wiok
MOVE.L #$1FFFE,D0
wiok LSR.L #1,D0
MOVE.W 22(A3),D1
SUB.W D0,D1
MOVE.W D0,22(A3)
; -------------------------------------------
; IFF bugfix: update internal length variable
MOVE.W InsNum,D3
BEQ.B wiskip
SUBQ.W #1,D3
LSL.W #2,D3
AND.L #$FFFF,D0
ADD.L D0,D0
LEA SampleLengths,A2
MOVE.L D0,(A2,D3.W)
; -------------------------------------------
wiskip LEA SampleLengthAdd(PC),A3
MOVE.W InsNum,D0
ADD.W D0,D0
MOVE.W D1,(A3,D0.W)
RTS
CheckIFFLoop
MOVEM.L D0-D3/A0,-(SP)
TST.B IFFLoopFlag
BEQ.W wDisL
cilloop CMP.L #'VHDR',(A0)
BEQ.B wasvhdr
ADDQ #2,A0
CMP.L A1,A0
BLS.B cilloop
cilend
MOVEM.L (SP)+,D0-D3/A0
RTS
; 8bitbubsy: modified to safely disable overflown loop points
wasvhdr MOVE.L SampleInstrSave(PC),A3
MOVEQ #0,D0
MOVE.W 22(A3),D0
ADD.L D0,D0 ; D0 = allocated sample length (in bytes)
MOVE.L 8(A0),D1 ; D1 = IFF repeat
MOVE.L 12(A0),D2 ; D2 = IFF replen
CMP.L #2,D2 ; IFF replen >= 2 ?
BLO.B wDisL ; nope, disable loop
MOVE.L D1,D3
ADD.L D2,D3 ; D3 = IFF repend
CMP.L D0,D3 ; IFF repend <= allocated sample length ?
BHI.B wDisL ; nope, disable loop
LSR.L #1,D1
MOVE.W D1,26(A3) ; store repeat
LSR.L #1,D2
MOVE.W D2,28(A3) ; store replen
BRA.B cilend
wDisL MOVE.L SampleInstrSave(PC),A3
CLR.W 26(A3) ; disable sample loop
MOVE.W #1,28(A3)
BRA.B cilend
CNOP 0,4
SampleInstrSave dc.l 0
SampleLengthAdd dcb.w 32+1,0
ExamineAndAlloc ; fixed in PT2.3E to be 128kB compatible
MOVEQ #-2,D2
MOVE.L DOSBase,A6
JSR _LVOLock(A6)
MOVE.L D0,FileLock
BEQ.W CantFindFile
MOVE.L D0,D1
MOVE.L #FileInfoBlock,D2
JSR _LVOExamine(A6)
TST.L FIB_EntryType
BPL.W CantExamFile
MOVE.L FileLock,D1
JSR _LVOUnLock(A6)
MOVE.L FIB_FileSize,D0
BEQ.W FileIsEmpty
BSR.W TurnOffVoices
BSR.W FreeSample
MOVE.L FIB_FileSize,D0
CMP.L #$1FFFE,D0 ; 8bitbubsy: add padding for header
BLS.B exalloc
MOVE.L #$1FFFE,D0 ; 8bitbubsy: add padding for header
exalloc LEA SongDataPtr,A4
MOVEQ #0,D1
MOVE.W InsNum,D1
LSL.W #2,D1
ADD.L D1,A4
MOVE.L D0,124(A4)
MOVE.L D0,DiskDataLength
MOVE.L #MEMF_CHIP!MEMF_CLEAR,D1
JSR PTAllocMem
MOVE.L D0,DiskDataPtr
MOVE.L D0,(A4)
BEQ.W OutOfMemErr
LEA LoadingSampleText,A0
BSR.W ShowStatusText
SampleAllocOK
MOVE.L SongDataPtr,A0
MOVE.W InsNum,D0
MULU.W #30,D0
LEA -10(A0),A0
ADD.L D0,A0
MOVE.L A0,SampleInstrSave
MOVE.L DiskDataLength,D0
CMP.L #$1FFFE,D0
BLS.B .skip
MOVE.L #$1FFFE,D0
.skip LSR.L #1,D0
MOVE.W D0,22(A0)
MOVE.L #$00400000,24(A0)
MOVE.W #1,28(A0)
BSR.W ShowSampleInfo
MOVEQ #-1,D0
RTS
LoadNamedSample
TST.W InsNum
BEQ.W NotSampleNull
BSR.W StorePtrCol
BSR.W CreateSampleName
BSR.W SetDiskPtrCol
MOVE.L FileNamePtr,D1
BSR.W ExamineAndAlloc
BEQ.W Return2
MOVE.L FileNamePtr,D1
lnssec2 MOVE.L DOSBase,A6
MOVE.L #1005,D2
JSR _LVOOpen(A6)
MOVE.L D0,D7
BEQ.W CantOpenFile
MOVE.L D0,D1
MOVE.L DiskDataPtr,D2
MOVE.L DiskDataLength,D3
JSR _LVORead(A6)
MOVE.L D7,D1
JSR _LVOClose(A6)
MOVE.L DiskDataPtr,A0
MOVE.L DiskDataLength,A1
CMP.L #"PP20",(A0)
BEQ.W LoadCrunchedSample
CMP.L #"PX20",(A0)
BEQ.W LoadCrunchedSample
LoadSampleOK
BSR.W CheckForIFF2
BSR.W ValidateLoops
BSR.W ShowSampleInfo
MOVE.L DiskDataPtr,A0
CLR.W (A0)
JSR RedrawSample
CLR.L SavSamInf
BSR.W ShowAllRight
BRA.W RestorePtrCol
CreateSampleName
LEA SampleFileName,A0
MOVEQ #28-1,D0
csnloop CLR.B (A0)+
DBRA D0,csnloop
MOVE.L SongDataPtr,A0
MOVE.W InsNum,D0
MULU.W #30,D0
LEA -10(A0),A0
ADD.L D0,A0
MOVE.L A0,SampleInstrSave
MOVEQ #0,D0
MOVE.W 22(A0),D0
ADD.L D0,D0
MOVE.L D0,DiskDataLength
MOVE.L D0,IFFBODY+4
ADD.L #IFFEND-IFFFORM-8,D0
MOVE.L D0,IFFFORM+4
MOVEQ #0,D0
MOVE.W 22(A0),D0
ADD.L D0,D0
MOVEQ #0,D1
MOVE.W 28(A0),D1
CMP.W #1,D1
BLS.B csnskp2
ADD.L D1,D1
MOVEQ #0,D0
MOVE.W 26(A0),D0
ADD.L D0,D0
BRA.B csnskp3
csnskp2 MOVEQ #0,D1
csnskp3 MOVE.L D0,IFFVHDR+8
MOVE.L D1,IFFVHDR+12
LEA SampleFileName,A1
LEA IFFNAME+8(PC),A2
MOVEQ #22-1,D0
csnloop2
MOVE.B (A0),(A1)+
MOVE.B (A0)+,(A2)+
DBRA D0,csnloop2
MOVE.L #SampleFileName,D1
MOVE.L D1,FileNamePtr
BSR.B FindColon
BEQ.B CheckOverride
LEA SamplePath2,A0
BSR.W CopyPath
LEA SampleFileName,A0
csnloop3
MOVE.B (A0)+,(A1)+
BNE.B csnloop3
MOVE.L #FileName,FileNamePtr
RTS
FindColon
MOVE.L D1,A0
fcloop MOVE.B (A0)+,D0
BEQ.B FindColonFail
CMP.B #':',D0
BEQ.B FindColonSuccess
BRA.B fcloop
FindColonFail
MOVEQ #-1,D0
RTS
FindColonSuccess
MOVEQ #0,D0
RTS
CheckOverride
TST.B OverrideFlag
BEQ.W Return2
LEA SampleFileName,A0
MOVE.L A0,A1
LEA 21(A1),A1
MOVE.L A1,A2
chkovlp MOVE.B -(A1),D0
CMP.B #':',D0
BEQ.B chkovok
CMP.B #'/',D0
BEQ.B chkovok
MOVE.L A1,A2
CMP.L A0,A1
BHI.B chkovlp
chkovok LEA SamplePath2,A0
BSR.W CopyPath
chkovl2 MOVE.B (A2)+,(A1)+
BNE.B chkovl2
MOVE.L #FileName,FileNamePtr
RTS
ValidateLoops
MOVE.L SongDataPtr,A0
LEA sd_sampleinfo(A0),A0
MOVEQ #31-1,D0
valolop MOVE.W 22(A0),D1
MOVE.W 26(A0),D2
MOVE.W 28(A0),D3
CMP.W D1,D2
BHS.B valosk1
ADD.W D2,D3
CMP.W D1,D3
BHI.B valosk2
valoque TST.W 28(A0)
BNE.B valosk3
MOVE.W #1,28(A0)
valosk3 LEA 30(A0),A0
DBRA D0,valolop
RTS
valosk2 SUB.W D2,D1
MOVE.W D1,28(A0)
BRA.B valoque
valosk1 MOVEQ #1,D1
MOVE.L D1,26(A0)
BRA.B valoque
LoadPreset
CLR.B RawKeyCode
TST.W InsNum
BEQ.W NotSampleNull
BSR.W TurnOffVoices
BSR.W FreeSample
BSR.W CreateSampleName
MOVE.L FileNamePtr,A0
TST.B (A0)
BEQ.W Return2
MOVE.L DiskDataLength,D0
BEQ.W Return2
MOVE.L DiskDataLength,D0
BSR.B AllocSample
MOVE.L DiskDataPtr,D0
BEQ.B loprerr
BSR.W ShowSampleInfo
BSR.W DoLoadData
BSR.W ShowAllRight
MOVE.L DiskDataPtr,A0
MOVE.L DiskDataLength,A1
BSR.W CheckForIFF
BSR.W ValidateLoops
BSR.W ShowSampleInfo
MOVE.L DiskDataPtr,A0
CLR.W (A0)
JSR RedrawSample
ST UpdateFreeMem
RTS
loprerr BSR.W StorePtrCol
BSR.W OutOfMemErr
BSR.W RestorePtrCol
JMP RedrawSample
AllocSample
MOVE.L D0,-(SP)
MOVE.L #MEMF_CHIP!MEMF_CLEAR,D1
JSR PTAllocMem
MOVE.L D0,DiskDataPtr
LEA SamplePtrs,A0
MOVE.W InsNum,D1
LSL.W #2,D1
LEA (A0,D1.W),A0
MOVE.L DiskDataPtr,(A0)
MOVE.L (SP)+,124(A0)
RTS
FreeSample
LEA SamplePtrs,A0
MOVE.W InsNum,D0
BEQ.W Return2
LSL.W #2,D0
LEA (A0,D0.W),A0
MOVE.L (A0),D1
BEQ.W Return2
CLR.L (A0)
MOVE.L 124(A0),D0
CLR.L 124(A0)
MOVE.L D1,A1
JSR PTFreeMem
RTS
NotSampleNull
LEA NotSample0Text(PC),A0
BSR.W ShowStatusText
BRA.W SetErrorPtrCol
NotSample0Text dc.b 'not sample 0 !',0
EVEN
;----
xxDeleteSongGadg JMP DeleteSongGadg
DeleteSong
LEA DeleteSongText,A0
BSR.W AreYouSure
BNE.B xxDeleteSongGadg
LEA DeletingSongText,A0
BSR.W ShowStatusText
LEA SongsPath2,A0
JSR CopyPath
LEA DirInputName,A0
MOVEQ #DirNameLength-1,D0
dsloop MOVE.B (A0)+,(A1)+
DBRA D0,dsloop
MOVE.W #1,Action
Delete3 MOVE.L #FileName,FileNamePtr
MOVE.L DOSBase,A6
MOVE.L FileNamePtr,D1
MOVE.L D1,A0
JSR _LVODeleteFile(A6)
BSR.W ClearFileNames
BSR.W ShowAllRight
BSR.W SetNormalPtrCol
BSR.W StorePtrCol
JMP DoAutoDir
DeleteModule
LEA DeleteModuleText,A0
BSR.W AreYouSure
BNE.B xxDeleteModuleGadg
LEA DeletingModuleText,A0
BSR.W ShowStatusText
LEA ModulesPath2,A0
JSR CopyPath
LEA DirInputName,A0
MOVEQ #DirNameLength-1,D0
dmdloop MOVE.B (A0)+,(A1)+
DBRA D0,dmdloop
MOVE.W #3,Action
BRA.B Delete3
xxDeleteModuleGadg JMP DeleteModuleGadg
DeleteSample
LEA DeleteSampleText,A0
BSR.W AreYouSure
BNE.B xxDeleteSampleGadg
LEA DeletingSampleText,A0
BSR.W ShowStatusText
LEA SamplePath2,A0
JSR CopyPath
LEA DirInputName,A0
MOVEQ #DirNameLength-1,D0
dsaloop MOVE.B (A0)+,(A1)+
DBRA D0,dsaloop
MOVE.W #5,Action
BRA.W Delete3
xxDeleteSampleGadg JMP DeleteSampleGadg
RenameFile
LEA RenamingFileText,A0
BSR.W ShowStatusText
LEA DirInputName,A0
LEA NewInputName,A1
MOVEQ #24-1,D0
rnfloop MOVE.B (A0)+,(A1)+
BNE.B rnfskip
SUBQ.L #1,A0
rnfskip DBRA D0,rnfloop
BSR.W StorePtrCol
BSR.W SetWaitPtrCol
LEA NewInputName,A6
MOVE.L A6,ShowTextPtr
MOVE.L A6,TextEndPtr
ADD.L #23,TextEndPtr
MOVE.W #24,TextLength
MOVE.W FileNameScrollPos+2(PC),D0
MULU.W #240,D0
MOVE.W #1888,A4
ADD.W D0,A4
BSR.W GetTextLine
TST.B NewInputName
BEQ.B rnfend
CMP.B #69,MixChar
BEQ.B rnfend
MOVE.L PathPtr,A0
JSR CopyPath
LEA NewInputName,A0
MOVEQ #24-1,D0
rnfloop2 MOVE.B (A0)+,(A1)+
DBRA D0,rnfloop2
LEA FileName,A0
LEA NewFileName,A1
rnfloop3 MOVE.B (A0)+,(A1)+
BNE.B rnfloop3
MOVE.L PathPtr,A0
JSR CopyPath
LEA DirInputName,A0
MOVEQ #DirNameLength-1,D0
rnfloop4
MOVE.B (A0)+,(A1)+
DBRA D0,rnfloop4
MOVE.L #FileName,D1
MOVE.L #NewFileName,D2
MOVE.L DOSBase,A6
JSR _LVORename(A6)
rnfend BSR.W ClearFileNames
CLR.W Action
BSR.W RestorePtrCol
BSR.W ShowAllRight
JMP DoAutoDir
LoadSong CLR.W OutOfMemoryFlag
lbC00B62A MOVE.W #1,LoadInProgress
BSR.W DoClearSong
BSR.W ClrSampleInfo
LEA SongsPath2,A0
JSR CopyPath
LEA DirInputName,A0
MOVEQ #DirNameLength-1,D0
losoloop2
MOVE.B (A0)+,(A1)+
DBRA D0,losoloop2
MOVE.L SongDataPtr,DiskDataPtr
MOVE.L #FileName,FileNamePtr
MOVE.L SongAllocSize(PC),DiskDataLength
LEA LoadingSongText,A0
BSR.W ShowStatusText
BSR.W DoLoadData
BEQ.W lososkip3
MOVE.L SongDataPtr,A0
CMP.L #"PP20",(A0)
BEQ.W PowerPacked
CMP.L #"PX20",(A0)
BEQ.W PowerPacked
MOVE.L SongDataPtr,A0
CMP.L #"PAKK",(A0)
BNE.W lbC00B756
TST.W OutOfMemoryFlag
BNE.W lbC00B746
TST.B OneHundredPattFlag
BNE.W lbC00B75E
lbC00B6C2 MOVE.L SongDataPtr,D1
BEQ.B lbC00B6DC
MOVE.L D1,A1
MOVE.L SongAllocSize(PC),D0
JSR PTFreeMem
lbC00B6DC EOR.B #1,OneHundredPattFlag
MOVE.L #SONG_SIZE_64PAT,SongAllocSize
MOVE.L #63,MaxPattern
TST.B OneHundredPattFlag
BEQ.B lbC00B714
MOVE.L #SONG_SIZE_100PAT,SongAllocSize
MOVE.L #99,MaxPattern
lbC00B714 MOVE.L SongAllocSize(PC),D0
MOVE.L #MEMF_CLEAR!MEMF_PUBLIC,D1
JSR PTAllocMem
MOVE.L D0,SongDataPtr
BNE.B lbC00B742
BSR.W OutOfMemErr
MOVE.W #1,OutOfMemoryFlag
BRA.B lbC00B6C2
lbC00B742 BRA.W lbC00B62A
lbC00B746 BSR.W OutOfMemErr
BSR.W DoClearSong
BRA.W ClrSampleInfo
lbC00B756 CMP.L #"PACK",(A0)
BNE.B lbC00B796
lbC00B75E MOVE.L 4(A0),CrunchedSongLength
MOVE.L 8(A0),RealSongLength
MOVE.L SongDataPtr,D0
ADD.L SongAllocSize(PC),D0
SUB.L RealSongLength(PC),D0
MOVE.L D0,EndOfSongPtr
LEA DecrunchingText,A0
BSR.W ShowStatusText
BSR.W Decruncher
BSR.W ShowAllRight
lbC00B796
MOVE.L SongDataPtr,A0
CMP.L #'M!K!',sd_magicid(A0)
BNE.W lososkip
TST.W OutOfMemoryFlag
BNE.W lososkip2
TST.B OneHundredPattFlag
BNE.W lososkip2
lbC00B7BC MOVE.L SongDataPtr,D1
BEQ.B lbC00B7D6
MOVE.L D1,A1
MOVE.L SongAllocSize(PC),D0
JSR PTFreeMem
lbC00B7D6 EOR.B #1,OneHundredPattFlag
MOVE.L #SONG_SIZE_64PAT,SongAllocSize
MOVE.L #64-1,MaxPattern
TST.B OneHundredPattFlag
BEQ.B lbC00B80E
MOVE.L #SONG_SIZE_100PAT,SongAllocSize
MOVE.L #100-1,MaxPattern
lbC00B80E MOVE.L SongAllocSize(PC),D0
MOVE.L #MEMF_CLEAR!MEMF_PUBLIC,D1
JSR PTAllocMem
MOVE.L D0,SongDataPtr
BNE.B lbC00B83C
BSR.W OutOfMemErr
MOVE.W #1,OutOfMemoryFlag
BRA.B lbC00B7BC
lbC00B83C BRA.W lbC00B62A
lososkip
CMP.L #'M.K.',sd_magicid(A0)
BEQ.B lososkip2
BSR.W NotMKFormat
lososkip2
LEA LoadingSongText,A0
BSR.W ShowStatusText
BSR.W CheckAbort
BEQ.B lososkip3
TST.B AutoExitFlag
BEQ.B NoSongAutoExit
JSR ExitFromDir
NoSongAutoExit BSR.W ShowSongName
CLR.L PatternNumber
CLR.L CurrPos
BSR.W RedrawPattern
CLR.W ScrPattPos
BSR.W SetScrPatternPos
BSR.W SortDisks
LEA SampleSortList,A0
MOVEQ #31-1,D0
losoloop3
TST.B NosamplesFlag
BNE.B lososkip3
BSR.W CheckAbort
BEQ.B lososkip3
MOVE.W InsNum,TuneUp
JSR DoShowFreeMem
MOVE.L (A0)+,D1
MOVE.W D1,InsNum
MOVEM.L D0/D1/A0,-(SP)
BSR.W LoadPreset
BSR.W ShowSampleInfo
MOVEM.L (SP)+,D0/D1/A0
DBRA D0,losoloop3
lososkip3
TST.B OneHundredPattFlag
BNE.B lososkip5
LEA NoteDataClippedText(PC),A0
BSR.W ShowStatusText
BSR.W WaitALittle
MOVE.L SongDataPtr,A0
LEA sd_pattpos(A0),A0
MOVEQ #0,D0
MOVE.B -1(A0),D0
MOVEQ #$3F,D3
losoloop4 CMP.B (A0)+,D3
BHI.B lososkip4
MOVE.B D3,-1(A0)
lososkip4
DBRA D0,losoloop4
lososkip5
MOVE.W #1,InsNum
MOVE.L #6,CurrSpeed
CLR.W LoadInProgress
BSR.W ShowAllRight
BSR.W SetNormalPtrCol
JSR DoShowFreeMem
BSR.W CheckInstrLengths
BSR.W ShowSampleInfo
JMP RedrawSample
SortDisks
MOVEM.L D0-D4/A0/A1,-(SP)
MOVE.L SongDataPtr,A0
LEA 23(A0),A0
LEA SampleSortList,A1
MOVEQ #1,D0
losoloop5
MOVE.B (A0)+,(A1)+ ; ST-(0)1
MOVE.B (A0),(A1)+ ; ST-0(1)
MOVE.W D0,(A1)+ ; insnum
LEA 29(A0),A0
ADDQ.L #1,D0
CMP.L #32,D0
BLO.B losoloop5
losoloop6
CLR.W MoreInstrFlag
LEA SampleSortList,A0
MOVEQ #30-1,D2
losoloop7
MOVE.W (A0),D0
MOVE.W 4(A0),D1
CMP.W D0,D1 ; if next disk greater
BHS.B loso2_2
MOVE.W #1,MoreInstrFlag
MOVE.L (A0),D3 ; swap disks
MOVE.L 4(A0),D4
MOVE.L D4,(A0)
MOVE.L D3,4(A0)
loso2_2 ADDQ #4,A0
DBRA D2,losoloop7
TST.W MoreInstrFlag
BNE.B losoloop6
LEA SampleSortList,A0
MOVEQ #31-1,D0
losoloop8
CLR.W (A0)
ADDQ #4,A0
DBRA D0,losoloop8
MOVEM.L (SP)+,D0-D4/A0/A1
RTS
NotMKFormat
LEA Loadas31Text(PC),A0
BSR.W AreYouSure
BEQ.B putmk
MOVE.L SongDataPtr,A0 ; convert 15 samples to M.K. 31 samples format
LEA 466(A0),A1
ADD.L #66006,A0
makloop MOVE.L (A0),484(A0)
CLR.L (A0)
SUBQ.L #4,A0
CMP.L A0,A1
BNE.B makloop
MOVE.L SongDataPtr,A0
LEA sd_magicid(A0),A1
LEA sd_numofpatt(A0),A0
makloop2
MOVE.W 4(A0),(A0)+
CMP.L A0,A1
BNE.B makloop2
MOVE.L #'M.K.',(A0) ; M.K. again!
MOVEQ #0,D0
RTS
putmk
MOVE.L SongDataPtr,A0
MOVE.L #'M.K.',sd_magicid(A0)
MOVEQ #-1,D0
RTS
Loadas31Text dc.b "Load as 31 instr?",0
CheckInstrLengths
MOVE.L SongDataPtr,A0
LEA 20(A0),A0
MOVEQ #31-1,D1
xilloop MOVE.W 26(A0),D0
ADD.W 28(A0),D0
CMP.W 22(A0),D0
BLS.B xilSkip
MOVE.W 26(A0),D0
LSR.W #1,D0
MOVE.W D0,26(A0)
xilSkip
; --PT2.3D bug fix: zero loop lens + beep fix
TST.W 28(A0)
BNE.B xilSkip2
MOVE.W #1,28(A0)
xilSkip2
; --END OF FIX-------------------------------
LEA 30(A0),A0
DBRA D1,xilloop
RTS
; Added new mouse code.
; PT2.3A added crude acceleration, which made the
; mouse very annoying during precise sliding.
CNOP 0,4
MouseX dc.w 0 ; do not change order
MouseY dc.w 0 ; do not change order
MouseXFrac dc.w 0
MouseYFrac dc.w 0
InpUnchain
MOVE.L A2,D0
BNE.B InpUnc2
MOVE.L (A1),A0
RTS
InpUnc2 MOVE.L (A1),(A2)
RTS
InpRawmouse
BSR.B InpUnchain
; ----------------------
TST.B DiskDriveBusy ; is floppy drive accessing?
BNE.B .next
; ----------------------
MOVEQ #15,D3 ; AND mask for frac
; ----------------------
MOVEQ #MOUSE_SPEED,D0
MULS.W 10(A1),D0
MOVE.W MouseX(PC),D1
LSL.W #4,D1
ADD.W MouseXFrac(PC),D1
ADD.W D1,D0
BPL.B .L0
MOVEQ #0,D0
.L0 CMP.W #319<<4,D0
BLE.B .L1
MOVE.W #319<<4,D0
.L1 MOVE.W D0,D1
AND.W D3,D1
MOVE.W D1,MouseXFrac
LSR.W #4,D0
SWAP D0
; ----------------------
MOVEQ #MOUSE_SPEED,D1
MULS.W 12(A1),D1
MOVE.W MouseY(PC),D2
LSL.W #4,D2
ADD.W MouseYFrac(PC),D2
ADD.W D2,D1
BPL.B .L2
MOVEQ #0,D1
.L2 CMP.W #255<<4,D1
BLE.B .L3
MOVE.W #255<<4,D1
.L3 MOVE.W D1,D2
AND.W D3,D2
MOVE.W D2,MouseYFrac
LSR.W #4,D1
MOVE.W D1,D0
; ----------------------
MOVE.L D0,MouseX ; writes to X and Y in one go
; ----------------------
.next JMP InpNext
CheckAbort
BTST #2,$DFF016 ; right mouse button
BNE.W Return2
MOVEM.L D0-D7/A0-A6,-(SP)
LEA AbortLoadingText,A0
BSR.W AreYouSure
BNE.B chabno
MOVEM.L (SP)+,D0-D7/A0-A6
MOVEQ #0,D7
RTS
chabno
MOVEM.L (SP)+,D0-D7/A0-A6
MOVEQ #-1,D7
RTS
StopIt
BSR.B DoStopIt
CLR.W $DFF0A8 ; clear voice #1 volume
CLR.W $DFF0B8 ; clear voice #2 volume
CLR.W $DFF0C8 ; clear voice #3 volume
CLR.W $DFF0D8 ; clear voice #4 volume
TurnOffVoices
MOVE.L A0,-(SP)
MOVE.L A1,-(SP)
MOVE.W #$000F,$DFF096 ; turn off voice DMAs
CLR.B RawKeyCode
LEA ScopeInfo,A0
LEA BlankSample,A1
MOVE.L A1,ns_sampleptr+(ScopeInfoSize*0)(A0)
MOVE.L A1,ns_sampleptr+(ScopeInfoSize*1)(A0)
MOVE.L A1,ns_sampleptr+(ScopeInfoSize*2)(A0)
MOVE.L A1,ns_sampleptr+(ScopeInfoSize*3)(A0)
MOVE.L (SP)+,A1
MOVE.L (SP)+,A0
RTS
DoStopIt
TST.W TempPPFileFlag
BNE.B dsiskip
BSR.W SetNormalPtrCol
dsiskip
CLR.L EditMode
CLR.L RunMode
CLR.B PattDelayTime
CLR.B PattDelayTime2
BRA.W RestoreEffects2
UsePreset
BSR.W StorePtrCol
TST.L PLSTmem
BEQ.B upend
TST.W InsNum
BEQ.B upend
CLR.B RawKeyCode
MOVE.W CurrentPreset,D0
SUBQ.W #1,D0
MULU.W #30,D0
MOVE.L PLSTmem,A0
ADD.L D0,A0
MOVE.W InsNum,D0
MULU.W #30,D0
MOVE.L SongDataPtr,A1
LEA -10(A1,D0.W),A1
MOVE.L A1,A2
MOVEQ #30-1,D0
uploop MOVE.B (A0)+,(A1)+
DBRA D0,uploop
MOVE.L (A2),D0
AND.L #$DFDFFFFF,D0
CMP.L #$53540000,D0 ;ST__
BNE.B upok
CLR.W (A2)
CLR.L 22(A2)
MOVE.L #$00000001,26(A2)
upok BSR.W LoadPreset
upend BSR.W ShowSampleInfo
BRA.W RestorePtrCol
;---- Edit ----
Edit TST.W SamScrEnable
BNE.W Return2
BSR.W StopIt
CLR.B RawKeyCode
BSR.W SetEditPtrCol
BSR.W SetScrPatternPos
MOVE.L #'edit',EditMode
BRA.W WaitForButtonUp
;---- Edit Op. ----
DoEditOp
CLR.B RawKeyCode
CMP.W #1,CurrScreen
BNE.W Return2
TST.B EdEnable
BEQ.B EditOp
ADDQ.B #1,EdScreen
CMP.B #4,EdScreen
BLO.B EditOp
MOVE.B #1,EdScreen
EditOp BSR.W WaitForButtonUp
ST EdEnable
ST DisableAnalyzer
JSR ClearAnalyzerColors
BSR.W ClearRightArea
BRA.B DrawEditMenu
EdEnable dc.b 0
EdScreen dc.b 1
EVEN
DrawEditMenu
CMP.B #1,EdScreen
BNE.B demskip
MOVE.L #EditOpText1,ShowTextPtr
LEA Edit1Data,A0
MOVE.L #Edit1Size,D0
BRA.B demit
demskip
CMP.B #2,EdScreen
BNE.B demskip2
MOVE.L #EditOpText2,ShowTextPtr
LEA Edit2Data,A0
MOVE.L #Edit2Size,D0
BRA.B demit
demskip2
CMP.B #3,EdScreen
BNE.B demskip3
MOVE.L #EditOpText3,ShowTextPtr
LEA Edit3Data,A0
MOVE.L #Edit3Size,D0
BRA.B demit
demskip3
CMP.B #4,EdScreen
BNE.W Return2
MOVE.L #EditOpText4,ShowTextPtr
LEA Edit4Data,A0
MOVE.L #Edit4Size,D0
demit BSR.W Decompact
BEQ.W ExitEditOp
LEA SpectrumAnaPos,A0
MOVEQ #55-1,D0
demloop1
MOVEQ #25-1,D1
demloop2
MOVE.B 1430(A1),10240(A0)
MOVE.B (A1)+,(A0)+
DBRA D1,demloop2
LEA 15(A0),A0
ADDQ #1,A1
DBRA D0,demloop1
BSR.W FreeDecompMem
MOVE.W #1936,TextOffset
MOVE.W #22,TextLength
BSR.W ShowText
CMP.B #1,EdScreen
BEQ.W ShowSampleAll
CMP.B #2,EdScreen
BNE.B demskip4
BSR.W ShowTrackPatt
BSR.W ShowFrom
BSR.W ShowTo
BSR.W ShowRecordMode
BSR.W ShowQuantize
BSR.W ShowMetronome
BRA.W ShowMultiMode
demskip4
CMP.B #3,EdScreen
BNE.B demskip5
BSR.W ShowHalfClip
BSR.W ShowPos
BSR.W ShowMod
BRA.W ShowVol
demskip5
CMP.B #4,EdScreen
BNE.W Return2
BSR.W ShowNewOld
BSR.W ShowChordLength
BRA.W DisplayChordNotes
EditOpText1 dc.b ' track pattern '
EditOpText2 dc.b ' record samples '
EditOpText3 dc.b ' sample editor '
EditOpText4 dc.b ' sample chord editor '
EVEN
CheckEditOpGadgs
MOVE.W PattCurPos,D0
BSR.B GetPositionPtr
MOVE.W MouseX2,D0
MOVE.W MouseY2,D1
CMP.W #306,D0
BHS.B CheckEdSwap
CMP.B #1,EdScreen
BEQ.W CheckEdGadg1
CMP.B #2,EdScreen
BEQ.W CheckEdGadg2
CMP.B #3,EdScreen
BEQ.W CheckEdGadg3
CMP.B #4,EdScreen
BEQ.W CheckEdGadg4
RTS
GetPositionPtr
MOVE.L SongDataPtr,A0
LEA sd_patterndata(A0),A0
MOVE.L PatternNumber,D2
LSL.L #8,D2
LSL.L #2,D2
ADD.L D2,A0
MOVEQ #0,D2
MOVE.B D0,D2
DIVU.W #6,D2
LSL.W #2,D2
ADD.W D2,A0
RTS
CheckEdSwap
CMP.W #55,D1
BLS.W Return2
MOVEQ #1,D2
CMP.W #66,D1
BLS.B SetEditOpScreen
MOVEQ #2,D2
CMP.W #77,D1
BLS.B SetEditOpScreen
MOVEQ #3,D2
CMP.W #88,D1
BLS.B SetEditOpScreen
CMP.W #99,D1
BLS.B ExitEditOp
RTS
SetEditOpScreen
MOVE.B D2,EdScreen
BRA.W EditOp
ExitEditOp
SF EdEnable
CLR.B RawKeyCode
BRA.W DisplayMainScreen
CheckEdGadg1
CMP.W #55,D1
BLS.W ToggleSampleAll
CMP.W #66,D1
BLS.W NoteUp
CMP.W #77,D1
BLS.W NoteDown
CMP.W #88,D1
BLS.W OctaveUp
CMP.W #99,D1
BLS.W OctaveDown
RTS
CheckEdGadg2
CMP.W #55,D1
BLS.W ToggleTrackPatt
CMP.W #212,D0
BLS.B ceg2left
CMP.W #66,D1
BLS.W DeleteOrKill
CMP.W #77,D1
BLS.W ExchangeOrCopy
CMP.W #88,D1
BLS.W SetSampleFrom
CMP.W #99,D1
BLS.W SetSampleTo
RTS
ceg2left
CMP.W #66,D1
BLS.W ToggleRecordMode
CMP.W #77,D1
BLS.W SetQuantize
CMP.W #88,D1
BLS.W SetMetronome
CMP.W #99,D1
BLS.W ToggleMultiMode
RTS
CheckEdGadg3
MOVE.L SongDataPtr,A5
LEA -10(A5),A5
MOVE.W InsNum,D2
BNE.B ceg3skip
MOVE.W LastInsNum,D2
ceg3skip
MULU.W #30,D2
ADD.L D2,A5
CMP.W #55,D1
BLS.W ToggleHalfClip
CMP.W #212,D0
BLS.B ceg3mid
CMP.W #66,D1
BLS.W SetSamplePos
CMP.W #77,D1
BLS.W SetModSpeed
CMP.W #88,D1
BLS.W CutBeg
CMP.W #99,D1
BLS.W ChangeVolume
RTS
ceg3mid CMP.W #165,D0
BLS.B ceg3left
CMP.W #66,D1
BLS.W Echo
CMP.W #77,D1
BLS.W Filter
CMP.W #88,D1
BLS.W Backwards
CMP.W #99,D1
BLS.W DownSample
RTS
ceg3left
CMP.W #66,D1
BLS.W Mix
CMP.W #77,D1
BLS.W Boost
CMP.W #88,D1
BLS.W XFade
CMP.W #99,D1
BLS.W Upsample
RTS
ToggleSampleAll
BSR.W WaitForButtonUp
EOR.B #1,SampleAllFlag
ShowSampleAll
LEA BitplaneData+1838,A1
LEA S_BoxData,A2
TST.B SampleAllFlag
BEQ.B xrtdoit
LEA A_BoxData,A2
xrtdoit JMP rtdoit
OctaveUp
MOVE.W #24,NoteShift
BRA.B nup2
NoteUp MOVE.W #2,NoteShift
nup2 BSR.W SaveUndo
CMP.W #212,D0
BLS.B nup3
MOVEQ #0,D0
BSR.W GetPositionPtr
BSR.B SampleNoteUp
MOVEQ #6,D0
BSR.W GetPositionPtr
BSR.B SampleNoteUp
MOVEQ #12,D0
BSR.W GetPositionPtr
BSR.B SampleNoteUp
MOVEQ #18,D0
BSR.W GetPositionPtr
nup3 BSR.B SampleNoteUp
BRA.W RedrawPattern
SampleNoteUp
MOVEQ #63,D6
MOVE.L A0,A3
MOVE.W InsNum,D3
TST.B SampleAllFlag
BEQ.B sanulo2
MOVEQ #0,D3
sanulo2 MOVE.L D6,D0
MOVE.L A3,A0
sanuloop
MOVE.B 2(A0),D1
LSR.B #4,D1
MOVE.B (A0),D2
AND.B #$F0,D2
OR.B D2,D1
CMP.B D3,D1
BNE.B sanuskip
MOVE.W (A0),D1
MOVE.W D1,D2
AND.W #$F000,D2
AND.W #$0FFF,D1
BEQ.B sanuskip
BSR.W CheckPeriod
BNE.B sanuskip
ADD.W NoteShift(PC),D5
CMP.W #$0048,D5
BLO.B sanuok
TST.B TransDelFlag
BEQ.B sanuskip
AND.L #$00000FFF,(A0)
BRA.B sanuskip
sanuok MOVE.W (A2,D5.W),D1
OR.W D2,D1
MOVE.W D1,(A0)
sanuskip
LEA 16(A0),A0
DBRA D0,sanuloop
TST.B SampleAllFlag
BEQ.W Return2
ADDQ.W #1,D3
CMP.W #32,D3
BLO.B sanulo2
RTS
OctaveDown
MOVE.W #24,NoteShift
BRA.B ndown2
NoteDown
MOVE.W #2,NoteShift
ndown2 BSR.W SaveUndo
CMP.W #212,D0
BLS.B ndown3
MOVEQ #0,D0
BSR.W GetPositionPtr
BSR.B SampleNoteDown
MOVEQ #6,D0
BSR.W GetPositionPtr
BSR.B SampleNoteDown
MOVEQ #12,D0
BSR.W GetPositionPtr
BSR.B SampleNoteDown
MOVEQ #18,D0
BSR.W GetPositionPtr
ndown3 BSR.B SampleNoteDown
BRA.W RedrawPattern
SampleNoteDown
MOVEQ #64-1,D6
MOVE.L A0,A3
MOVE.W InsNum,D3
TST.B SampleAllFlag
BEQ.B sandlo2
MOVEQ #0,D3
sandlo2 MOVE.W D6,D0
MOVE.L A3,A0
sandloop
MOVE.B 2(A0),D1
LSR.B #4,D1
MOVE.B (A0),D2
AND.B #$F0,D2
OR.B D2,D1
CMP.B D1,D3
BNE.B sandskip
MOVE.W (A0),D1
MOVE.W D1,D2
AND.W #$F000,D2
AND.W #$0FFF,D1
BEQ.B sandskip
BSR.B CheckPeriod
BNE.B sandskip
SUB.W NoteShift(PC),D5
BPL.B sandok
TST.B TransDelFlag
BEQ.B sandskip
AND.L #$00000FFF,(A0)
BRA.B sandskip
sandok MOVE.W (A2,D5.W),D1
OR.W D2,D1
MOVE.W D1,(A0)
sandskip
LEA 16(A0),A0
DBRA D0,sandloop
TST.B SampleAllFlag
BEQ.W Return2
ADDQ.W #1,D3
CMP.W #$20,D3
BLO.B sandlo2
RTS
NoteShift dc.w 0
CheckPeriod
LEA PeriodTable,A2
MOVEQ #-2,D5
chpeloop
ADDQ.L #2,D5
MOVE.W (A2,D5.W),D4
BEQ.B PeriodNotOk
CMP.W D4,D1
BEQ.B PeriodOk
BRA.B chpeloop
PeriodOk
MOVEQ #0,D4
RTS
PeriodNotOk
MOVEQ #-1,D4
RTS
ToggleTrackPatt
BSR.W WaitForButtonUp
ADDQ.B #1,TrackPattFlag
CMP.B #3,TrackPattFlag
BLO.B ShowTrackPatt
CLR.B TrackPattFlag
ShowTrackPatt
LEA BitplaneData+1838,A1
LEA T_BoxData,A2
TST.B TrackPattFlag
BNE.B ttrpattskip
DoShowTrackpatt
JMP rtdoit
ttrpattskip
LEA P_BoxData,A2
CMP.B #1,TrackPattFlag
BEQ.B DoShowTrackpatt
LEA S_BoxData,A2
JMP rtdoit
KillInstrTrack
BSR.W SaveUndo
MOVE.W PattCurPos,D0
BSR.W GetPositionPtr
BRA.B dst2
DeleteOrKill
CMP.W #260,D0
BHS.B KillSample
BSR.W SaveUndo
TST.B TrackPattFlag
BEQ.B dst2
MOVEQ #0,D0
BSR.W GetPositionPtr
BSR.B dstdoit
MOVEQ #6,D0
BSR.W GetPositionPtr
BSR.B dstdoit
MOVEQ #12,D0
BSR.W GetPositionPtr
BSR.B dstdoit
MOVEQ #18,D0
BSR.W GetPositionPtr
dst2 BSR.B dstdoit
BRA.W RedrawPattern
dstdoit CLR.B RawKeyCode
MOVEQ #64-1,D0
MOVE.W InsNum,D3
BEQ.W NotSampleNull
ksloop MOVE.B 2(A0),D1
LSR.B #4,D1
MOVE.B (A0),D2
AND.B #$F0,D2
OR.B D2,D1
CMP.B D1,D3
BNE.B ksskip
CLR.L (A0)
ksskip LEA 16(A0),A0
DBRA D0,ksloop
RTS
KillSample
LEA KillSampleText,A0
JSR AreYouSure
BNE.W Return2
Destroy BSR.W StorePtrCol
MOVE.W InsNum,D0
BEQ.W ErrorRestoreCol
BSR.W TurnOffVoices
BSR.W FreeSample
MOVE.L SongDataPtr,A0
MOVE.W InsNum,D0
MULU.W #30,D0
LEA -10(A0),A0
ADD.L D0,A0
MOVE.L A0,A1
MOVEQ #30-1,D0
kisalop CLR.B (A0)+
DBRA D0,kisalop
MOVE.W #1,28(A1)
BSR.W ShowSampleInfo
BSR.W RedrawSample
BRA.W RestorePtrCol
ExchangeOrCopy
MOVEQ #-1,D4
CMP.W #260,D0
CMP.W #260,D0
BHS.B CopySampleTrack
ExchSampleTrack
CMP.B #2,TrackPattFlag
BEQ.W ExchSamples
MOVEQ #0,D4
BRA.B mstskip
CopySampleTrack
CMP.B #2,TrackPattFlag
BEQ.W CopySamples
mstskip TST.B TrackPattFlag
BEQ.B mst2
MOVEQ #0,D0
BSR.W GetPositionPtr
BSR.B mstdoit
MOVEQ #6,D0
BSR.W GetPositionPtr
BSR.B mstdoit
MOVEQ #12,D0
BSR.W GetPositionPtr
BSR.B mstdoit
MOVEQ #18,D0
BSR.W GetPositionPtr
mst2 BSR.B mstdoit
BRA.W RedrawPattern
mstdoit MOVEQ #64-1,D0
esloop MOVE.B 2(A0),D1
LSR.B #4,D1
MOVE.B (A0),D2
AND.B #$F0,D2
OR.B D2,D1
CMP.B SampleFrom(PC),D1
BNE.B esskip2
AND.L #$FFF0FFF,(A0)
MOVE.B SampleTo(PC),D2
MOVE.B D2,D3
AND.B #$F0,D2
OR.B D2,(A0)
LSL.B #4,D3
OR.B D3,2(A0)
BRA.B esskip3
esskip2 TST.B D4
BNE.B esskip3
CMP.B SampleTo(PC),D1
BNE.B esskip3
AND.L #$FFF0FFF,(A0)
MOVE.B SampleFrom(PC),D2
MOVE.B D2,D3
AND.B #$F0,D2
OR.B D2,(A0)
LSL.B #4,D3
OR.B D3,2(A0)
esskip3 LEA 16(A0),A0
DBRA D0,esloop
RTS
ExchSamples
BSR.W StorePtrCol
MOVEQ #0,D0
MOVE.B SampleFrom(PC),D0
BEQ.W ErrorRestoreCol
MOVEQ #0,D1
MOVE.B SampleTo(PC),D1
BEQ.W ErrorRestoreCol
MOVE.W D0,D2
MOVE.W D1,D3
LEA SampleLengthAdd+2(PC),A2
ADD.W D2,D2
ADD.W D3,D3
LEA (A2,D2.W),A0
LEA (A2,D3.W),A1
MOVE.W (A0),D4
MOVE.W (A1),(A0)
MOVE.W D4,(A1)
LEA SongDataPtr,A2
ADD.W D2,D2
ADD.W D3,D3
LEA (A2,D2.W),A0
LEA (A2,D3.W),A1
MOVE.L (A0),D4
MOVE.L (A1),(A0)
MOVE.L D4,(A1)
MOVE.L 124(A0),D4
MOVE.L 124(A1),124(A0)
MOVE.L D4,124(A1)
SUBQ.W #1,D0
SUBQ.W #1,D1
MULU.W #30,D0
MULU.W #30,D1
MOVE.L SongDataPtr,A2
LEA sd_sampleinfo(A2),A2
LEA (A2,D0.W),A0
LEA (A2,D1.W),A1
MOVEQ #30-1,D0
exsalop MOVE.B (A0),D1
MOVE.B (A1),(A0)+
MOVE.B D1,(A1)+
DBRA D0,exsalop
BSR.W ShowSampleInfo
BSR.W RedrawSample
BRA.W RestorePtrCol
CopySamples
BSR.W StorePtrCol
MOVEQ #0,D0
MOVE.B SampleFrom(PC),D0
BEQ.W ErrorRestoreCol
MOVEQ #0,D1
MOVE.B SampleTo(PC),D1
BEQ.W ErrorRestoreCol
; --PT2.3D bug fix: fix crash when copying sample to itself
CMP.B D0,D1
BEQ.W ErrorRestoreCol
; ---------------------------------------------------------
LEA SongDataPtr,A2
LSL.W #2,D0
LSL.W #2,D1
LEA (A2,D0.W),A3
LEA (A2,D1.W),A4
MOVE.L (A3),D0
BEQ.W ErrorRestoreCol
MOVE.L 124(A3),D0
MOVEQ #MEMF_CHIP,D1
JSR PTAllocMem
TST.L D0
BEQ.W OutOfMemErr
MOVE.L D0,A5
MOVEQ #0,D0
MOVE.B SampleTo(PC),D0
MOVE.W D0,InsNum
BSR.W Destroy
MOVE.L A5,(A4)
MOVE.L 124(A3),D0
MOVE.L D0,124(A4)
MOVE.L (A3),A0
cosalp2 MOVE.B (A0)+,(A5)+
SUBQ.L #1,D0
BNE.B cosalp2
MOVEQ #0,D0
MOVEQ #0,D1
MOVE.B SampleFrom(PC),D0
MOVE.B SampleTo(PC),D1
MOVE.W D1,InsNum
MULU.W #30,D0
MULU.W #30,D1
MOVE.L SongDataPtr,A2
LEA -10(A2),A2
LEA (A2,D0.W),A0
LEA (A2,D1.W),A1
MOVEQ #30-1,D0
cosalop MOVE.B (A0)+,(A1)+
DBRA D0,cosalop
BSR.W ShowSampleInfo
BSR.W RedrawSample
BRA.W RestorePtrCol
SetSampleFrom
MOVE.W InsNum,D2
CMP.W #283,D0
BLS.B sesfskip
MOVE.B SampleFrom(PC),D2
CMP.W #294,D0
BLS.B sesfup
SUBQ.B #1,D2
BPL.B sesfskip
MOVEQ #0,D2
sesfskip
MOVE.B D2,SampleFrom
BSR.W Wait_4000
BRA.B ShowFrom
sesfup ADDQ.B #1,D2
CMP.B #$1F,D2
BLS.B sesfskip
MOVE.B #$1F,SampleFrom
ShowFrom
MOVE.W #$CC9,TextOffset
CLR.W WordNumber
MOVE.B SampleFrom(PC),WordNumber+1
BRA.W PrintHexByte
SetSampleTo
MOVE.W InsNum,D2
CMP.W #283,D0
BLS.B sestskip
MOVE.B SampleTo(PC),D2
CMP.W #294,D0
BLS.B sestup
SUBQ.B #1,D2
BPL.B sestskip
MOVEQ #0,D2
sestskip
MOVE.B D2,SampleTo
BSR.W Wait_4000
BRA.B ShowTo
sestup ADDQ.B #1,D2
CMP.B #$1F,D2
BLS.B sestskip
MOVE.B #$1F,SampleTo
ShowTo MOVE.W #3713,TextOffset
CLR.W WordNumber
MOVE.B SampleTo(PC),WordNumber+1
BRA.W PrintHexByte
SampleFrom dc.b 0
SampleTo dc.b 0
EVEN
ToggleRecordMode
JSR WaitForButtonUp
EOR.B #1,RecordMode
ShowRecordMode
MOVE.W #2382,D1
LEA PattText(PC),A0
TST.B RecordMode
BEQ.B srmskip
LEA SongText(PC),A0
srmskip MOVEQ #4,D0
BRA.W ShowText3
AbortDecFlag dc.w 0
AbortHexFlag dc.w 0
AbortStrFlag dc.w 0
PattText dc.b 'patt'
SongText dc.b 'song'
RecordMode dc.b 0
QuantizeValue dc.b 1
MetroSpeed dc.b 4
MetroChannel dc.b 0
MultiFlag dc.b 0
SampleAllFlag dc.b 0
TrackPattFlag dc.b 0
ChordUseOldSmpFlag dc.b 0
EVEN
GetDecByte
MOVE.W #1,AbortDecFlag
JSR StorePtrCol
JSR SetWaitPtrCol
BSR.W UpdateLineCurPos
BSR.W GetKey0_9
CMP.B #68,D1
BEQ.B gdbexit
MOVE.B D1,D0
MULU.W #10,D0
MOVE.B D0,GetDecTemp
BSR.W ShowOneDigit
ADDQ.W #8,LineCurX
BSR.W UpdateLineCurPos
BSR.W GetKey0_9
CMP.B #68,D1
BEQ.B gdbexit
ADD.B D1,GetDecTemp
CLR.W AbortDecFlag
gdbexit CLR.W LineCurX
MOVE.W #270,LineCurY
BSR.W UpdateLineCurPos
JSR RestorePtrCol
MOVE.B GetDecTemp,D0
RTS
SetQuantize
CLR.B RawKeyCode
MOVE.W #196,LineCurX
MOVE.W #75,LineCurY
MOVE.W #2824,TextOffset
BSR.W GetDecByte
TST.W AbortDecFlag
BNE.B ShowQuantize
CMP.B #63,D0
BLS.B tqskip
MOVE.B #63,D0
tqskip MOVE.B D0,QuantizeValue
ShowQuantize MOVE.W #2824,TextOffset
CLR.W WordNumber
MOVE.B QuantizeValue(PC),WordNumber+1
BRA.W Print2DecDigits
SetMetronome
CLR.B RawKeyCode
CMP.W #188,D0
BHS.B smchan
MOVE.W #3261,TextOffset
MOVE.W #172,LineCurX
MOVE.W #86,LineCurY
BSR.W GetDecByte
TST.W AbortDecFlag
BNE.B ShowMetronome
CMP.B #64,D0
BLS.B smexit
MOVE.B #64,D0
smexit MOVE.B D0,MetroSpeed
BRA.B ShowMetronome
smchan MOVE.W #3264,TextOffset
MOVE.W #196,LineCurX
MOVE.W #86,LineCurY
BSR.W GetDecByte
TST.W AbortDecFlag
BNE.B ShowMetronome
CMP.W #4,D0
BLS.B smexit2
MOVEQ #4,D0
smexit2 MOVE.B D0,MetroChannel
ShowMetronome MOVE.W #3261,TextOffset
CLR.W WordNumber
MOVE.B MetroSpeed(PC),WordNumber+1
BSR.W Print2DecDigits
MOVE.W #$CC0,TextOffset
CLR.W WordNumber
MOVE.B MetroChannel(PC),WordNumber+1
BRA.W Print2DecDigits
ToggleMultiMode
JSR WaitForButtonUp
CLR.B RawKeyCode
EOR.B #1,MultiFlag
ShowMultiMode
BSR.B Show_MS
CMP.W #1,CurrScreen
BNE.W Return3
CMP.B #2,EdScreen
BNE.W Return3
TST.B EdEnable
BEQ.W Return3
MOVE.W #3700,D1
LEA SingleText(PC),A0
TST.B MultiFlag
BEQ.B smmskip
LEA MultiText(PC),A0
smmskip MOVEQ #6,D0
BRA.W ShowText3
SingleText dc.b 'single'
MultiText dc.b ' multi'
EVEN
Show_MS CMP.W #4,CurrScreen
BEQ.W Return3
MOVE.B #' ',D3
TST.B MetroFlag
BEQ.B smsskp1
MOVE.B #'M',D3
smsskp1 MOVE.B #' ',D0
TST.B MultiFlag
BEQ.B smsskp2
MOVE.B #'M',D0
smsskp2 MOVE.B #' ',D1
TST.B SplitFlag
BEQ.B smsskp3
MOVE.B #'S',D1
smsskp3 MOVE.B D3,mstext
MOVE.B D0,mstext+2
MOVE.B D1,mstext+1
MOVE.W EditMoveAdd(PC),D2
ADD.B #48,D2
MOVE.B D2,mstext+3
MOVE.W #4120,D1
MOVEQ #4,D0
LEA mstext(PC),A0
BSR.W ShowText3
BRA.W ShowAutoInsert
mstext dc.b '____'
EVEN
;---- Edit Op. 3 ----
ToggleHalfClip
JSR WaitForButtonUp
EOR.B #1,HalfClipFlag
ShowHalfClip
LEA BitplaneData+1838,A1
LEA H_BoxData,A2
TST.B HalfClipFlag
BEQ.B DoShowHalfClip
LEA C_BoxData,A2
DoShowHalfClip JMP rtdoit
SetSamplePos
MOVE.L SamplePos(PC),D2
CMP.W #237,D0
BLS.W Return3
CMP.W #283,D0
BLS.W EnterSamplePos
CMP.W #294,D0
BLS.B shpoup
SUBQ.L #1,D2
BTST #2,$DFF016 ; right mouse button
BNE.B shposkip
SUB.L #15,D2
shposkip
BPL.B shposkip2
MOVEQ #0,D2
shposkip2
JSR GUIDelay
shposkip4
MOVE.L D2,SamplePos
BRA.B ShowPos
shpoup ADDQ.L #1,D2
BTST #2,$DFF016 ; right mouse button
BNE.B shposkip3
ADD.L #15,D2
shposkip3
MOVEQ #0,D3
MOVE.W 22(A5),D3
ADD.L D3,D3
CMP.L D3,D2
BLS.B shposkip2
MOVE.L D3,SamplePos
ShowPos
CMP.W #1,CurrScreen
BNE.W Return3
TST.B EdEnable
BEQ.W Return3
CMP.B #3,EdScreen
BNE.W Return3
MOVE.W #2390,TextOffset
MOVE.L SamplePos(PC),LongWordNumber
BRA.W Print5HexDigits
EnterSamplePos
CLR.B RawKeyCode
MOVEQ #0,D7
BTST #2,$DFF016 ; right mouse button
BNE.B espskip
BRA.B espskip2
espskip
MOVE.W #2390,TextOffset
BSR.W GetHexNybble
TST.W AbortHexFlag
BNE.B espskip3
LSL.L #8,D0
LSL.L #8,D0
OR.L D0,D7
MOVE.W #2391,TextOffset
BSR.W GetHexByte
TST.W AbortHexFlag
BNE.B espskip3
LSL.W #8,D0
OR.W D0,D7
MOVE.W #2393,TextOffset
BSR.W GetHexByte
TST.W AbortHexFlag
BNE.B espskip3
OR.B D0,D7
EXT.L D7
espskip2
MOVE.L D7,SamplePos
MOVEQ #0,D3
MOVE.W 22(A5),D3
ADD.L D3,D3
CMP.L D3,D7
BLS.B espskip3
MOVE.L D3,SamplePos
espskip3
BRA.W ShowPos
SetModSpeed
CMP.W #243,D0
BLS.W DoMod
CMP.W #283,D0
BLS.W semoRTS
MOVEQ #0,D2
MOVE.B ModSpeed(PC),D2
CMP.W #294,D0
BLS.B semoup
SUBQ.B #1,D2
CMP.B #127,D2
BNE.B semoskp
MOVE.B #128,D2
BRA.B semoskp6
semoskp
BTST #2,$DFF016 ; right mouse button
BNE.B semoskp2
MOVEQ #9-1,D0
semodown
SUBQ.B #1,D2
CMP.B #127,D2
BEQ.B semoskp2
DBRA D0,semodown
semoskp2
CMP.B #127,D2
BNE.B semoskp6
MOVE.B #128,D2
BRA.B semoskp6
semoup
ADDQ.B #1,D2
CMP.B #128,D2
BNE.B semoskp3
MOVEQ #127,D2
BRA.B semoskp6
semoskp3
BTST #2,$DFF016 ; right mouse button
BNE.B semoskp5
MOVEQ #9-1,D0
semoskp4
ADDQ.B #1,D2
CMP.B #128,D2
BEQ.B semoskp5
DBRA D0,semoskp4
semoskp5
CMP.B #128,D2
BNE.B semoskp6
MOVEQ #127,D2
semoskp6
MOVE.B D2,ModSpeed
BSR.W Wait_4000
ShowMod LEA PlusMinusText(PC),A0
MOVEQ #0,D6
MOVE.B ModSpeed(PC),D6
BPL.B semoskp7
NEG.B D6
ADDQ #1,A0
semoskp7 MOVEQ #1,D0
MOVE.W #2831,D1
BSR.W ShowText3
MOVE.W D6,WordNumber
BRA.W Print3DecDigits
semoRTS
MOVEQ #0,D2
BTST #2,$DFF016 ; right mouse button
BEQ.B semoskp6
RTS
PlusMinusText dc.b ' -'
EVEN
DoMod ; fixed in PT2.3E to be 128kB compatible
JSR WaitForButtonUp
JSR StorePtrCol
JSR SetWaitPtrCol
MOVEQ #0,D2
MOVE.W SampleInfo,D2
BEQ.W bwErrorRestoreCol
ADD.L D2,D2
;SUBQ.L #1,D2
MOVE.L si_pointer,D0
BEQ.W bwErrorRestoreCol
BSR.W AllocBuffer
MOVE.L D0,A2
MOVE.L D0,A3
MOVE.L A1,A4
ADD.L D2,A3
CLR.L ModOffset
CLR.L ModPos
dmoloop CMP.L A3,A2
BHS.B dmoskip
MOVE.B (A1),(A2)+
BSR.B UpdateMod
BRA.B dmoloop
dmoskip MOVE.L si_pointer,A1
CLR.W (A1)
BSR.W FreeBuffer
JSR RestorePtrCol
BRA.W DisplaySample
UpdateMod
MOVEQ #0,D0
MOVE.B ModSpeed(PC),D0
BEQ.B upmplus
EXT.W D0
EXT.L D0
MOVE.L ModPos(PC),D1
ADD.L D0,D1
MOVE.L D1,ModPos
ASR.L #8,D1
ASR.L #4,D1
MOVE.L D1,D3
AND.W #$1F,D1
LEA VibratoTable,A0
MOVEQ #0,D0
MOVE.B (A0,D1.W),D0
LSR.B #2,D0
MOVE.L ModOffset(PC),D1
BTST #5,D3
BEQ.B upmskip
SUB.L D0,D1
BRA.B upmskp2
upmskip ADD.L D0,D1
upmskp2 ADD.L #$800,D1
MOVE.L D1,ModOffset
ASR.L #8,D1
ASR.L #3,D1
BPL.B upmskp3
MOVEQ #0,D1
upmskp3 CMP.L D2,D1
BLO.B upmskp4
MOVE.L D2,D1
upmskp4 MOVE.L A4,A1
ADD.L D1,A1
RTS
upmplus ADDQ #1,A1
RTS
CutBeg
CMP.W #287,D0
BHI.W FadeDown
CMP.W #269,D0
BHI.B FadeUp
CMP.W #230,D0
BHI.W DrawEditOp4
; fixed in PT2.3E to be 128kB compatible
JSR WaitForButtonUp
JSR StorePtrCol
JSR SetWaitPtrCol
MOVEQ #0,D3
MOVE.W SampleInfo,D3
BEQ.W bwErrorRestoreCol
ADD.L D3,D3
SUBQ.L #1,D3
MOVE.L si_pointer,D0
BEQ.W bwErrorRestoreCol
MOVE.L D0,A1
MOVE.L D0,A2
MOVE.L D0,A3
ADD.L SamplePos(PC),A2
ADD.L D3,A3
cbeloop CMP.L A3,A2
BHS.B cbeskip
MOVE.B (A2),D0
CLR.B (A2)+
MOVE.B D0,(A1)+
BRA.B cbeloop
cbeskip MOVE.L si_pointer,A2
CLR.W (A2)
SUB.L A2,A1
MOVE.L A1,D0
LSR.L #1,D0
ADDQ.L #1,D0
AND.L #$FFFF,D0
MOVE.W D0,22(A5)
BSR.W ShowSampleInfo
JSR RestorePtrCol
BRA.W DisplaySample
; 128kB compatible and faster, by 8bitbubsy
FadeUp
JSR WaitForButtonUp
JSR StorePtrCol
JSR SetWaitPtrCol
TST.W SampleInfo
BEQ.W bwErrorRestoreCol
MOVE.L SamplePos(PC),D5
BEQ.W bwErrorRestoreCol
MOVE.L si_pointer,D0
BEQ.W bwErrorRestoreCol
MOVE.L D0,A0
; --------------------
MOVE.L #32768<<16,D0
MOVE.L D5,D1
JSR DIVU32
MOVE.L D0,D3 ; 16.16fp delta
; --------------------
MOVEQ #0,D2
MOVEQ #0,D4
; --------------------
fuloop MOVE.L D2,D1
SWAP D1
MOVE.B (A0),D0
EXT.W D0
MULS.W D1,D0
SWAP D0
ROL.L #1,D0
MOVE.B D0,(A0)+
ADD.L D3,D2
ADDQ.L #1,D4
CMP.L D5,D4
BLO.B fuloop
; --------------------
JSR RestorePtrCol
BRA.W DisplaySample
; 128kB compatible and faster, by 8bitbubsy
FadeDown
JSR WaitForButtonUp
JSR StorePtrCol
JSR SetWaitPtrCol
MOVEQ #0,D3
MOVE.W SampleInfo,D3
BEQ.W bwErrorRestoreCol
ADD.L D3,D3
SUBQ.L #1,D3 ;Length-1
MOVE.L SamplePos(PC),D5
CMP.L D3,D5
BHS.W bwErrorRestoreCol
MOVE.L D3,D4 ; Copy length to D4
SUB.L D5,D3 ; Length-pos
MOVE.L D3,D5 ; Copy offset to D2
MOVE.L si_pointer,D0
BEQ.W bwErrorRestoreCol
MOVE.L D0,A0
LEA (A0,D4.L),A0 ;Start at end of sample
MOVE.L D5,D3
; --------------------
MOVE.L #32768<<16,D0
MOVE.L D5,D1
JSR DIVU32
MOVE.L D0,D3 ; 16.16fp delta
; --------------------
MOVEQ #0,D2
MOVEQ #0,D4
; --------------------
fdloop MOVE.L D2,D1
SWAP D1
MOVE.B (A0),D0
EXT.W D0
MULS.W D1,D0
SWAP D0
ROL.L #1,D0
MOVE.B D0,(A0)
ADD.L D3,D2
ADDQ.L #1,D4
SUBQ.L #1,A0
CMP.L D5,D4
BLO.B fdloop
; --------------------
JSR RestorePtrCol
BRA.W DisplaySample
ChangeVolume
MOVE.W SampleVol(PC),D2
CMP.W #$F3,D0
BLS.W DoChangeVol
CMP.W #$11B,D0
BLS.B shvoskip4
CMP.W #$126,D0
BLS.B shvoup
SUBQ.W #1,D2
BTST #2,$DFF016 ; right mouse button
BNE.B shvoskip
SUB.W #9,D2
shvoskip
BPL.B shvoskip2
MOVEQ #0,D2
shvoskip2
MOVE.W D2,SampleVol
BSR.W Wait_4000
BRA.B ShowVol
shvoup ADDQ.L #1,D2
BTST #2,$DFF016 ; right mouse button
BNE.B shvoskip3
ADD.W #9,D2
shvoskip3
CMP.W #999,D2
BLS.B shvoskip2
MOVE.W #999,SampleVol
BSR.W Wait_4000
ShowVol MOVE.W #3711,TextOffset
MOVE.W SampleVol(PC),WordNumber
BSR.W Print3DecDigits
LEA PercentText(PC),A0
MOVE.W #1,TextLength
BRA.W ShowText2
shvoskip4
CLR.B RawKeyCode
MOVEQ #100,D0
BTST #2,$DFF016 ; right mouse button
BNE.B shvoskip5
BRA.B shvoskip6
shvoskip5
MOVEQ #0,D0
MOVE.W #252,LineCurX
MOVE.W #97,LineCurY
MOVE.W #3711,TextOffset
BSR.W GetDec3Dig
TST.W AbortDecFlag
BNE.B ShowVol
shvoskip6
MOVE.W D0,SampleVol
BRA.B ShowVol
PercentText dc.b '%',0
EVEN
; 128kB compatible and much faster, by 8bitbubsy.
dcvrts RTS
DoChangeVol
JSR WaitForButtonUp
CMP.W #100,SampleVol ; volume change needed (vol != 100)?
BEQ.B dcvrts ; nope, don't do anything
JSR StorePtrCol
JSR SetWaitPtrCol
MOVEQ #0,D3
MOVE.W SampleInfo,D3
BEQ.W bwErrorRestoreCol
ADD.L D3,D3
SUBQ.L #1,D3
MOVE.L si_pointer,D0
BEQ.W bwErrorRestoreCol
MOVE.L D0,A1
; 8bb:
; Instead of doing a full loop of MUL+ASR, let's precalc
; a 256 byte long conversion LUT instead. This is
; dramatically faster.
; create amp conversion LUT
MOVEQ #0,D0
MOVE.W SampleVol(PC),D0
MOVEQ #11,D6 ; max bits for 0..999 range
LSL.L D6,D0 ; rescale volume range (for DIV -> bitshift)
DIVU.W #100,D0 ; vol 0..999/100 --> 0..20459
LEA SmpConvLUT,A0
MOVEQ #127,D4 ; clip values
MOVEQ #-128,D5 ;
MOVEQ #0,D2
dcvll MOVE.B D2,D1
EXT.W D1
MULS.W D0,D1
SWAP D1
ROL.L #5,D1
CMP.W D4,D1
BGT.B dcvhi
CMP.W D5,D1
BLT.B dcvlo
MOVE.B D1,(A0)+
dcvnext ADDQ.B #1,D2
BCC.B dcvll
BRA.B dcvdone
dcvhi MOVE.B D4,(A0)+
BRA.B dcvnext
dcvlo MOVE.B D5,(A0)+
BRA.B dcvnext
dcvdone
; do actual volume change
LEA SmpConvLUT,A0
MOVEQ #0,D0
dcvloop MOVE.B (A1),D0
MOVE.B (A0,D0.W),(A1)+
SUBQ.L #1,D3
BPL.B dcvloop
; done!
MOVE.L si_pointer,A1
CLR.W (A1)
JSR RestorePtrCol
BRA.W DisplaySample
Mix
BTST #2,$DFF016 ; right mouse button
BEQ.W OldMix
JSR WaitForButtonUp
JSR StorePtrCol
JSR SetWaitPtrCol
MOVE.W #1,GetLineFlag
MOVE.W #4,MixCurPos
mixlopx BSR.W DisplayMix
BSR.W GetHexKey
TST.B D0
BNE.B mixnzro
CMP.B #68,MixChar
BEQ.W Mix2
CMP.B #69,MixChar
BEQ.W EndMix
BTST #2,$DFF016 ; right mouse button
BEQ.W EndMix
LEA MixText(PC),A0
LEA FastHexTable+1,A1
ADD.W D1,D1
MOVE.W MixCurPos(PC),D0
MOVE.B (A1,D1.W),(A0,D0.W)
MixMoveRight
MOVE.W MixCurPos(PC),D0
ADDQ.W #1,D0
CMP.W #6,D0
BEQ.B mmrp1
CMP.W #9,D0
BEQ.B mmrp2
CMP.W #15,D0
BHS.B mmrp3
mmrok MOVE.W D0,MixCurPos
BRA.B mixlopx
mmrp1 MOVEQ #7,D0
BRA.B mmrok
mmrp2 MOVEQ #13,D0
BRA.B mmrok
mmrp3 MOVEQ #14,D0
BRA.B mmrok
mixnzro CMP.B #1,D0
BEQ.B MixMoveRight
MixMoveLeft
MOVE.W MixCurPos(PC),D0
SUBQ.W #1,D0
CMP.W #4,D0
BLO.B mmlp1
CMP.W #6,D0
BEQ.B mmlp2
CMP.W #12,D0
BEQ.B mmlp3
BRA.B mmrok
mmlp1 MOVEQ #4,D0
BRA.B mmrok
mmlp2 MOVEQ #5,D0
BRA.B mmrok
mmlp3 MOVEQ #8,D0
BRA.B mmrok
DisplayMix
MOVE.W #53,LineCurY
MOVE.W MixCurPos(PC),D0
LSL.W #3,D0
ADD.W #132,D0
MOVE.W D0,LineCurX
BSR.W UpdateLineCurPos
LEA MixText(PC),A0
MOVE.W #1936,D1
MOVEQ #22,D0
BSR.W ShowText3
BSR.W Wait_4000
BSR.W Wait_4000
BRA.W Wait_4000
CNOP 0,4
FromPtr1 dc.l 0
FromPtr2 dc.l 0
ToPtr dc.l 0
MixPtr dc.l 0
MixLength dc.l 0
MixCurPos dc.w 0
ToSam dc.w 0
MixText dc.b 'mix 01+02 to 03 ',0
MixChar dc.b 0
EVEN
EndMix CLR.B RawKeyCode
BSR.B RestoreMix
JMP RestorePtrCol
RestoreMix
CLR.W GetLineFlag
MOVE.W #270,LineCurY
CLR.W LineCurX
BSR.W UpdateLineCurPos
LEA EditOpText3(PC),A0
MOVE.W #1936,D1
MOVEQ #22,D0
BRA.W ShowText3
; 128kB compatible and optimized by 8bitbubsy
Mix2
BSR.B RestoreMix
BSR.W TurnOffVoices
LEA SongDataPtr,A2
MOVEQ #0,D0
LEA MixText+4(PC),A0
BSR.W HexToInteger2
TST.W D0
BEQ.W SamOutOfRange
CMP.W #$1F,D0
BHI.W SamOutOfRange
LSL.W #2,D0
LEA (A2,D0.W),A3
MOVE.L A3,FromPtr1
MOVEQ #0,D0
LEA MixText+7(PC),A0
BSR.W HexToInteger2
TST.W D0
BEQ.W SamOutOfRange
CMP.W #$1F,D0
BHI.W SamOutOfRange
LSL.W #2,D0
LEA (A2,D0.W),A3
MOVE.L A3,FromPtr2
MOVEQ #0,D0
LEA MixText+13(PC),A0
BSR.W HexToInteger2
MOVE.W D0,ToSam
BEQ.W SamOutOfRange
CMP.W #$1F,D0
BHI.W SamOutOfRange
LSL.W #2,D0
LEA (A2,D0.W),A3
MOVE.L A3,ToPtr
MOVE.L FromPtr1(PC),A1
MOVE.L FromPtr2(PC),A2
MOVE.L 124(A1),D1
MOVE.L 124(A2),D2
CMP.L D1,D2
BLO.B mixnswp
EXG D1,D2
EXG A1,A2
mixnswp MOVE.L (A1),A1
MOVE.L (A2),A2
; A1/D1 = longest running (or same as A2/D2)
TST.L D1
BEQ.W SamEmptyError ; Both samples had length=0
MOVE.L D1,D0
AND.L #$1FFFE,D0
MOVE.L D0,MixLength
MOVE.L D1,-(SP)
MOVE.L #MEMF_CHIP,D1
JSR PTAllocMem
MOVE.L (SP)+,D1
MOVE.L D0,MixPtr
BEQ.W SamMemError ; No memory for new sample...
LEA mixingtext(PC),A0
BSR.W ShowStatusText
LEA (A1,D1.L),A4 ; A4 = end of A1
LEA (A2,D2.L),A5 ; A5 = end of A2
MOVE.L MixPtr(PC),A3
TST.B HalfClipFlag
BEQ.B mixhalf
MOVEQ #127,D2
MOVEQ #-128,D3
; clipped mixing
mixlop2 MOVE.B (A1)+,D0
CMP.L A5,A2 ; at end of smp2?
BHS.B .set ; yes, no mixing needed
EXT.W D0
MOVE.B (A2)+,D1
EXT.W D1
ADD.W D1,D0
CMP.W D2,D0
BGT.B .hi
CMP.W D3,D0
BLT.B .lo
.set MOVE.B D0,(A3)+
CMP.L A4,A1
BLO.B mixlop2
BRA.B mixdone
.hi MOVE.L D2,D0
BRA.B .set
.lo MOVE.L D3,D0
BRA.B .set
; halved mixing
mixhalf MOVE.B (A1)+,D0
EXT.W D0
CMP.L A5,A2 ; at end of smp2?
BHS.B .set ; yes, no mixing needed
MOVE.B (A2)+,D1
EXT.W D1
ADD.W D1,D0
.set ASR.W #1,D0
MOVE.B D0,(A3)+
CMP.L A4,A1
BLO.B mixhalf
mixdone
MOVE.W ToSam(PC),InsNum
BSR.W FreeSample
MOVE.L ToPtr(PC),A0
MOVE.L MixPtr(PC),A1
CLR.W (A1)
MOVE.L A1,(A0)
MOVE.L MixLength(PC),124(A0)
MOVE.L SongDataPtr,A0
MOVE.W ToSam(PC),D0
SUBQ.W #1,D0
MULU.W #30,D0
LEA sd_sampleinfo(A0,D0.W),A0
MOVE.L MixLength(PC),D0
LSR.L #1,D0
MOVE.W D0,22(A0)
MOVE.W #$0040,24(A0) ; finetune:$00 volume:$40
MOVE.L #$00000001,26(A0) ; repeat:$0000 replen:$0001
JSR RestorePtrCol
BSR.W ShowAllRight
BSR.W ShowSampleInfo
BSR.W DisplaySample
BRA.W RedrawSample
SamOutOfRange
LEA mixerrtext1(PC),A0
BSR.W ShowStatusText
JMP ErrorRestoreCol
SamEmptyError
LEA mixerrtext2(PC),A0
BSR.W ShowStatusText
JMP ErrorRestoreCol
SamMemError
LEA mixerrtext3(PC),A0
BSR.W ShowStatusText
JMP ErrorRestoreCol
OutOfMemErr
LEA mixerrtext3(PC),A0
BSR.W ShowStatusText
JSR SetErrorPtrCol
MOVEQ #0,D0
RTS
mixerrtext1 dc.b 'not range 01-1F !',0
mixerrtext2 dc.b 'empty samples !!!',0
mixerrtext3 dc.b 'out of memory !!!',0
mixingtext dc.b 'mixing samples...',0
EVEN
; 128kB compatible and optimized by 8bitbubsy
OldMix
MOVE.L SamplePos(PC),D6
BEQ.W bwErrorRestoreCol
MOVEQ #0,D2
MOVE.W SampleInfo,D2 ; 22(A0)
BEQ.W bwErrorRestoreCol
JSR StorePtrCol
JSR SetWaitPtrCol
ADD.L D2,D2
CMP.L D6,D2
BEQ.W bwErrorRestoreCol
MOVE.L si_pointer,D0
BEQ.W bwErrorRestoreCol
BSR.W AllocBuffer
MOVE.L D0,A2
; A1 = copy of sample
LEA (A2,D2.L),A3 ; A3 = end of original sample (A2)
ADD.L D6,A2 ; A2 = mix pos in original sample
CMP.L A3,A2
BHS.B omixdone
TST.B HalfClipFlag
BEQ.B omixhalf
MOVEQ #127,D2
MOVEQ #-128,D3
; clipped mixing
omixloop
MOVE.B (A2),D0
EXT.W D0
MOVE.B (A1)+,D1
EXT.W D1
ADD.W D1,D0
CMP.W D2,D0
BGT.B .hi
CMP.W D3,D0
BLT.B .lo
.set MOVE.B D0,(A2)+
CMP.L A3,A2
BLO.B omixloop
BRA.B omixdone
.hi MOVE.L D2,D0
BRA.B .set
.lo MOVE.L D3,D0
BRA.B .set
; halved mixing
omixhalf
MOVE.B (A2),D0
EXT.W D0
MOVE.B (A1)+,D1
EXT.W D1
ADD.W D1,D0
ASR.W #1,D0
MOVE.B D0,(A2)+
CMP.L A3,A2
BLO.B omixhalf
omixdone
MOVE.L si_pointer,A1
CLR.W (A1)
BSR.B FreeBuffer
JSR RestorePtrCol
JSR WaitForButtonUp
BRA.W DisplaySample
AllocBuffer ; fixed in PT2.3E to be 128kB compatible
MOVE.L D0,D7
MOVE.L D2,D0
MOVE.L D2,BufMemSize
MOVE.L #MEMF_PUBLIC,D1
JSR PTAllocMem
MOVE.L D0,BufMemPtr
BEQ.W OutOfMemErr
MOVE.L D7,A0
MOVE.L D0,A1
MOVE.L BufMemSize(PC),D0
SUBQ.L #1,D0
albloop MOVE.B (A0)+,(A1)+
SUBQ.L #1,D0
BPL.B albloop
MOVE.L BufMemPtr(PC),A1
MOVE.L D7,D0
RTS
FreeBuffer
MOVE.L BufMemPtr(PC),D0
BEQ.W Return3
MOVE.L D0,A1
MOVE.L BufMemSize(PC),D0
JSR PTFreeMem
CLR.L BufMemPtr
RTS
Echo ; fixed in PT2.3E to be 128kB compatible
MOVE.L SamplePos(PC),FlangePos
JSR WaitForButtonUp
JSR StorePtrCol
JSR SetWaitPtrCol
MOVEQ #0,D2
MOVE.W SampleInfo,D2 ; 22(A0)
BEQ.W bwErrorRestoreCol
ADD.L D2,D2
MOVE.L si_pointer,D0
BEQ.W bwErrorRestoreCol
MOVE.L D0,A1
MOVE.L D0,A2
MOVE.L D0,A3
MOVE.L D0,A4
ADD.L D2,A3
ADD.L FlangePos(PC),A2
CLR.L ModOffset
CLR.L ModPos
flaloop CMP.L A3,A2
BHS.B flaskip
MOVE.B (A2),D0
EXT.W D0
MOVE.B (A1),D1
EXT.W D1
ADD.W D1,D0
ASR.W #1,D0
MOVE.B D0,(A2)+
BSR.W UpdateMod
BRA.B flaloop
flaskip MOVE.L si_pointer,A1
CLR.W (A1)
JSR RestorePtrCol
TST.B HalfClipFlag
BEQ.W DisplaySample
MOVE.W SampleVol(PC),-(SP)
MOVE.W #200,SampleVol
BSR.W DoChangeVol
MOVE.W (SP)+,SampleVol
BRA.W DisplaySample
; 128kB compatible and optimized by 8bitbubsy
Filter
TST.W SampleInfo
BEQ.W bwErrorRestoreCol
CLR.B RawKeyCode
JSR WaitForButtonUp
JSR StorePtrCol
JSR SetWaitPtrCol
LEA FilteringText(PC),A0
BSR.W ShowStatusText
MOVEQ #0,D3
MOVE.W SampleInfo,D3
BEQ.B .end
ADD.L D3,D3
SUBQ.L #1,D3
MOVE.L si_pointer,D0
BEQ.B .end
MOVE.L D0,A1
MOVE.L MarkStartOfs(PC),D0
BMI.B .loop
MOVE.L MarkEndOfs(PC),D1
SUB.L D0,D1
BEQ.B .loop
MOVE.L D1,D3
MOVE.L SamStart(PC),A1
ADD.L D0,A1
; ------------------------
.loop MOVE.B (A1),D0
EXT.W D0
MOVE.B 1(A1),D1
EXT.W D1
ADD.W D1,D0
ASR.W #1,D0
MOVE.B D0,(A1)+
SUBQ.L #1,D3
BPL.B .loop
; ------------------------
MOVE.L si_pointer,A1
CLR.W (A1)
.end BSR.W ShowAllRight
JSR RestorePtrCol
BRA.W DisplaySample
; 128kB compatible, and very lightly optimized
Boost
MOVE.W SampleInfo,D3
BEQ.W bwErrorRestoreCol
CLR.B RawKeyCode
JSR WaitForButtonUp
JSR StorePtrCol
JSR SetWaitPtrCol
LEA BoostingText(PC),A0
BSR.W ShowStatusText
MOVEQ #0,D3
MOVE.W SampleInfo,D3
BEQ.B .end
ADD.L D3,D3
SUBQ.L #1,D3
MOVE.L si_pointer,D0
BEQ.B .end
MOVE.L D0,A1
MOVE.L MarkStartOfs(PC),D0
BMI.B .L0
MOVE.L MarkEndOfs(PC),D1
SUB.L D0,D1
BEQ.B .L0
MOVE.L D1,D3
MOVE.L SamStart(PC),A1
ADD.L D0,A1
.L0 ; ------------------------
MOVEQ #0,D0
MOVEQ #127,D4
MOVEQ #-128,D5
; ------------------------
.loop MOVE.B (A1),D1
EXT.W D1
MOVE.W D1,D2
SUB.W D0,D1
MOVE.W D2,D0
TST.W D1
BMI.B .neg
ASR.W #2,D1
ADD.W D1,D2
BRA .L1
.neg NEG.W D1
ASR.W #2,D1
SUB.W D1,D2
.L1 CMP.W D4,D2
BGT.B .hi
CMP.W D5,D2
BLT.B .lo
.set MOVE.B D2,(A1)+
SUBQ.L #1,D3
BPL.B .loop
; ------------------------
MOVE.L si_pointer,A1
CLR.W (A1)
.end BSR.W ShowAllRight
JSR RestorePtrCol
BRA.W DisplaySample
; ------------------------
.hi MOVE.L D4,D2
BRA.B .set
.lo MOVE.L D5,D2
BRA.B .set
FilteringText dc.b 'filtering',0
BoostingText dc.b 'boosting',0
EVEN
; fixed in PT2.3E to be 128kB compatible
XFade
JSR WaitForButtonUp
JSR StorePtrCol
JSR SetWaitPtrCol
MOVEQ #0,D2
MOVE.W SampleInfo,D2 ; 22(A0)
BEQ.B xfErrorRestoreCol
ADD.L D2,D2
MOVE.L si_pointer,D0
BEQ.B xfErrorRestoreCol
MOVE.L D0,A1
MOVE.L D0,A2
ADD.L D2,A2
TST.B HalfClipFlag
BEQ.B xfahalf
MOVEQ #127,D2
MOVEQ #-127,D3
; clipped mixing
xfaloop MOVE.B (A1),D0
EXT.W D0
MOVE.B -(A2),D1
EXT.W D1
ADD.W D1,D0
CMP.W D2,D0
BGT.B .hi
CMP.W D3,D0
BLT.B .lo
.set MOVE.B D0,(A1)+
MOVE.B D0,(A2)
CMP.L A2,A1
BLO.B xfaloop
BRA.B xfadone
.hi MOVE.L D2,D0
BRA.B .set
.lo MOVE.L D3,D0
BRA.B .set
; halved mixing
xfahalf MOVE.B (A1),D0
EXT.W D0
MOVE.B -(A2),D1
EXT.W D1
ADD.W D1,D0
ASR.W #1,D0
MOVE.B D0,(A1)+
MOVE.B D0,(A2)
CMP.L A2,A1
BLO.B xfahalf
xfadone
MOVE.L si_pointer,A1
CLR.W (A1)
JSR RestorePtrCol
BRA.W DisplaySample
xfErrorRestoreCol JMP ErrorRestoreCol
Backwards
JSR WaitForButtonUp
JSR StorePtrCol
JSR SetWaitPtrCol
MOVEQ #0,D2
MOVE.W 22(A5),D2
BEQ.B bwErrorRestoreCol
MOVE.L si_pointer,D0
BEQ.B bwErrorRestoreCol
MOVE.L D0,A1
MOVE.L D0,A2
ADD.L D2,D2
ADD.L D2,A2
MOVE.L MarkStartOfs(PC),D0
BMI.B bacloop
MOVE.L MarkEndOfs(PC),D1
SUB.L D0,D1
BEQ.B bacloop
MOVE.L SamStart(PC),A1
ADD.L D0,A1
MOVE.L A1,A2
ADD.L D1,A2
bacloop MOVE.B (A1),D0
MOVE.B -(A2),(A1)+
MOVE.B D0,(A2)
CMP.L A2,A1
BLO.B bacloop
MOVE.L si_pointer,A1
CLR.W (A1)
JSR RestorePtrCol
BRA.W DisplaySample
bwErrorRestoreCol JMP ErrorRestoreCol
Upsample
JSR WaitForButtonUp
LEA UpsampleText(PC),A0
JSR AreYouSure
BNE.W Return3
BSR.W TurnOffVoices
JSR StorePtrCol
JSR SetWaitPtrCol
MOVE.W InsNum,D0
LSL.W #2,D0
LEA SongDataPtr,A0
LEA (A0,D0.W),A0
MOVE.L 124(A0),D3
CMP.L #2,D3
BLS.B bwErrorRestoreCol
MOVE.L (A0),D0
BEQ.B bwErrorRestoreCol
MOVE.L D0,A2
MOVE.L D0,A4
MOVE.L D3,D4
LSR.L #1,D3
BCLR #0,D3 ; even'ify
MOVE.L D3,D0
MOVEQ #MEMF_CHIP,D1
JSR PTAllocMem
TST.L D0
BEQ.B upserro
MOVE.L D0,A3
MOVE.L D0,D2
MOVE.L D3,D5
SUBQ.L #1,D3
upsloop MOVE.B (A2)+,(A3)+
ADDQ #1,A2
DBRA D3,upsloop
MOVE.L A4,A1
MOVE.L D4,D0
JSR PTFreeMem
MOVE.W InsNum,D0
LSL.W #2,D0
LEA SongDataPtr,A0
LEA (A0,D0.W),A0
MOVE.L D2,(A0)
MOVE.L D5,124(A0)
MOVE.L D2,A0
CLR.W (A0)
MOVE.W 22(A5),D0
LSR.W #1,D0
MOVE.W D0,22(A5)
MOVE.W 26(A5),D0
LSR.W #1,D0
MOVE.W D0,26(A5)
MOVE.W 28(A5),D0
LSR.W #1,D0
BNE.B upsskip2
MOVEQ #1,D0
upsskip2
MOVE.W D0,28(A5)
BSR.W ShowSampleInfo
JSR WaitForButtonUp
JSR RestorePtrCol
BRA.W RedrawSample
upserro JSR RestorePtrCol
BRA.W OutOfMemErr
DownSample ; fixed in PT2.3E to be 128kB compatible
JSR WaitForButtonUp
TST.W InsNum
BEQ.W NotSampleNull
LEA DownSampleText(PC),A0
JSR AreYouSure
BNE.W Return3
BSR.W TurnOffVoices
JSR StorePtrCol
JSR SetWaitPtrCol
MOVE.L si_pointer,D0
BEQ.W dsErrorRestoreCol
MOVEQ #0,D0
MOVE.W SampleInfo,D0
BEQ.W dsErrorRestoreCol
ADD.L D0,D0 ; real size
ADD.L D0,D0 ; multiply by two to get new size
CMP.L #$1FFFE,D0
BLS.B dnsskip
MOVE.L #$1FFFE,D0
dnsskip MOVE.L D0,BufMemSize
MOVEQ #MEMF_CHIP,D1
JSR PTAllocMem
MOVE.L D0,BufMemPtr
BEQ.W SamMemError
MOVE.L si_pointer,A1
MOVE.L D0,A2
MOVE.L BufMemSize(PC),D3
LSR.L #1,D3
SUBQ.L #1,D3
dnsloop MOVE.B (A1)+,D0
MOVE.B D0,(A2)+
MOVE.B D0,(A2)+
SUBQ.L #1,D3
BPL.B dnsloop
BSR.W FreeSample
LEA SongDataPtr,A0
MOVE.W InsNum,D0
LSL.W #2,D0
MOVE.L BufMemPtr(PC),(A0,D0.W)
MOVE.L BufMemSize(PC),124(A0,D0.W)
MOVEQ #0,D0
MOVE.W 22(A5),D0
ADD.L D0,D0
CMP.L #$FFFF,D0
BLS.B dnsok1
MOVE.L #$FFFF,D0
dnsok1 MOVE.W D0,22(A5)
MOVEQ #0,D0
MOVE.W 26(A5),D0
ADD.L D0,D0
CMP.L #$FFFF,D0
BLS.B dnsok2
MOVE.L #$FFFF,D0
dnsok2 MOVE.W D0,26(A5)
MOVEQ #0,D0
MOVE.W 28(A5),D0
CMP.W #1,D0
BEQ.B dnsok3
ADD.L D0,D0
CMP.L #$FFFF,D0
BLS.B dnsok3
MOVE.L #$FFFF,D0
dnsok3 MOVE.W D0,28(A5)
BSR.W ShowSampleInfo
JSR WaitForButtonUp
JSR RestorePtrCol
BRA.W RedrawSample
dsErrorRestoreCol JMP ErrorRestoreCol
CNOP 0,4
SamplePos dc.l 0
FlangePos dc.l 0
ModPos dc.l 0
ModOffset dc.l 0
BufMemPtr dc.l 0
BufMemSize dc.l 0
SampleVol dc.w 100
ModSpeed dc.b 0
HalfClipFlag dc.b 0
EVEN
; -----------------------------------------------------------------------------
; SAMPLE CHORD EDITOR
;
; Rewritten by 8bitbubsy to generate better samples (normalized gain), and use
; way less RAM.
; -----------------------------------------------------------------------------
CheckEdGadg4
CMP.W #55,D1
BLS.W ToggleNewOld
CMP.W #204,D0
BLS.W ChordMenu2
CMP.W #251,D0
BLS.B ChordMenu3
CMP.W #283,D0
BLS.B ChordMenu4
CMP.W #294,D0
BLS.B ChordMenu5
ChordMenu6
CMP.W #66,D1
BLS.W ChordNote1Down
CMP.W #77,D1
BLS.W ChordNote2Down
CMP.W #88,D1
BLS.W ChordNote3Down
CMP.W #99,D1
BLS.W ChordNote4Down
RTS
ChordMenu5
CMP.W #66,D1
BLS.W ChordNote1Up
CMP.W #77,D1
BLS.W ChordNote2Up
CMP.W #88,D1
BLS.W ChordNote3Up
CMP.W #99,D1
BLS.W ChordNote4Up
RTS
ChordMenu4
CMP.W #66,D1
BLS.W ChordNote1Gadget
CMP.W #77,D1
BLS.W ChordNote2Gadget
CMP.W #88,D1
BLS.W ChordNote3Gadget
CMP.W #99,D1
BLS.W ChordNote4Gadget
RTS
ChordMenu3
CMP.W #66,D1
BLS.W ChordMajor7
CMP.W #77,D1
BLS.W ChordMinor7
CMP.W #88,D1
BLS.W ChordMajor6
CMP.W #99,D1
BLS.W ChordMinor6
RTS
ChordMenu2
CMP.W #165,D0
BLS.B ChordMenu1
CMP.W #66,D1
BLS.W ChordMajor
CMP.W #77,D1
BLS.W ChordMinor
CMP.W #88,D1
BLS.W ChordSus4
RTS
ChordMenu1
CMP.W #66,D1
BLS.W ChordMake
CMP.W #77,D1
BLS.W ChordReset
CMP.W #88,D1
BLS.W ChordUndo
RTS
DrawEditOp4
MOVE.B #4,EdScreen
JSR WaitForButtonUp
JSR ClearRightArea
MOVE.L #EditOpText4,ShowTextPtr
LEA Edit4Data,A0
MOVE.L #Edit4Size,D0
BSR.W demit
BRA.W CalculateChordLen
ToggleNewOld
JSR WaitForButtonUp
EOR.B #1,ChordUseOldSmpFlag
ShowNewOld
LEA BitplaneData+1838,A1
LEA N_BoxData,A2
TST.B ChordUseOldSmpFlag
BEQ.B DoDrawNewOld
LEA O_BoxData,A2
DoDrawNewOld JMP rtdoit
; Input: D0.B (chord note)
; Output: D0.L (16.16fp delta)
GetDeltaFromChordNote
CMP.B #36,D0
BHS.B .err
; -----------------------
MOVEM.L D1/D2/A0,-(SP)
; -----------------------
MOVE.L SongDataPtr,A0
MOVE.W ChordSrcSmpNum(PC),D2
MULU.W #30,D2
MOVEQ #0,D1
MOVE.B 14(A0,D2.W),D1 ; finetune
AND.B #$0F,D1
LSL.B #2,D1
LEA ftunePerTab(PC),A0
MOVE.L (A0,D1.W),A0 ; A0 = finetuned section in period table
MOVEQ #0,D1
AND.W #$FF,D0
ADD.W D0,D0
MOVEQ #0,D1
MOVE.W (A0,D0.W),D1 ; D1.L = dst. period
; -----------------------
LEA PeriodTable,A0
MOVEQ #0,D0
MOVE.W TuneNote,D0
ADD.W D0,D0
MOVE.W (A0,D0.W),D0 ; D0.L = ref. period
SWAP D0
CLR.W D0
JSR DIVU32
; -----------------------
MOVEM.L (SP)+,D1/D2/A0
RTS
.err MOVEQ #0,D0
RTS
; Input: D0.B (chord note)
; Output: D0.L (new sample length, in bytes)
GetSmpLenFromChordNote
MOVEM.L D1/D2/A0/A1,-(SP)
; -----------------------
MOVE.L SongDataPtr,A0
MOVE.W InsNum,D2
BNE.B .L0
MOVE.W LastInsNum,D2
.L0 MULU.W #30,D2
MOVEQ #0,D1
MOVE.B 14(A0,D2.W),D1 ; finetune
AND.B #$0F,D1
LSL.B #2,D1
LEA ftunePerTab(PC),A1
MOVE.L (A1,D1.W),A1
AND.W #$FF,D0
ADD.W D0,D0
MOVE.W (A1,D0.W),D1 ; D1.L = dst. period
; -----------------------
MOVEQ #0,D0
MOVE.W 12(A0,D2.W),D0 ; length
ADD.L D0,D0
JSR MULU32
MOVEQ #0,D1
MOVE.W TuneNote,D1
ADD.W D1,D1
LEA PeriodTable(PC),A1
MOVE.W (A1,D1.W),D1 ; D1.L = ref. period
JSR DIVU32
BCLR #0,D0
CMP.L #$1FFFE,D0
BLS.B .L1
MOVE.L #$1FFFE,D0
.L1 ; -----------------------
MOVEM.L (SP)+,D1/D2/A0/A1
RTS
CalculateChordLen
CMP.W #1,CurrScreen
BNE.W Return3
TST.B EdEnable
BEQ.W Return3
CMP.B #4,EdScreen
BNE.W Return3
; -----------------------
MOVE.W ChordNote1(PC),D1
MOVE.W ChordNote2(PC),D2
MOVE.W ChordNote3(PC),D3
MOVE.W ChordNote4(PC),D4
MOVEQ #36,D6
CMP.W D6,D1
BNE.B .L0
CMP.W D6,D2
BNE.B .L0
CMP.W D6,D3
BNE.B .L0
CMP.W D6,D4
BNE.B .L0
CLR.L ChordLen
BRA.W ShowChordLength
.L0 ; -----------------------
; get highest chord note (min length)
; -----------------------
MOVEQ #0,D0
CMP.W D6,D1 ; note empty?
BEQ.B .L6 ; yes
CMP.W D1,D0
BHS.B .L6
MOVE.W D1,D0
.L6 CMP.W D6,D2 ; note empty?
BEQ.B .L7 ; yes
CMP.W D2,D0
BHS.B .L7
MOVE.W D2,D0
.L7 CMP.W D6,D3 ; note empty?
BEQ.B .L8 ; yes
CMP.W D3,D0
BHS.B .L8
MOVE.W D3,D0
.L8 CMP.W D6,D4 ; note empty?
BEQ.B .L9 ; yes
CMP.W D4,D0
BHS.B .L9
MOVE.W D4,D0
.L9 ; -----------------------
BSR.W GetSmpLenFromChordNote
MOVE.L D0,ChordLen
; -----------------------
; fall-through
ShowChordLength
CMP.W #1,CurrScreen
BNE.W Return3
TST.B EdEnable
BEQ.W Return3
CMP.B #4,EdScreen
BNE.W Return3
; -----------------------
MOVE.W #3700,TextOffset
MOVE.L ChordLen(PC),D7
MOVE.L D7,LongWordNumber
BRA.W Print5HexDigits
DisplayChordNotes
CMP.W #1,CurrScreen
BNE.W Return3
TST.B EdEnable
BEQ.W Return3
CMP.B #4,EdScreen
BNE.W Return3
MOVE.L NoteNamesPtr,A4
; -----------------------
MOVE.W #2392,TextOffset
MOVE.W ChordNote1(PC),D0
LSL.W #2,D0
LEA (A4,D0.W),A0
MOVE.L A0,ShowTextPtr
MOVE.W #3,TextLength
BSR.W ShowText
; -----------------------
MOVE.W #2832,TextOffset
MOVE.W ChordNote2(PC),D0
LSL.W #2,D0
LEA (A4,D0.W),A0
MOVE.L A0,ShowTextPtr
MOVE.W #3,TextLength
BSR.W ShowText
; -----------------------
MOVE.W #3272,TextOffset
MOVE.W ChordNote3(PC),D0
LSL.W #2,D0
LEA (A4,D0.W),A0
MOVE.L A0,ShowTextPtr
MOVE.W #3,TextLength
BSR.W ShowText
; -----------------------
MOVE.W #3712,TextOffset
MOVE.W ChordNote4(PC),D0
LSL.W #2,D0
LEA (A4,D0.W),A0
MOVE.L A0,ShowTextPtr
MOVE.W #3,TextLength
BRA.W ShowText
ChordNote1Down
MOVE.W ChordNote1(PC),D0
LEA ChordNote1(PC),A0
BRA.B ChordNoteDown
ChordNote2Down
MOVE.W ChordNote2(PC),D0
LEA ChordNote2(PC),A0
BRA.B ChordNoteDown
ChordNote3Down
MOVE.W ChordNote3(PC),D0
LEA ChordNote3(PC),A0
BRA.B ChordNoteDown
ChordNote4Down
MOVE.W ChordNote4(PC),D0
LEA ChordNote4(PC),A0
ChordNoteDown
SUBQ.W #1,D0
BTST #2,$DFF016 ; right mouse button
BNE.B .L0
SUBQ.W #8,D0
SUBQ.W #3,D0
.L0 TST.W D0
BPL.B .L1
CLR.W D0
.L1 MOVE.W D0,(A0)
CLR.L SplitAddress
BSR.W Wait_4000
;BSR.W Wait_4000
BSR.W CalculateChordLen
BRA.W DisplayChordNotes
ChordNote1Up
MOVE.W ChordNote1(PC),D0
LEA ChordNote1(PC),A0
BRA.B ChordNoteUp
ChordNote2Up
MOVE.W ChordNote2(PC),D0
LEA ChordNote2(PC),A0
BRA.B ChordNoteUp
ChordNote3Up
MOVE.W ChordNote3(PC),D0
LEA ChordNote3(PC),A0
BRA.B ChordNoteUp
ChordNote4Up
MOVE.W ChordNote4(PC),D0
LEA ChordNote4(PC),A0
ChordNoteUp
ADDQ.W #1,D0
BTST #2,$DFF016 ; right mouse button
BNE.B .L0
ADDQ.W #8,D0
ADDQ.W #3,D0
.L0 CMP.W #36,D0
BLS.B .L1
MOVE.W #36,D0
.L1 MOVE.W D0,(A0)
CLR.L SplitAddress
BSR.W Wait_4000
;BSR.W Wait_4000
BSR.W CalculateChordLen
BRA.W DisplayChordNotes
ChordNote1Gadget
BSR.W SetUndoNotes
BTST #2,$DFF016 ; right mouse button
BNE.B .L0
MOVE.W #36,ChordNote1
BRA.W DisplayChordNotes
.L0 MOVE.W #2392,TextOffset
MOVE.W #3,TextLength
MOVE.L #SpcNoteText,ShowTextPtr
BSR.W ShowText
MOVE.W #5,SamNoteType
MOVE.L #ChordNote1,SplitAddress
LEA SelectNoteText,A0
BSR.W ShowStatusText
JMP WaitForButtonUp
ChordNote2Gadget
BSR.W SetUndoNotes
BTST #2,$DFF016 ; right mouse button
BNE.B .L0
MOVE.W #36,ChordNote2
BRA.W DisplayChordNotes
.L0 MOVE.W #2832,TextOffset
MOVE.W #3,TextLength
MOVE.L #SpcNoteText,ShowTextPtr
BSR.W ShowText
MOVE.W #5,SamNoteType
MOVE.L #ChordNote2,SplitAddress
LEA SelectNoteText,A0
BSR.W ShowStatusText
JMP WaitForButtonUp
ChordNote3Gadget
BSR.W SetUndoNotes
BTST #2,$DFF016 ; right mouse button
BNE.B .L0
MOVE.W #36,ChordNote3
BRA.W DisplayChordNotes
.L0 MOVE.W #3272,TextOffset
MOVE.W #3,TextLength
MOVE.L #SpcNoteText,ShowTextPtr
BSR.W ShowText
MOVE.W #5,SamNoteType
MOVE.L #ChordNote3,SplitAddress
LEA SelectNoteText,A0
BSR.W ShowStatusText
JMP WaitForButtonUp
ChordNote4Gadget
BSR.W SetUndoNotes
BTST #2,$DFF016 ; right mouse button
BNE.B .L0
MOVE.W #36,ChordNote4
BRA.W DisplayChordNotes
.L0 MOVE.W #3712,TextOffset
MOVE.W #3,TextLength
MOVE.L #SpcNoteText,ShowTextPtr
BSR.W ShowText
MOVE.W #5,SamNoteType
MOVE.L #ChordNote4,SplitAddress
LEA SelectNoteText,A0
BSR.W ShowStatusText
JMP WaitForButtonUp
ChordMajor7
BSR.W SetUndoNotes
MOVE.W ChordNote1(PC),D0
CMP.W #36,D0
BEQ.W BaseNoteError
ADDQ.W #4,D0
MOVE.W D0,ChordNote2
ADDQ.W #3,D0
MOVE.W D0,ChordNote3
ADDQ.W #4,D0 ; --PT2.3D bug fix: fixed major7 chord (was #3)
MOVE.W D0,ChordNote4
; fall-through
CheckOctaves3
CMP.W #35,ChordNote2
BLS.B .L0
SUB.W #12,ChordNote2
.L0 CMP.W #35,ChordNote3
BLS.B .L1
SUB.W #12,ChordNote3
.L1 CMP.W #35,ChordNote4
BLS.B .L2
SUB.W #12,ChordNote4
.L2 BSR.W CalculateChordLen
BRA.W DisplayChordNotes
ChordMinor7
BSR.W SetUndoNotes
MOVE.W ChordNote1(PC),D0
CMP.W #36,D0
BEQ.W BaseNoteError
ADDQ.W #3,D0
MOVE.W D0,ChordNote2
ADDQ.W #4,D0
MOVE.W D0,ChordNote3
ADDQ.W #3,D0
MOVE.W D0,ChordNote4
BRA.B CheckOctaves3
ChordMajor6
BSR.W SetUndoNotes
MOVE.W ChordNote1(PC),D0
CMP.W #36,D0
BEQ.W BaseNoteError
ADDQ.W #4,D0
MOVE.W D0,ChordNote2
ADDQ.W #3,D0
MOVE.W D0,ChordNote3
ADDQ.W #2,D0
MOVE.W D0,ChordNote4
BRA.W CheckOctaves3
ChordMinor6
BSR.W SetUndoNotes
MOVE.W ChordNote1(PC),D0
CMP.W #36,D0
BEQ.W BaseNoteError
ADDQ.W #3,D0
MOVE.W D0,ChordNote2
ADDQ.W #4,D0
MOVE.W D0,ChordNote3
ADDQ.W #2,D0
MOVE.W D0,ChordNote4
BRA.W CheckOctaves3
ChordMajor
BSR.W SetUndoNotes
MOVE.W ChordNote1(PC),D0
CMP.W #36,D0
BEQ.W BaseNoteError
ADDQ.W #4,D0
MOVE.W D0,ChordNote2
ADDQ.W #3,D0
MOVE.W D0,ChordNote3
MOVE.W #36,ChordNote4
CheckOctaves2
CMP.W #35,ChordNote2
BLS.B .L0
SUB.W #12,ChordNote2
.L0 CMP.W #35,ChordNote3
BLS.B .L1
SUB.W #12,ChordNote3
.L1 BRA.W DisplayChordNotes
ChordMinor
BSR.W SetUndoNotes
MOVE.W ChordNote1(PC),D0
CMP.W #36,D0
BEQ.W BaseNoteError
ADDQ.W #3,D0
MOVE.W D0,ChordNote2
ADDQ.W #4,D0
MOVE.W D0,ChordNote3
MOVE.W #36,ChordNote4
BRA.B CheckOctaves2
ChordSus4
BSR.W SetUndoNotes
MOVE.W ChordNote1(PC),D0
CMP.W #36,D0
BEQ.W BaseNoteError
ADDQ.W #5,D0
MOVE.W D0,ChordNote2
ADDQ.W #2,D0
MOVE.W D0,ChordNote3
MOVE.W #36,ChordNote4
BRA.W CheckOctaves2
ChordReset
BSR.B SetUndoNotes
MOVEQ #36,D0
MOVE.W D0,ChordNote1
MOVE.W D0,ChordNote2
MOVE.W D0,ChordNote3
MOVE.W D0,ChordNote4
CLR.L ChordLen
RedrawNotes
BSR.W ShowChordLength
BRA.W DisplayChordNotes
ChordUndo
MOVE.W ChordNote1Old(PC),ChordNote1
MOVE.W ChordNote2Old(PC),ChordNote2
MOVE.W ChordNote3Old(PC),ChordNote3
MOVE.W ChordNote4Old(PC),ChordNote4
MOVE.L ChordLenOld(PC),ChordLen
BRA.B RedrawNotes
SetUndoNotes
MOVE.W ChordNote1(PC),ChordNote1Old
MOVE.W ChordNote2(PC),ChordNote2Old
MOVE.W ChordNote3(PC),ChordNote3Old
MOVE.W ChordNote4(PC),ChordNote4Old
MOVE.L ChordLen(PC),ChordLenOld
RTS
ChordMake
LEA MakeChordText(PC),A0
JSR AreYouSure
BNE.W Return2
JSR StorePtrCol
JSR SetWaitPtrCol
; ---------------------
; sort note list...
; ---------------------
MOVEQ #2-1,D7
MOVEQ #36,D5
.loop MOVE.W ChordNote1(PC),D1
MOVE.W ChordNote2(PC),D2
MOVE.W ChordNote3(PC),D3
MOVE.W ChordNote4(PC),D4
CMP.W D5,D1
BEQ.W BaseNoteError
CMP.W D5,D2
BNE.B .L0
MOVE.W D3,D2
MOVE.W D4,D3
MOVE.W D5,D4
.L0 CMP.W D5,D3
BNE.B .L1
MOVE.W D4,D3
MOVE.W D5,D4
.L1 CMP.W D2,D1
BNE.B .L2
MOVE.W D3,D2
MOVE.W D4,D3
MOVE.W D5,D4
BRA.B .L1
.L2 CMP.W D3,D1
BNE.B .L3
MOVE.W D4,D3
MOVE.W D5,D4
BRA.B .L1
.L3 CMP.W D4,D1
BNE.B .L4
MOVE.W D5,D4
BRA.B .L1
.L4 CMP.W D3,D2
BNE.B .L5
MOVE.W D4,D3
MOVE.W D5,D4
CMP.W D5,D2
BEQ.B .L5
BRA.B .L1
.L5 CMP.W D4,D2
BNE.B .L6
MOVE.W D5,D4
CMP.W D5,D2
BEQ.B .L6
BRA.B .L1
.L6 CMP.W D4,D3
BNE.B .L7
MOVE.W D5,D4
CMP.W D5,D3
BEQ.B .L7
BRA.B .L1
.L7 MOVE.W D1,ChordNote1
MOVE.W D2,ChordNote2
MOVE.W D3,ChordNote3
MOVE.W D4,ChordNote4
DBRA D7,.loop
; ---------------------
ResetLocalLabels
; ---------------------
BSR.W DisplayChordNotes
; ---------------------
CMP.W #36,ChordNote2
BEQ.W OneNoteError
; ---------------------
CMP.L #2,ChordLen
BLO.W LenTooSmallError
; ---------------------
MOVE.W InsNum,D0
BNE.B .L0
MOVE.W LastInsNum,D0
.L0 MOVE.W D0,ChordSrcSmpNum
MOVEQ #0,D1
MOVE.W D0,D1
SUBQ.W #1,D0
LSL.W #2,D0
MULU.W #30,D1
MOVE.L SongDataPtr(PC),A2
MOVE.W 12(A2,D1.W),D1
ADD.L D1,D1
MOVE.L D1,ChordSrcSmpLen
LEA SampleStarts(PC),A0
LEA SampleLengths(PC),A1
MOVE.L (A0,D0.W),ChordSrcSmpPtr
MOVE.L (A1,D0.W),ChordSrcSmpAllocLen
; ---------------------
; get destination sample number
; ---------------------
TST.B ChordUseOldSmpFlag
BEQ.B .new
MOVE.W InsNum,D0
BNE.B .L1
MOVE.W LastInsNum,D0
BRA.B .L1
.new ; find first available sample slot
LEA SampleStarts,A2
MOVEQ #1,D0
.loop0 TST.L (A2)+
BEQ.B .L1
ADDQ.B #1,D0
CMP.B #31,D0
BLS.B .loop0
MOVEQ #0,D0
.L1 MOVE.W D0,ChordDstSmpNum
BEQ.W NoEmptySampleError
; ---------------------
; set voice datas
; ---------------------
LEA ChordVoices(PC),A6
LEA ChordNote1(PC),A0
MOVEQ #4-1,D7
MOVEQ #0,D2
.loop1 MOVE.W (A0)+,D0 ; D0.W = current note
CMP.W #36,D0 ; do we have a note set?
BHS.B .nextv ; nope, go to next note
CLR.L cv_pos(A6)
CLR.W cv_frac(A6)
BSR.W GetDeltaFromChordNote
MOVE.W D0,cv_deltalo(A6)
CLR.W D0
SWAP D0 ; D0.L = resampling delta integer
MOVE.L D0,cv_deltahi(A6)
ADDQ.W #1,D2
LEA CV_SIZE(A6),A6
.nextv DBRA D7,.loop1
CMP.W #2,D2
BLO.W OneNoteError
MOVE.W D2,ChordNumVoices
; ---------------------
; allocate sample data
; ---------------------
MOVE.L ChordLen(PC),D0
MOVE.L #MEMF_CHIP,D1
JSR PTAllocMem
MOVE.L D0,ChordDstSmpPtr
BEQ.W ChordOutOfMemory
; ---------------------
; scan mix peak
; ---------------------
LEA PeakScanText(PC),A0
BSR.W ShowStatusText
; ---------------------
MOVE.L ChordLen(PC),D7
LEA ChordVoices(PC),A4
MOVE.L ChordSrcSmpPtr(PC),A0
MOVE.W ChordNumVoices(PC),D2
SUBQ.W #2,D2
LSL.W #2,D2
LEA ChordScanPeakFunc(PC),A3
MOVE.L (A3,D2.W),A3
JSR (A3)
TST.W D0 ; D0.W = mix peak (0 .. 128*4)
BNE.B .L2
MOVEQ #1,D0
.L2 MOVE.L #256*127,D1
DIVU.W D0,D1
MOVE.W D1,ChordNormalizeMul
; ---------------------
; do resampling+mixing...
; ---------------------
LEA MakingChordText(PC),A0
BSR.W ShowStatusText
; ---------------------
LEA ChordVoices(PC),A4
CLR.L cv_pos+(CV_SIZE*0)(A4)
CLR.W cv_frac+(CV_SIZE*0)(A4)
CLR.L cv_pos+(CV_SIZE*1)(A4)
CLR.W cv_frac+(CV_SIZE*1)(A4)
CLR.L cv_pos+(CV_SIZE*2)(A4)
CLR.W cv_frac+(CV_SIZE*2)(A4)
CLR.L cv_pos+(CV_SIZE*3)(A4)
CLR.W cv_frac+(CV_SIZE*3)(A4)
MOVE.L ChordSrcSmpPtr(PC),A0
MOVE.L ChordDstSmpPtr(PC),A1
MOVE.L ChordLen(PC),D7
MOVE.W ChordNormalizeMul(PC),D0
MOVE.L ChordSrcSmpLen(PC),A2 ; length of original sample
SUBQ #1,A2
MOVE.W ChordNumVoices(PC),D2
SUBQ.W #2,D2
LSL.W #2,D2
LEA ChordMixFunc(PC),A3
MOVE.L (A3,D2.W),A3
JSR (A3)
; ---------------------
BSR.W TurnOffVoices
; ---------------------
; free memory (if needed)
; ---------------------
TST.B ChordUseOldSmpFlag
BEQ.B .L3
MOVE.L ChordSrcSmpPtr(PC),A1
MOVE.L ChordSrcSmpAllocLen(PC),D0
JSR PTFreeMem
.L3 ; ---------------------
; set last sample text char to '!'
; ---------------------
MOVE.W ChordDstSmpNum(PC),D0
MOVE.W D0,InsNum ; set current sample
MOVE.W D0,D1 ; copy for code below
MULU.W #30,D1
MOVE.L SongDataPtr(PC),A2
LEA -10(A2,D1.W),A1
MOVE.B #'!',21(A1)
; ---------------------
; update sample attributes
; ---------------------
LEA SampleStarts(PC),A0
LEA SampleLengths(PC),A1
SUBQ.W #1,D0
LSL.W #2,D0
MOVE.L ChordDstSmpPtr(PC),(A0,D0.W)
MOVE.L ChordLen(PC),D2
MOVE.L D2,(A1,D0.W)
LEA 12(A2,D1.W),A0
LSR.L #1,D2
MOVE.W D2,(A0) ; length
MOVE.L #$00000001,4(A0) ; repeat:$0000 replen:$0001
TST.B ChordUseOldSmpFlag ; if we used a new smp, edit more stuff
BNE.B .L4
MOVE.W #$0040,2(A0) ; finetune:$00 volume:$40
LEA -10(A2,D1.W),A0 ; copy over sample text
MOVE.W ChordSrcSmpNum(PC),D0
MULU.W #30,D0
LEA -10(A2,D0.W),A1
MOVEQ #21-1,D0
.loop2 MOVE.B (A1)+,(A0)+
DBRA D0,.loop2
.L4 ; ---------------------
JSR RestorePtrCol
JSR ClearSamStarts
BSR.W ShowAllRight
BSR.W ShowSampleInfo
BSR.W RedrawSample
BRA.W DisplaySample
CVMIX1_M MACRO
MOVE.L cv_pos(A6),D2
MOVE.W cv_frac(A6),D3
MOVE.B (A0,D2.L),D6
EXT.W D6
MOVE.B 1(A0,D2.L),D4
EXT.W D4
SUB.W D6,D4
MOVE.W D3,D5
LSR.W #1,D5
MULS.W D5,D4
SWAP D4
ROL.L #1,D4
ADD.W D4,D6
MOVE.W D6,D1
MOVE.L cv_deltahi(A6),D6
ADD.W cv_deltalo(A6),D3
ADDX.L D6,D2
MOVE.L D2,cv_pos(A6)
MOVE.W D3,cv_frac(A6)
ENDM
CVMIX2_M MACRO
MOVE.L cv_pos(A6),D2
MOVE.W cv_frac(A6),D3
MOVE.B (A0,D2.L),D6
EXT.W D6
MOVE.B 1(A0,D2.L),D4
EXT.W D4
SUB.W D6,D4
MOVE.W D3,D5
LSR.W #1,D5
MULS.W D5,D4
SWAP D4
ROL.L #1,D4
ADD.W D4,D6
ADD.W D6,D1
MOVE.L cv_deltahi(A6),D6
ADD.W cv_deltalo(A6),D3
ADDX.L D6,D2
MOVE.L D2,cv_pos(A6)
MOVE.W D3,cv_frac(A6)
ENDM
ChordMix2Voices
MOVE.L A4,A6
CVMIX1_M
LEA CV_SIZE(A6),A6
CVMIX2_M
; ---------------------
MULS.W D0,D1
ASR.L #8,D1
MOVE.B D1,(A1)+
; ---------------------
SUBQ.L #1,D7
BNE.B ChordMix2Voices
RTS
ChordMix3Voices
MOVE.L A4,A6
CVMIX1_M
LEA CV_SIZE(A6),A6
CVMIX2_M
LEA CV_SIZE(A6),A6
CVMIX2_M
; ---------------------
MULS.W D0,D1
ASR.L #8,D1
MOVE.B D1,(A1)+
; ---------------------
SUBQ.L #1,D7
BNE.W ChordMix3Voices
RTS
ChordMix4Voices
MOVE.L A4,A6
CVMIX1_M
LEA CV_SIZE(A6),A6
CVMIX2_M
LEA CV_SIZE(A6),A6
CVMIX2_M
LEA CV_SIZE(A6),A6
CVMIX2_M
; ---------------------
MULS.W D0,D1
ASR.L #8,D1
MOVE.B D1,(A1)+
; ---------------------
SUBQ.L #1,D7
BNE.W ChordMix4Voices
RTS
ChordScanPeak2Voices
MOVEQ #0,D0 ; peak
; ---------------------
.loop MOVE.L A4,A6
CVMIX1_M
LEA CV_SIZE(A6),A6
CVMIX2_M
; ---------------------
TST.W D1
BPL.B .L0
NEG.W D1
.L0 CMP.W D1,D0
BLO.B .setNewPeak
; ---------------------
.next SUBQ.L #1,D7
BNE.B .loop
RTS
.setNewPeak
MOVE.W D1,D0
BRA.B .next
ChordScanPeak3Voices
MOVEQ #0,D0 ; peak
; ---------------------
.loop MOVE.L A4,A6
CVMIX1_M
LEA CV_SIZE(A6),A6
CVMIX2_M
LEA CV_SIZE(A6),A6
CVMIX2_M
; ---------------------
TST.W D1
BPL.B .L0
NEG.W D1
.L0 CMP.W D1,D0
BLO.B .setNewPeak
; ---------------------
.next SUBQ.L #1,D7
BNE.W .loop
RTS
.setNewPeak
MOVE.W D1,D0
BRA.B .next
ChordScanPeak4Voices
MOVEQ #0,D0 ; peak
; ---------------------
.loop MOVE.L A4,A6
CVMIX1_M
LEA CV_SIZE(A6),A6
CVMIX2_M
LEA CV_SIZE(A6),A6
CVMIX2_M
LEA CV_SIZE(A6),A6
CVMIX2_M
; ---------------------
TST.W D1
BPL.B .L0
NEG.W D1
.L0 CMP.W D1,D0
BLO.B .setNewPeak
; ---------------------
.next SUBQ.L #1,D7
BNE.W .loop
RTS
.setNewPeak
MOVE.W D1,D0
BRA.B .next
BaseNoteError
LEA NoBaseNoteText(PC),A0
BSR.W ShowStatusText
JMP SetErrorPtrCol
NoEmptySampleError
LEA NoEmptySampleText(PC),A0
BSR.W ShowStatusText
JMP ErrorRestoreCol
OneNoteError
LEA OnlyOneNoteText(PC),A0
BSR.W ShowStatusText
JMP ErrorRestoreCol
LenTooSmallError
LEA LenTooSmallText(PC),A0
BSR.W ShowStatusText
JMP ErrorRestoreCol
ChordOutOfMemory
LEA mixerrtext3(PC),A0
BSR.W ShowStatusText
JMP ErrorRestoreCol
cv_deltahi EQU 0 ; L
cv_pos EQU 4 ; L
cv_deltalo EQU 8 ; W
cv_frac EQU 10 ; W
CV_SIZE EQU 12 ; must be a multiple of 4!
CNOP 0,4
ChordMixFunc
dc.l ChordMix2Voices, ChordMix3Voices, ChordMix4Voices
ChordScanPeakFunc
dc.l ChordScanPeak2Voices, ChordScanPeak3Voices, ChordScanPeak4Voices
ChordVoices dcb.b CV_SIZE*4,0
ChordSrcSmpPtr dc.l 0
ChordSrcSmpLen dc.l 0
ChordSrcSmpAllocLen dc.l 0
ChordDstSmpPtr dc.l 0
ChordLen dc.l 0
ChordLenOld dc.l 0
ChordNormalizeMul dc.w 0
ChordNote1 dc.w 36 ; do not change the order of these!
ChordNote2 dc.w 36 ; --
ChordNote3 dc.w 36 ; --
ChordNote4 dc.w 36 ; --
ChordNote1Old dc.w 36
ChordNote2Old dc.w 36
ChordNote3Old dc.w 36
ChordNote4Old dc.w 36
ChordSrcSmpNum dc.w 0
ChordDstSmpNum dc.w 0
ChordNumVoices dc.w 0
MakeChordText dc.b 'Make chord?',0
PeakScanText dc.b 'Scanning peak...',0
MakingChordText dc.b 'Making chord...',0
NoBaseNoteText dc.b 'No base note!',0
NoEmptySampleText dc.b 'No empty sample!',0
OnlyOneNoteText dc.b 'Only one note!',0
LenTooSmallText dc.b 'Length too small!',0
EVEN
;---- Save Song ----
SaveSong
BSR.W StopIt
CLR.B RawKeyCode
MOVE.L SongDataPtr(PC),A0
LEA SampleLengthAdd(PC),A1
MOVEQ #0,D0
MOVEQ #2,D1
sadloop MOVE.W (A1,D1.W),D2
ADD.W D2,42(A0,D0.W)
ADD.W #$1E,D0
ADDQ.W #2,D1
CMP.W #$3E,D1
BNE.B sadloop
LEA sd_pattpos(A0),A0
MOVEQ #0,D0
MOVEQ #0,D1
MOVEQ #0,D2
CLR.W HighPattNum
ssloop MOVE.B (A0,D0.W),D1
ADDQ.W #1,D0
CMP.W #128,D0
BHI.B DoSaveSong
MOVE.W HighPattNum(PC),D2
CMP.W D2,D1
BLS.B ssloop
MOVE.W D1,HighPattNum
BRA.B ssloop
DoSaveSong
LEA SongsPath2,A0
JSR CopyPath
MOVE.L SongDataPtr(PC),A0
MOVEQ #20-1,D0
dssoloop MOVE.B (A0)+,(A1)+
DBRA D0,dssoloop
MOVE.L #FileName,FileNamePtr
MOVE.L SongDataPtr(PC),A0
MOVE.L A0,DiskDataPtr
MOVE.L #1084,DiskDataLength
MOVEQ #0,D0
MOVE.W HighPattNum(PC),D0
ADDQ.L #1,D0
LSL.L #8,D0
LSL.L #2,D0
ADD.L D0,DiskDataLength
MOVE.B #$7F,951(A0)
MOVE.L #'M.K.',sd_magicid(A0)
CMP.W #$40,HighPattNum
BLO.B lbC00E82C
MOVE.L #'M!K!',sd_magicid(A0)
lbC00E82C MOVE.B PackMode,D0
BTST #0,D0
BEQ.B lbC00E852
LEA CrunchingText(PC),A0
BSR.W ShowStatusText
BSR.B Cruncher
CMP.W #$40,HighPattNum
BLO.B lbC00E852
MOVE.L #$50414B4B,(A0)
lbC00E852 BSR.W DoSaveData
MOVE.B PackMode,D0
BTST #0,D0
BEQ.B lbC00E86E
LEA DecrunchingText(PC),A0
BSR.W ShowStatusText
BSR.W Decruncher
lbC00E86E MOVE.L SongDataPtr(PC),A0
LEA SampleLengthAdd(PC),A1
MOVEQ #0,D0
MOVEQ #2,D1
lbC00E87A MOVE.W (A1,D1.W),D2
SUB.W D2,42(A0,D0.W)
ADD.W #$1E,D0
ADDQ.W #2,D1
CMP.W #$3E,D1
BNE.B lbC00E87A
BSR.W ShowAllRight
JSR SetNormalPtrCol
JMP DoAutoDir
Cruncher
JSR SetNormalPtrCol
MOVE.L SongDataPtr(PC),A0
MOVE.L A0,A1
LEA 12(A1),A1
MOVE.L A1,SongPlus12Ptr
MOVE.L A0,A1
ADD.L SongAllocSize(PC),A1
MOVE.L A1,SongPlus70kPtr
MOVE.L A0,A1
ADD.L SongAllocSize(PC),A1
SUB.L DiskDataLength(PC),A1
MOVE.L A1,EndOfSongPtr
MOVE.L DiskDataLength(PC),RealSongLength
MOVE.L SongDataPtr(PC),A0
ADD.L DiskDataLength(PC),A0
MOVE.L SongDataPtr(PC),A1
ADD.L SongAllocSize(PC),A1
MOVE.L DiskDataLength(PC),D0
cloop MOVE.B -(A0),-(A1)
SUBQ.L #1,D0
BNE.B cloop
BSR.B DoCrunch
SUB.L SongPlus12Ptr(PC),A2
MOVE.L A2,D0
MOVE.L D0,CrunchedSongLength
MOVE.L D0,D1
ADD.L SongPlus12Ptr(PC),D1
MOVE.L SongDataPtr(PC),A0
MOVE.L #'PACK',(A0)
MOVE.L CrunchedSongLength(PC),4(A0)
MOVE.L RealSongLength(PC),8(A0)
MOVE.L SongDataPtr(PC),DiskDataPtr
MOVE.L CrunchedSongLength(PC),D0
ADD.L #12,D0
MOVE.L D0,DiskDataLength
RTS
CNOP 0,4
EndOfSongPtr dc.l 0
SongPlus70kPtr dc.l 0
RealSongLength dc.l 0
SongPlus12Ptr dc.l 0
CrunchedSongLength dc.l 0
DoCrunch
MOVE.L EndOfSongPtr(PC),A0
MOVE.L SongPlus70kPtr(PC),A1
MOVE.L SongPlus12Ptr(PC),A2
MOVEQ #1,D2
CLR.W D1
dcloop BSR.B DoCrunch2
TST.B D0
BEQ.B dcskip
ADDQ.W #1,D1
CMP.W #$0108,D1
BNE.B dcskip
BSR.W DoCrunch6
dcskip CMP.L A0,A1
BGT.B dcloop
BSR.W DoCrunch6
BRA.W DoCrunch8
DoCrunch2
MOVE.L A0,A3
LEA 127(A3),A3
CMP.L A1,A3
BLE.B dc2skip
MOVE.L A1,A3
dc2skip MOVEQ #1,D5
MOVE.L A0,A5
ADDQ #1,A5
dc2_1 MOVE.B (A0),D3
MOVE.B 1(A0),D4
MOVE.W D3,$DFF1A2
dc2loop CMP.B (A5)+,D3
BNE.B dc2skip2
CMP.B (A5),D4
BEQ.B DoCrunch3
dc2skip2 CMP.L A5,A3
BGT.B dc2loop
BRA.B dc4_3
DoCrunch3
SUBQ.L #1,A5
MOVE.L A0,A4
dc3loop MOVE.B (A4)+,D3
CMP.B (A5)+,D3
BNE.B dc3skip
CMP.L A5,A3
BGT.B dc3loop
dc3skip MOVE.L A4,D3
SUB.L A0,D3
SUBQ.L #1,D3
CMP.L D3,D5
BGE.B dc4_2
MOVE.L A5,D4
SUB.L A0,D4
SUB.L D3,D4
SUBQ.L #1,D4
CMP.L #4,D3
BLE.B DoCrunch4
MOVEQ #6,D6
CMP.L #$00000101,D3
BLT.B dc3skip2
MOVE.W #$0100,D3
dc3skip2
BRA.B dc4_1
DoCrunch4 MOVE.W D3,D6
SUBQ.W #2,D6
ADD.W D6,D6
dc4_1 LEA CrunchData3(PC),A6
CMP.W (A6,D6.W),D4
BGE.B dc4_2
MOVE.L D3,D5
MOVE.L D4,CrunchData1
MOVE.B D6,CrunchData2
dc4_2 CMP.L A5,A3
BGT.B dc2_1
dc4_3 CMP.L #1,D5
BEQ.B DoCrunch5
BSR.B DoCrunch6
MOVE.B CrunchData2(PC),D6
MOVE.L CrunchData1(PC),D3
MOVE.W 8(A6,D6.W),D0
BSR.W DoCrunch7
MOVE.W $10(A6,D6.W),D0
BEQ.B dc4skip
MOVE.L D5,D3
SUBQ.W #1,D3
BSR.W DoCrunch7
dc4skip MOVE.W $18(A6,D6.W),D0
MOVE.W $20(A6,D6.W),D3
BSR.B DoCrunch7
ADDQ.W #1,$28(A6,D6.W)
ADD.L D5,A0
CLR.B D0
RTS
DoCrunch5
MOVE.B (A0)+,D3
MOVEQ #8,D0
BSR.B DoCrunch7
MOVEQ #1,D0
RTS
CNOP 0,4
CrunchData1 dc.l 0
CrunchData2 dc.b 0,0
CrunchData3 dc.w $0100,$0200,$0400,$1000,8,9,10,8
dc.w 0,0,0,8,2,3,3,3,1,4,5,6,0,0,0,0
CrunchData4 dc.w 0
CrunchData5 dc.w 0
DoCrunch6
TST.W D1
BEQ.W Return3
MOVE.W D1,D3
CLR.W D1
CMP.W #9,D3
BGE.B dc6_2
ADDQ.W #1,CrunchData4
SUBQ.W #1,D3
MOVEQ #5,D0
BRA.B DoCrunch7
dc6_2 ADDQ.W #1,CrunchData5
SUB.W #9,D3
OR.W #$700,D3
MOVEQ #12-1,D0
DoCrunch7
SUBQ.W #1,D0
dc7loop LSR.L #1,D3
ROXL.L #1,D2
BCS.B dc8_2
DBRA D0,dc7loop
RTS
DoCrunch8
CLR.W D0
dc8_2 MOVE.L D2,(A2)+
MOVEQ #1,D2
DBRA D0,dc7loop
RTS
Decruncher
MOVE.L SongDataPtr(PC),A0
LEA 12(A0),A0
MOVE.L EndOfSongPtr(PC),A1
MOVE.L CrunchedSongLength(PC),D0
MOVE.L RealSongLength(PC),D1
BSR.B DoDecrunch
MOVE.L EndOfSongPtr(PC),A0
MOVE.L SongDataPtr(PC),A1
MOVE.L RealSongLength(PC),D0
ddcloop MOVE.B (A0)+,(A1)+
SUBQ.L #1,D0
BNE.B ddcloop
MOVE.L SongDataPtr(PC),A0
ADD.L SongAllocSize(PC),A0
MOVE.L SongDataPtr(PC),A1
ADD.L RealSongLength(PC),A1
SUB.L A1,A0
MOVE.L A0,D0
ddcloop2
CLR.B (A1)+
SUBQ.L #1,D0
BNE.B ddcloop2
RTS
DoDecrunch
ADD.L D0,A0
MOVE.L D1,A2
ADD.L A1,A2
MOVE.L -(A0),D0
dec_1 LSR.L #1,D0
BNE.B decskip
BSR.B dec5
decskip BLO.B dec3
MOVEQ #8,D1
MOVEQ #1,D3
LSR.L #1,D0
BNE.B decskip2
BSR.B dec5
decskip2
BCS.B dec4_1
MOVEQ #3,D1
CLR.W D4
dec_2 BSR.B dec6
MOVE.W D2,D3
ADD.W D4,D3
decloop1
MOVEQ #8-1,D1
decloop2
LSR.L #1,D0
BNE.B decskip3
BSR.B dec5
decskip3
ROXL.L #1,D2
DBRA D1,decloop2
MOVE.B D2,-(A2)
DBRA D3,decloop1
BRA.B dec4_3
dec2 MOVEQ #8,D1
MOVEQ #8,D4
BRA.B dec_2
dec3 MOVEQ #2,D1
BSR.B dec6
CMP.B #2,D2
BLT.B dec4
CMP.B #3,D2
BEQ.B dec2
MOVEQ #8,D1
BSR.B dec6
MOVE.W D2,D3
MOVE.W #8,D1
BRA.B dec4_1
dec4 MOVE.W #9,D1
ADD.W D2,D1
ADDQ.W #2,D2
MOVE.W D2,D3
dec4_1 BSR.B dec6
dec4_2 SUBQ #1,A2
MOVE.B (A2,D2.W),(A2)
DBRA D3,dec4_2
dec4_3 CMP.L A2,A1
BLT.B dec_1
RTS
dec5 MOVE.L -(A0),D0
MOVE.W D0,$DFF1A2
MOVE.W #$10,CCR
ROXR.L #1,D0
RTS
dec6 SUBQ.W #1,D1
CLR.W D2
dec6loop
LSR.L #1,D0
BNE.B dec6skip
MOVE.L -(A0),D0
MOVE.W D0,$DFF1A2
MOVE.W #$10,CCR
ROXR.L #1,D0
dec6skip
ROXL.L #1,D2
DBRA D1,dec6loop
RTS
OutOfMemoryFlag dc.w 0
NoteDataClippedText dc.b 'NoteData Clipped!',0
EVEN
LoadModule
CLR.W OutOfMemoryFlag
CLR.W TempPPFileFlag
LoadModule2
MOVE.W #1,LoadInProgress
BSR.W DoClearSong
BSR.W ClrSampleInfo
JSR SetDiskPtrCol
JSR StorePtrCol
BSR.W CheckForPosEdNames
JSR RestorePtrCol
LEA ModulesPath2,A0
JSR CopyPath
LEA DirInputName,A0
MOVEQ #DirNameLength-1,D0
lmloop2 MOVE.B (A0)+,(A1)+
DBRA D0,lmloop2
LEA LoadingModuleText(PC),A0
BSR.W ShowStatusText
LoadModule3
MOVE.L DOSBase(PC),A6
MOVE.L #FileName,D1
MOVE.L #1005,D2
JSR _LVOOpen(A6)
MOVE.L D0,FileHandle
BEQ.W CantOpenFile
MOVE.L D0,D1
MOVE.L SongDataPtr(PC),D2
MOVE.L #1084,D3
JSR _LVORead(A6)
MOVE.L SongDataPtr(PC),A0
CMP.L #'PP20',(A0)
BEQ.W UnpackPPFile
CMP.L #'PX20',(A0)
BEQ.W UnpackPPFile
; --PT2.3D fix: clamp song length to 128
CMP.B #128,sd_numofpatt(A0)
BLS.B songLenOK
MOVE.B #128,sd_numofpatt(A0)
songLenOK
MOVE.B #127,sd_numofpatt+1(A0) ; Set repeatstart to 127
CMP.L #'M!K!',sd_magicid(A0)
BNE.W lm64Patts
; 100 patterns MOD (M!K!)
TST.W OutOfMemoryFlag
BNE.W lbC00ED4A
TST.B OneHundredPattFlag
BNE.W lbC00ED4A
lbC00EC9A
MOVE.L SongDataPtr(PC),D1
BEQ.B lbC00ECB4
MOVE.L D1,A1
MOVE.L SongAllocSize(PC),D0
JSR PTFreeMem
lbC00ECB4
EOR.B #1,OneHundredPattFlag
MOVE.L #SONG_SIZE_64PAT,SongAllocSize
MOVE.L #64-1,MaxPattern
TST.B OneHundredPattFlag
BEQ.B lbC00ECEC
MOVE.L #SONG_SIZE_100PAT,SongAllocSize
MOVE.L #100-1,MaxPattern
lbC00ECEC
MOVE.L SongAllocSize(PC),D0
MOVE.L #MEMF_CLEAR!MEMF_PUBLIC,D1
JSR PTAllocMem
MOVE.L D0,SongDataPtr
BNE.B lbC00ED1A
BSR.W OutOfMemErr
MOVE.W #1,OutOfMemoryFlag
BRA.B lbC00EC9A
lbC00ED1A
MOVE.L FileHandle(PC),D1
MOVE.L DOSBase(PC),A6
JSR _LVOClose(A6)
BRA.W LoadModule2
; 64 patterns MOD (M.K.)
lm64Patts
CMP.L #'M.K.',sd_magicid(A0)
BEQ.B lbC00ED4A
BSR.W NotMKFormat
BNE.B lbC00ED4A
MOVE.L FileHandle(PC),D1
MOVE.L #600,D2
MOVEQ #-1,D3
JSR _LVOSeek(A6)
lbC00ED4A
LEA LoadingModuleText(PC),A0
BSR.W ShowStatusText
MOVEQ #0,D4
MOVE.L SongDataPtr(PC),A0
LEA sd_pattpos(A0),A0
MOVEQ #0,D0
MOVE.B -1(A0),D0
MOVEQ #0,D3
lbC00ED68
CMP.B (A0)+,D3
BHI.B lbC00ED70
MOVE.B -1(A0),D3
lbC00ED70
DBRA D0,lbC00ED68
ADDQ.W #1,D3
CMP.W #64,D3
BLE.B lbC00EDC8
TST.B OneHundredPattFlag
BNE.B lbC00EDC8
MOVE.W D3,D4
SUB.W #64,D4
MULU.W #1024,D4
MOVE.L SongDataPtr(PC),A0
LEA sd_pattpos(A0),A0
MOVEQ #0,D0
MOVE.B -1(A0),D0
MOVEQ #63,D3
lbC00ED9E
CMP.B (A0)+,D3
BHI.B lbC00EDA6
MOVE.B D3,-1(A0)
lbC00EDA6
DBRA D0,lbC00ED9E
LEA NoteDataClippedText(PC),A0
BSR.W ShowStatusText
JSR WaitALittle
LEA LoadingModuleText(PC),A0
BSR.W ShowStatusText
MOVEQ #64,D3
lbC00EDC8
MULU.W #1024,D3
MOVE.L FileHandle(PC),D1
MOVE.L SongDataPtr(PC),D2
ADD.L #1084,D2
MOVE.L DOSBase(PC),A6
JSR _LVORead(A6)
MOVE.L SongDataPtr(PC),A0
MOVE.L #'M.K.',sd_magicid(A0)
TST.L D4
BEQ.B lbC00EE2C
MOVE.L D4,D0
MOVE.L #MEMF_CLEAR!MEMF_PUBLIC,D1
JSR PTAllocMem
MOVE.L D0,D2
BEQ.B lbC00EE2C
MOVE.L D0,D7
MOVE.L D4,D3
MOVE.L FileHandle(PC),D1
MOVE.L DOSBase(PC),A6
JSR _LVORead(A6)
MOVE.L D7,D1
BEQ.B lbC00EE2C
MOVE.L D1,A1
MOVE.L D4,D0
JSR PTFreeMem
lbC00EE2C
CLR.L PatternNumber
CLR.L CurrPos
BSR.W RedrawPattern
CLR.W ScrPattPos
BSR.W SetScrPatternPos
MOVE.W #1,InsNum
BSET #1,$BFE001 ; --PT2.3D fix: disable LED filter on module load
BSR.W CheckAbort
BEQ.W rmiend
TST.B AutoExitFlag
BEQ.B readinstrloop
JSR ExitFromDir
readinstrloop
;JSR ShowSongName
TST.B NosamplesFlag
BNE.W rmiend
BSR.W CheckAbort
BEQ.W rmiend
BSR.W ShowSampleInfo
MOVE.W InsNum(PC),TuneUp
JSR DoShowFreeMem
BSR.W TurnOffVoices
MOVE.L SongDataPtr(PC),A0
MOVE.W InsNum(PC),D7
MULU.W #30,D7
MOVEQ #0,D0
MOVE.W 12(A0,D7.W),D0 ; sample length
BEQ.B rminext
MOVE.W 18(A0,D7.W),D5 ; sample loop length
ADD.L D0,D0
MOVE.L #MEMF_CHIP!MEMF_CLEAR,D1
MOVE.L D0,-(SP)
JSR PTAllocMem
MOVE.L (SP)+,D6
TST.L D0
BNE.B ReadModInstrument
BSR.W OutOfMemErr
MOVE.L DOSBase(PC),A6
MOVE.L FileHandle(PC),D1
MOVE.L D6,D2
MOVEQ #0,D3
BRA.B rminext
ReadModInstrument
MOVE.W InsNum(PC),D7
LSL.W #2,D7
LEA SongDataPtr(PC),A0
MOVE.L D0,(A0,D7.W)
MOVE.L D6,124(A0,D7.W)
MOVE.L DOSBase(PC),A6
MOVE.L FileHandle(PC),D1
MOVE.L D0,D2 ; 'read to' address
MOVE.L D6,D3 ; read length
JSR _LVORead(A6)
; PT2.3D change: clear first 2 bytes of non-looping samples (prevent beep)
CMP.W #1,D5 ; loop length
BHI.B rmiok ; loop deactivated, let's not modify!
MOVE.L D2,A0 ; sample data address
CLR.W (A0) ; clear first two bytes...
rmiok
; --END OF FIX------------------------------------------------------------
BSR.W RedrawSample
rminext ADDQ.W #1,InsNum
CMP.W #32,InsNum
BNE.W readinstrloop
rmiend MOVE.L FileHandle(PC),D1
MOVE.L DOSBase(PC),A6
JSR _LVOClose(A6)
TST.W TempPPFileFlag ; was our loaded MOD a temp PowerPacker file ?
BEQ.B rmiskip ; no, skip
MOVE.L DOSBase(PC),A6
MOVE.L #FileName,D1
MOVE.L D1,A0
JSR _LVODeleteFile(A6) ; delete temp PowerPacker file
rmiskip
MOVE.W #1,InsNum
MOVE.L #6,CurrSpeed
CLR.W LoadInProgress
BSR.W ShowAllRight
JSR SetNormalPtrCol
BSR.W CheckInstrLengths
BSR.W ShowSampleInfo
BSR.W RedrawSample
CLR.W TempPPFileFlag
JMP DoShowFreeMem
;---- PowerPacker routines -----
PowerPacked
LEA PowerPackedText(PC),A0
BSR.W ShowStatusText
JSR SetErrorPtrCol
BSR.W DoClearSong
BSR.W ClrSampleInfo
BRA.W rmiskip
UnpackPPFile
MOVE.W #1,TempPPFileFlag
LEA PowerPackedText(PC),A0
BSR.W ShowStatusText
BSR.W DoClearSong
BSR.W ClrSampleInfo
JSR DoShowFreeMem
MOVE.L FileHandle(PC),D1
MOVE.L DOSBase(PC),A6
JSR _LVOClose(A6)
MOVE.L PPLibBase(PC),D0
BNE.B uppfskip
LEA PPLibName(PC),A1
MOVE.L 4.W,A6
MOVEQ #0,D0
JSR _LVOOpenLibrary(A6)
MOVE.L D0,PPLibBase
BNE.B uppfskip
LEA PPLibErrorText(PC),A0
BRA.W uppferror
uppfskip
MOVE.L D0,A0
CMP.W #35,20(A0)
BGE.B uppfskip2
LEA MustHavePP35Text(PC),A0
BRA.W uppferror
uppfskip2
LEA FileName,A0
MOVEQ #2,D0
MOVE.L #MEMF_CLEAR!MEMF_CHIP,D1
MOVEA.W #-1,A3
LEA ppBufferPtr(PC),A1
LEA ppBufferLen(PC),A2
MOVE.L PPLibBase(PC),A6
JSR _LVOppLoadData(A6)
TST.L D0
BEQ.B uppfskip8
CMP.L #-1,D0
BNE.B uppfskip3
LEA CantOpenFileText(PC),A0
BRA.B uppferror
uppfskip3
CMP.L #-2,D0
BNE.B uppfskip4
LEA ReadErrorText(PC),A0
BRA.B uppferror
uppfskip4
CMP.L #-3,D0
BNE.B uppfskip5
LEA OutOfMemoryText(PC),A0
BRA.B uppferror
uppfskip5
CMP.L #-4,D0
BNE.B uppfskip6
LEA FileEncryptedText(PC),A0
BRA.B uppferror
uppfskip6
CMP.L #-6,D0
BNE.B uppfskip7
LEA WrongCruncherText(PC),A0
BRA.B uppferror
uppfskip7
LEA DecrunchErrorText(PC),A0
BRA.B uppferror
uppfskip8
MOVE.L DOSBase(PC),A6
MOVE.L #TempMODFileName,D1
MOVE.L #1006,D2
JSR _LVOOpen(A6)
MOVE.L D0,FileHandle
BNE.B uppfok
LEA DecrunchErrorText(PC),A0
uppferror
BSR.W ShowStatusText
JSR SetErrorPtrCol
MOVE.W #ERR_WAIT_TIME,WaitTime
JSR WaitALittle
TST.B AutoExitFlag
BEQ.B uppfskip9
JSR ExitFromDir
uppfskip9
BRA.W rmiskip
uppfok
MOVE.L FileHandle(PC),D1
MOVE.L ppBufferPtr(PC),D2
MOVE.L ppBufferLen(PC),D3
MOVE.L DOSBase(PC),A6
JSR _LVOWrite(A6)
CMP.L ppBufferLen(PC),D3
BEQ.B uppfskip10
LEA DiskErrorText(PC),A0
BSR.W ShowStatusText
;JSR PTScreenToFront (8bitbubsy: this causes issues on exit!)
JSR SetErrorPtrCol
uppfskip10
MOVE.L FileHandle(PC),D1
JSR _LVOClose(A6)
MOVE.L ppBufferPtr(PC),A1
MOVE.L ppBufferLen(PC),D0
MOVE.L 4.W,A6
JSR _LVOFreeMem(A6)
LEA TempMODFileName(PC),A0
LEA FileName,A1
MOVEQ #20-1,D0
uppfloop
MOVE.B (A0)+,(A1)+
DBRA D0,uppfloop
BRA.W LoadModule3
LoadCrunchedSample
BSR.W FreeSample
LEA PowerPackedText(PC),A0
BSR.W ShowStatusText
MOVE.L PPLibBase(PC),D0
BNE.B lbC00F168
LEA PPLibName(PC),A1
MOVE.L 4.W,A6
MOVEQ #0,D0
JSR _LVOOpenLibrary(A6)
MOVE.L D0,PPLibBase
BNE.B lbC00F168
LEA PPLibErrorText(PC),A0
BRA.W lbC00F246
lbC00F168
MOVE.L D0,A0
CMP.W #35,20(A0)
BGE.B lbC00F17C
LEA MustHavePP35Text(PC),A0
BRA.W lbC00F246
lbC00F17C
LEA FileName,A0
MOVEQ #2,D0
MOVE.L #MEMF_CLEAR!MEMF_CHIP,D1
MOVEA.W #-1,A3
LEA ppBufferPtr(PC),A1
LEA ppBufferLen(PC),A2
MOVE.L PPLibBase(PC),A6
JSR _LVOppLoadData(A6)
TST.L D0
BEQ.B lbC00F204
CMP.L #-1,D0
BNE.B lbC00F1BC
LEA CantOpenFileText(PC),A0
BRA.W lbC00F246
lbC00F1BC
CMP.L #-2,D0
BNE.B lbC00F1CC
LEA ReadErrorText(PC),A0
BRA.B lbC00F246
lbC00F1CC
CMP.L #-3,D0
BNE.B lbC00F1DC
LEA OutOfMemoryText(PC),A0
BRA.B lbC00F246
lbC00F1DC
CMP.L #-4,D0
BNE.B lbC00F1EC
LEA FileEncryptedText(PC),A0
BRA.B lbC00F246
lbC00F1EC
CMP.L #-6,D0
BNE.B lbC00F1FC
LEA WrongCruncherText(PC),A0
BRA.B lbC00F246
lbC00F1FC
LEA DecrunchErrorText(PC),A0
BRA.B lbC00F246
lbC00F204
LEA SongDataPtr(PC),A4
MOVEQ #0,D1
MOVE.W InsNum(PC),D1
LSL.W #2,D1
ADD.L D1,A4
MOVE.L ppBufferPtr(PC),D2
MOVE.L ppBufferLen(PC),D3
MOVE.L D2,(A4)
MOVE.L D3,124(A4)
MOVE.L D2,DiskDataPtr
MOVE.L D3,DiskDataLength
BSR.W SampleAllocOK
MOVE.L DiskDataPtr(PC),A0
MOVE.L DiskDataLength(PC),A1
BRA.W LoadSampleOK
lbC00F246
BSR.W ShowStatusText
JSR SetErrorPtrCol
MOVE.W #ERR_WAIT_TIME,WaitTime
JSR WaitALittle
RTS
; ---
CheckForPosEdNames
TST.B LoadNamesFlag
BEQ.B ClearPosEdNames
LEA LoadingNamesText(PC),A0
BSR.W ShowStatusText
JSR WaitALittle
LEA ModulesPath2,A0
JSR CopyPath
LEA DirInputName,A0
MOVE.B (A0)+,(A1)+
MOVE.B (A0)+,(A1)+
MOVE.B (A0)+,(A1)+
MOVE.B (A0)+,(A1)+
MOVE.B #$21,-1(A1)
MOVEQ #26-1,D0
cfpenloop
MOVE.B (A0)+,(A1)+
DBRA D0,cfpenloop
MOVE.L DOSBase(PC),A6
MOVE.L #FileName,D1
MOVE.L #1005,D2
JSR _LVOOpen(A6)
MOVE.L D0,FileHandle
BEQ.B lbC00F2EC
MOVE.L D0,D1
MOVE.L #PosEdNames,D2
MOVE.L #16*100,D3
JSR _LVORead(A6)
MOVE.L FileHandle(PC),D1
JSR _LVOClose(A6)
RTS
ClearPosEdNames
LEA PosEdNames(PC),A0
MOVE.L #(16*100)-1,D0
cpednloop MOVE.B #' ',(A0)+
DBRA D0,cpednloop
RTS
lbC00F2EC
BSR.B ClearPosEdNames
BRA.W CantOpenFile
lbC00F2F2
TST.B SaveNamesFlag
BEQ.W Return2
CMP.W #1,makeExeModFlag
BEQ.W Return2
LEA SavingNamesText(PC),A0
BSR.W ShowStatusText
JSR WaitALittle
LEA ModulesPath2,A0
JSR CopyPath
MOVE.B #'m',(A1)+
MOVE.B #'o',(A1)+
MOVE.B #'d',(A1)+
MOVE.B #'!',(A1)+
MOVE.L SongDataPtr(PC),A0
MOVEQ #20-1,D0
lbC00F338
MOVE.B (A0)+,(A1)+
DBRA D0,lbC00F338
TST.B ModPackMode
BEQ.B lbC00F362
LEA FileName,A0
lbC00F34C
TST.B (A0)+
BNE.B lbC00F34C
MOVE.B #'.',-1(A0)
MOVE.B #'p',(A0)+
MOVE.B #'p',(A0)+
MOVE.B #$00,(A0)
lbC00F362
MOVE.L DOSBase(PC),A6
MOVE.L #FileName,D1
MOVE.L #1006,D2
JSR _LVOOpen(A6)
MOVE.L D0,FileHandle
BEQ.W CantOpenFile
MOVE.L D0,D1
MOVE.L #PosEdNames,D2
MOVE.L #16*100,D3
JSR _LVOWrite(A6)
MOVE.L FileHandle(PC),D1
JSR _LVOClose(A6)
RTS
CNOP 0,4
ppBufferPtr dc.l 0
ppBufferLen dc.l 0
TempPPFileFlag dc.w 0
PowerPackedText dc.b 'Powerpacked File!',0
PPLibErrorText dc.b 'Cant open PP.lib!',0
MustHavePP35Text dc.b 'Needs version 35+',0
OutOfMemoryText dc.b 'Not Enough Memory',0
ReadErrorText dc.b 'Read Error! ',0
FileEncryptedText dc.b 'File is encrypted',0
WrongCruncherText dc.b 'Wrong Cruncher! ',0
DecrunchErrorText dc.b 'Decrunch Error! ',0
PPLibName dc.b 'libs:powerpacker.library',0
TempMODFileName dc.b 'RAM:Mod.TempFile',0
IconPathText dc.b 'Icons/Mod.'
IconExtText dc.b '.info',0
LoadingNamesText dc.b 'Loading names',0
SavingNamesText dc.b 'Saving names',0
EVEN
SaveModule
JSR StorePtrCol
JSR SetDiskPtrCol
BSR.W lbC00F2F2
JSR SetDiskPtrCol
TST.W lbW015B92
BEQ.W smoskip3
CMP.W #1,makeExeModFlag
BEQ.W smoskip3
MOVE.L #263,DiskDataLength
MOVE.L #exeDotInfoData,DiskDataPtr
LEA PTPath,A0
JSR CopyPath
LEA IconPathText(PC),A0
MOVEQ #10-1,D0
smoloop
MOVE.B (A0)+,(A1)+
DBRA D0,smoloop
MOVE.L SongDataPtr(PC),A0
MOVEQ #20-1,D0
smoloop2
MOVE.B (A0)+,D1
BEQ.B smoskip
MOVE.B D1,(A1)+
DBRA D0,smoloop2
smoskip
TST.B ModPackMode
BEQ.B smoskip2
MOVE.B #'.',(A1)+
MOVE.B #'p',(A1)+
MOVE.B #'p',(A1)+
smoskip2
LEA IconExtText(PC),A0
MOVEQ #6-1,D0
smoloop3
MOVE.B (A0)+,(A1)+
DBRA D0,smoloop3
LEA SavingIconText(PC),A0
BSR.W ShowStatusText
BSR.W OpenModForWrite
BNE.W CantOpenFile
BSR.W WriteModuleData
BNE.W WriteModError
BSR.W CloseWriteMod
smoskip3
MOVE.L SongDataPtr(PC),A0
LEA sd_pattpos(A0),A0
MOVEQ #0,D0
MOVEQ #0,D1
MOVEQ #0,D2
CLR.W HighPattNum
smoloop4
MOVE.B (A0,D0.W),D1
ADDQ.W #1,D0
CMP.W #128,D0
BHI.B DoSaveModule
MOVE.W HighPattNum(PC),D2
CMP.W D2,D1
BLS.B smoloop4
MOVE.W D1,HighPattNum
BRA.B smoloop4
DoSaveModule
LEA ModulesPath2,A0
JSR CopyPath
CMP.W #1,makeExeModFlag
BEQ.B dsmskip1
MOVE.B #'m',(A1)+
MOVE.B #'o',(A1)+
MOVE.B #'d',(A1)+
MOVE.B #'.',(A1)+
dsmskip1
MOVE.L SongDataPtr(PC),A0
MOVEQ #20-1,D0
dsmloop
MOVE.B (A0)+,(A1)+
DBRA D0,dsmloop
MOVE.L SongDataPtr(PC),A0
MOVE.L A0,DiskDataPtr
MOVE.L #1084,DiskDataLength
MOVEQ #0,D0
MOVE.W HighPattNum(PC),D0
ADDQ.L #1,D0
LSL.L #8,D0
LSL.L #2,D0
ADD.L D0,DiskDataLength ; Add 1024 x NumOfPatt
MOVE.B #127,sd_numofpatt+1(A0) ; Set maxpatt to 127
MOVE.L #'M.K.',sd_magicid(A0) ; M.K. again...
CMP.W #64,HighPattNum
BLO.B dsmskip2
MOVE.L #'M!K!',sd_magicid(A0) ; over 64 patterns...
dsmskip2
CMP.W #1,makeExeModFlag
BEQ.W WriteExeModule
TST.B ModPackMode
BEQ.W WriteModule
; Module Crunch (PAK)
LEA FileName,A0
dsmgetend
TST.B (A0)+
BNE.B dsmgetend
MOVE.B #'.',-1(A0)
MOVE.B #'p',(A0)+
MOVE.B #'p',(A0)+
MOVE.B #$00,(A0)
ShowModCrunchBox
JSR ClearFileNames
LEA CrunchBoxData,A1
LEA FormatBoxPos,A0
JSR DoSwapBox
BSR.W ShowCrunchModeTexts
LEA AreYouSureText(PC),A0
BSR.W ShowStatusText
dsmloop3
JSR CheckPatternRedraw2
JSR DoKeyBuffer
MOVE.B RawKeyCode(PC),D0
CMP.B #69,D0 ; ESC
BEQ.B AbortModCrunchBox
BTST #6,$BFE001 ; left mouse button
BNE.B dsmloop3
MOVE.W MouseX(PC),D0
MOVE.W MouseY(PC),D1
CMP.W #89,D0
BLO.B dsmloop3
CMP.W #212,D0
BHI.B dsmloop3
CMP.W #72,D1
BLO.B ModCrunchSettings
CMP.W #82,D1
BHI.B dsmloop3
CMP.W #136,D0
BLO.W DoModCrunch
CMP.W #166,D0
BLO.B dsmloop3
AbortModCrunchBox
LEA CrunchBoxData,A1
LEA FormatBoxPos,A0
JSR DoSwapBox
JSR ClearFileNames
LEA CrunchAbortedText,A0
BSR.W ShowStatusText
JMP SetErrorPtrCol
ModCrunchSettings
CMP.W #54,D1
BLO.B dsmloop3
CMP.W #136,D0
BLO.B ToggleModCrunchSpeed
CMP.W #166,D0
BLO.W dsmloop3
ADDQ.L #1,CrunchBufferMode
CMP.L #3,CrunchBufferMode
BNE.B mcsskip
CLR.L CrunchBufferMode
mcsskip
BSR.B ShowCrunchModeTexts
BRA.W dsmloop3
ToggleModCrunchSpeed
ADDQ.L #1,CrunchSpeed
CMP.L #5,CrunchSpeed
BNE.B tmcsskip
CLR.L CrunchSpeed
tmcsskip
BSR.B ShowCrunchModeTexts
BRA.W dsmloop3
ShowCrunchModeTexts
MOVE.L CrunchSpeed(PC),D0
LSL.L #3,D0
LEA CrunchSpeedText(PC),A0
ADD.L D0,A0
MOVEQ #8,D0
MOVE.W #$A33,D1
BSR.W ShowText3
MOVE.L CrunchBufferMode(PC),D0
MULU.W #6,D0
LEA CrunchBufferSizeText(PC),A0
ADD.L D0,A0
MOVEQ #6,D0
MOVE.W #2621,D1
BSR.W ShowText3
JSR WaitForButtonUp
RTS
CrunchSpeedText dc.b ' FAST MEDIOCRE GOOD VERYGOOD BEST '
CrunchBufferSizeText dc.b 'LARGE MEDIUMSMALL '
EVEN
DoModCrunch
LEA CrunchBoxData,A1
LEA FormatBoxPos,A0
JSR DoSwapBox
JSR ClearFileNames
CLR.L CrunchInfoPtr
MOVE.L TuneMemory,D0
MOVE.L #MEMF_CLEAR!MEMF_PUBLIC,D1
JSR PTAllocMem
MOVE.L D0,CrunchBufferPtr
BNE.B casmskip
BSR.W OutOfMemErr
BRA.W ModCrunchCleanup
casmskip
MOVE.L SongDataPtr(PC),A0
MOVE.L CrunchBufferPtr,A1
MOVE.L DiskDataLength(PC),D0
SUBQ.L #1,D0
casmloop
MOVE.B (A0)+,(A1)+
DBRA D0,casmloop
MOVEQ #1,D6
MOVE.L D6,D0
casmloop2
LSL.W #2,D0
LEA SongDataPtr(PC),A0
MOVE.L (A0,D0.W),D1
BEQ.B casmskip2
MOVE.L 124(A0,D0.W),D0
BEQ.B casmskip2
MOVE.L SongDataPtr(PC),A0
LEA 12(A0),A0
MOVE.W D6,D0
MULU.W #30,D0
ADD.L D0,A0
MOVEQ #0,D0
MOVE.W (A0),D0
ADD.L D0,D0
MOVE.L D1,A0
SUBQ.L #1,D0
casmloop3
MOVE.B (A0)+,(A1)+
DBRA D0,casmloop3
casmskip2
ADDQ.L #1,D6
MOVE.L D6,D0
CMP.L #32,D0
BNE.B casmloop2
MOVE.L PPLibBase(PC),D0
BNE.B casmskip3
LEA PPLibName(PC),A1
MOVE.L 4.W,A6
MOVEQ #0,D0
JSR _LVOOpenLibrary(A6)
MOVE.L D0,PPLibBase
BNE.B casmskip3
LEA PPLibErrorText(PC),A0
BRA.W ModCrunchError
casmskip3
MOVE.L D0,A6
CMP.W #35,20(A6)
BGE.B casmskip4
LEA MustHavePP35Text(PC),A0
BRA.W ModCrunchError
casmskip4
MOVE.L CrunchSpeed(PC),D0
MOVE.L CrunchBufferMode(PC),D1
LEA CrunchInterrupt(PC),A0
SUB.L A1,A1
MOVE.L PPLibBase(PC),A6
JSR _LVOppAllocCrunchInfo(A6)
MOVE.L D0,CrunchInfoPtr
BEQ.W ModCrunchOutOfMemory
LEA CrunchingText(PC),A0
CLR.L 12(A0)
BSR.W ShowStatusText
MOVE.L CrunchInfoPtr,A0
MOVE.L CrunchBufferPtr,A1
MOVE.L TuneMemory,D0
MOVE.L PPLibBase(PC),A6
JSR _LVOppCrunchBuffer(A6)
LEA CrunchAbortedText,A0
TST.L D0
BEQ.W ModCrunchError
LEA BufOverflowText,A0
CMP.L #-1,D0
BEQ.W ModCrunchError
MOVE.L D0,CrunchBufferLen
MOVE.L #FileName,D1
MOVE.L #1006,D2
MOVE.L DOSBase(PC),A6
JSR _LVOOpen(A6)
MOVE.L D0,FileHandle
BNE.B casmskip5
LEA CantOpenFileText(PC),A0
BSR.W ShowStatusText
BRA.W ModCrunchCleanup
casmskip5
LEA CrunchGainText(PC),A0
BSR.W ShowStatusText
MOVE.L CrunchBufferLen,D1
MOVE.L TuneMemory,D2
casmloop4
CMP.L #$FFFF,D2
BLE.B casmskip6
LSR.L #1,D2
LSR.L #1,D1
BRA.B casmloop4
casmskip6
MULU.W #100,D1
DIVU.W D2,D1
NEG.W D1
ADD.W #100,D1
MOVE.W D1,WordNumber
MOVE.W #5139,TextOffset
BSR.W Print3DecDigits
MOVE.W #ERR_WAIT_TIME,WaitTime
JSR WaitALittle
LEA SavingModuleText(PC),A0
BSR.W ShowStatusText
MOVE.L FileHandle(PC),D0
MOVE.L CrunchSpeed(PC),D1
MOVEQ #0,D2
MOVEQ #0,D3
MOVE.L PPLibBase(PC),A6
JSR _LVOppWriteDataHeader(A6)
MOVE.L FileHandle(PC),D1
MOVE.L CrunchBufferPtr,D2
MOVE.L CrunchBufferLen,D3
MOVE.L DOSBase(PC),A6
JSR _LVOWrite(A6)
CMP.L CrunchBufferLen,D3
BEQ.B casmskip7
BSR.W CantSaveFile
casmskip7
MOVE.L FileHandle(PC),D1
MOVE.L DOSBase(PC),A6
JSR _LVOClose(A6)
ModCrunchCleanup
TST.L CrunchInfoPtr
BEQ.B mccskip
MOVE.L CrunchInfoPtr,A0
MOVE.L PPLibBase(PC),A6
JSR _LVOppFreeCrunchInfo(A6)
mccskip
MOVE.L CrunchBufferPtr,D1
BEQ.B mccskip2
MOVE.L D1,A1
MOVE.L TuneMemory,D0
JSR PTFreeMem
mccskip2
JSR SetNormalPtrCol
BSR.W ShowAllRight
JMP DoAutoDir
ModCrunchError
BSR.W ShowStatusText
JSR SetErrorPtrCol
MOVE.W #ERR_WAIT_TIME,WaitTime
JSR WaitALittle
BRA.B ModCrunchCleanup
ModCrunchOutOfMemory
LEA NoBufMemText,A0
BSR.W ShowStatusText
MOVE.W #ERR_WAIT_TIME,WaitTime
JSR WaitALittle
LEA ChooseSmallerText,A0
BSR.W ShowStatusText
MOVE.W #ERR_WAIT_TIME,WaitTime
JSR WaitALittle
MOVE.L CrunchBufferPtr,D1
BEQ.B mcoomskip
MOVE.L D1,A1
MOVE.L TuneMemory,D0
JSR PTFreeMem
mcoomskip
BRA.W ShowModCrunchBox
CrunchInterrupt ; periodically called while crunching
MOVEM.L D0-D7/A0-A6,RegBackup
MOVE.L (SP)+,D4
MOVEM.L (SP),D0-D3
MOVE.L D4,-(SP)
cruiloop
CMP.L #$FFFF,D2
BLE.B cruiskip
LSR.L #1,D2
LSR.L #1,D1
LSR.L #1,D0
BRA.B cruiloop
cruiskip
MULU.W #100,D0
DIVU.W D2,D0
MOVE.W #5143,TextOffset
MOVE.W D0,WordNumber
BSR.W Print3DecDigits
LEA PercentText(PC),A0
MOVE.W #1,TextLength
BSR.W ShowText2
MOVEQ #-1,D0
BTST #6,$BFE001 ; left mouse button
BNE.B cruiskip2
LEA CrunchingText(PC),A0
CLR.L 12(A0)
MOVEM.L RegBackup(PC),D0-D7/A0-A6
MOVEQ #0,D0
RTS
cruiskip2
JSR CheckPatternRedraw2
MOVEM.L RegBackup(PC),D0-D7/A0-A6
RTS
CNOP 0,4
RegBackup dcb.l 15 ; 8*4 + 7*4 [D0-D7/A0-A6]
CrunchSpeed dc.l 0
CrunchBufferMode dc.l 0
CrunchGainText dc.b 'Gain... %',0
EVEN
WriteExeModule
LEA FileName,A0
seloop
TST.B (A0)+
BNE.B seloop
MOVE.B #'.',-1(A0)
MOVE.B #'e',(A0)+
MOVE.B #'x',(A0)+
MOVE.B #'e',(A0)+
MOVE.B #0,(A0)
MOVE.L SongDataPtr(PC),A0
LEA exeReplayData(PC),A1
LEA 145(A1),A1
MOVEQ #19-1,D1
seloop2
MOVE.B (A0)+,(A1)+
DBRA D1,seloop2
MOVE.L SongDataPtr(PC),A0
LEA sd_sampleinfo(A0),A0
LEA exeReplayData(PC),A1
LEA 175(A1),A1
MOVEQ #21-1,D1
seloop3
MOVE.B (A0)+,(A1)+
DBRA D1,seloop3
LEA exeReplayData(PC),A0
MOVE.L TuneMemory,D1
ADD.L #5080,D1
MOVE.L D1,D2
LSR.L #2,D1
BTST #1,D2
BEQ.B seskip
ADDQ.L #1,D1
ADDQ.L #2,DiskDataLength
seskip
MOVE.L D1,28(A0)
ADD.L #$40000000,D1
MOVE.L D1,sd_sampleinfo(A0)
WriteModule
LEA SavingModuleText(PC),A0
BSR.W ShowStatusText
BTST #2,$DFF016 ; right mouse button
BEQ.W CantOpenFile
BSR.W OpenModForWrite
BNE.W CantOpenFile
CMP.W #1,makeExeModFlag
BNE.B wmskip1
MOVE.L FileHandle(PC),D1
MOVE.L #exeReplayData,D2
MOVE.L #5112,D3
JSR _LVOWrite(A6)
CMP.L #5112,D3
BNE.W WriteModError
wmskip1
BSR.W WriteModuleData
BNE.B WriteModError
BTST #2,$DFF016 ; right mouse button
BEQ.B WriteModError
MOVE.W InsNum(PC),SaveInstrNum
MOVEQ #1,D6
saveinstrloop
MOVE.W D6,InsNum
BSR.W ShowSampleInfo
BSR.B WriteInstrument
TST.L D0
BNE.B WriteModError
ADDQ.B #1,D6
CMP.B #32,D6
BNE.B saveinstrloop
CMP.W #1,makeExeModFlag
BNE.B wmskip2
CLR.W makeExeModFlag
MOVE.L FileHandle(PC),D1
MOVE.L #exeReplayRelocHunk,D2
MOVE.L #304,D3
JSR _LVOWrite(A6)
CMP.L #304,D3
BNE.B WriteModError
wmskip2
BSR.W CloseWriteMod
MOVE.W SaveInstrNum(PC),InsNum
BSR.W ShowSampleInfo
BSR.W ShowAllRight
JSR RestorePtrCol
JMP DoAutoDir
SaveInstrNum dc.w 0
WriteModError
BSR.W CloseWriteMod
BRA.W CantSaveFile
WriteInstrument
MOVE.W D6,D0
LSL.W #2,D0
LEA SamplePtrs(PC),A0
MOVE.L (A0,D0.W),D1
BEQ.B wrinskip
MOVE.L 124(A0,D0.W),D0
BEQ.W Return3
MOVE.L D1,DiskDataPtr
MOVE.L SongDataPtr(PC),A0
LEA 12(A0),A0
MOVE.W D6,D0
MULU.W #30,D0
ADD.L D0,A0
MOVEQ #0,D0
MOVE.W (A0),D0
ADD.L D0,D0
MOVE.L D0,DiskDataLength
BNE.B WriteModuleData
RTS
wrinskip
MOVEQ #0,D0
RTS
OpenModForWrite
MOVE.L DOSBase(PC),A6
MOVE.L #FileName,D1
MOVE.L #1006,D2
JSR _LVOOpen(A6)
MOVE.L D0,FileHandle
BEQ.B wmfailed
MOVEQ #0,D0
RTS
WriteModuleData
MOVE.L DOSBase(PC),A6
MOVE.L FileHandle(PC),D1
MOVE.L DiskDataPtr(PC),D2
MOVE.L DiskDataLength(PC),D3
BEQ.B .okok
JSR _LVOWrite(A6)
CMP.L DiskDataLength(PC),D3
BNE.B wmfailed
MOVEQ #0,D0
.okok RTS
wmfailed
MOVEQ #-1,D0
RTS
CloseWriteMod
MOVE.L DOSBase(PC),A6
MOVE.L FileHandle(PC),D1
JMP _LVOClose(A6)
;---- Load PLST ----
LoadPLST
LEA LoadPLSTText(PC),A0
JSR AreYouSure
BNE.W Return3
JSR WaitForButtonUp
LEA LoadingPLSTText(PC),A0
BSR.W ShowStatusText
DoLoadPLST
JSR StorePtrCol
LEA PTPath,A0
JSR CopyPath
LEA PLSTname(PC),A0
MOVEQ #5-1,D0
dlploop MOVE.B (A0)+,(A1)+
DBRA D0,dlploop
MOVE.L #FileName,D1
MOVE.L #1005,D2
MOVE.L DOSBase(PC),A6
JSR _LVOOpen(A6)
MOVE.L D0,D7
BEQ.W PLSTOpenErr
JSR SetDiskPtrCol
CLR.L PresetTotal
BSR.B AllocPLST
MOVE.L PLSTmem(PC),D2
BEQ.W PLSTMemErr2
MOVE.L D7,D1
MOVE.L PLSTAllocSize(PC),D3
MOVE.L DOSBase(PC),A6
JSR _LVORead(A6)
MOVE.L D0,MaxPLSTOffset
DIVU.W #30,D0
MOVE.W D0,PresetTotal
cloplst MOVE.L D7,D1
MOVE.L DOSBase(PC),A6
JSR _LVOClose(A6)
BSR.W PLSTCheckNum
BSR.W ShowAllRight
JMP RestorePtrCol
PLSTname dc.b 'PLST',0
EVEN
AllocPLST
BSR.B FreePLST
MOVE.W MaxPLSTEntries,D0
BEQ.W Return3
MULU.W #30,D0
MOVE.L D0,PLSTAllocSize
MOVE.L #MEMF_CLEAR,D1
JSR PTAllocMem
MOVE.L D0,PLSTmem
MOVE.W MaxPLSTEntries,MaxPLSTEntries2
RTS
FreePLST
CLR.W MaxPLSTEntries2
CLR.L MaxPLSTOffset
CLR.W PresetTotal
MOVE.L PLSTmem(PC),D0
BEQ.W Return3
MOVE.L D0,A1
MOVE.L PLSTAllocSize(PC),D0
JSR PTFreeMem
CLR.L PLSTmem
RTS
PLSTMemErr2
BSR.B PLSTMemErr
BRA.W cloplst
PLSTMemErr
TST.W MaxPLSTEntries
BEQ.B reptrco
BSET #0,InitError
LEA PLSTMemText(PC),A0
plster BSR.W ShowStatusText
MOVE.W #ERR_WAIT_TIME,WaitTime
JMP ErrorRestoreCol
reptrco JMP RestorePtrCol
PLSTOpenErr
TST.W MaxPLSTEntries
BEQ.B reptrco
BSET #1,InitError
LEA PLSTOpenText(PC),A0
BRA.B plster
RTS
PLSTMemText dc.b 'no mem for plst !',0
PLSTOpenText dc.b 'plst not found ! ',0
EVEN
ShowAllRight
MOVEM.L D0-D7/A0-A6,-(SP)
LEA AllRightText(PC),A0
BSR.W ShowStatusText
MOVEM.L (SP)+,D0-D7/A0-A6
RTS
ShowStatusText
MOVEM.L D0/D1/A1,-(SP)
LEA TextBitplane+5131,A1
MOVEQ #5-1,D0
stloop1 MOVEQ #17-1,D1
stloop2 CLR.B (A1)+
DBRA D1,stloop2
LEA 23(A1),A1
DBRA D0,stloop1
MOVE.L A0,A1
MOVE.W #5131,D1
MOVEQ #-1,D0
stloop3 ADDQ.W #1,D0
TST.B (A1)+
BNE.B stloop3
BSR.W ShowText3
MOVEM.L (SP)+,D0/D1/A1
RTS
;---- Redraw Pattern ----
RedrawPattern
TST.W SamScrEnable
BNE.W Return3
SF PattRfsh
MOVE.W #5121,TextOffset
MOVE.W PatternNumber+2(PC),WordNumber
BSR.W Print2DecDigits ; Print PatternNumber
MOVE.L SongDataPtr(PC),A6
LEA $043C(A6),A6
MOVE.L PatternNumber(PC),D6
LSL.L #8,D6
LSL.L #2,D6
ADD.L D6,A6
MOVE.W #7521,TextOffset
CLR.W PPattPos
LEA RedrawBuffer(PC),A3
LEA FastHexTable(PC),A4
MOVE.L NoteNamesPtr(PC),A5
MOVE.L #Period2Note,D4
MOVE.B BlankZeroFlag,D5
MOVEQ #64-1,D6 ; row counter
rpnxpos MOVEQ #4-1,D7 ; channel counter
MOVE.W PPattPos(PC),WordNumber
ADDQ.W #1,PPattPos
BSR.W Print2DecDigits ; Print PatternPosition
ADDQ.W #1,TextOffset
rploop
; convert period to note number string
MOVE.W (A6),D1
AND.W #$0FFF,D1 ; D1.W = period
BNE.B rpfind
MOVE.L #'--- ',(A3)
BRA.B rpskip2
rpfind MOVEQ #0,D0
SUB.W #113,D1
BLT.W rplo
CMP.W #856-113,D1
BHI.B rpskip1
MOVE.L D4,A1 ; A1 = Period2Note
MOVE.B (A1,D1.W),D0 ; note*4, for NoteNamesPtr (A0) dword look-up
rpskip1 MOVE.L (A5,D0.W),(A3)
rpskip2
MOVE.B (A6)+,D0
LSR.B #4,D0
AND.B #$01,D0 ; --PT2.3D bug fix: mask high nybble of sample num for broken MODs
ADD.B #'0',D0
MOVE.B D0,3(A3)
ADDQ #1,A6 ; skip byte
MOVEQ #0,D0
MOVE.B (A6)+,D0
ADD.W D0,D0
MOVE.W (A4,D0.W),4(A3)
MOVEQ #0,D0
MOVE.B (A6)+,D0
ADD.W D0,D0
MOVE.W (A4,D0.W),6(A3)
TST.B D5 ; BlankZeroFlag set?
BEQ.B rpskp3
CMP.B #'0',3(A3)
BNE.B rpskp3
MOVE.B #' ',3(A3)
rpskp3
; 8bitbubsy: print note data (slightly faster than calling ShowText)
LEA TextBitplane,A1
ADD.W TextOffset(PC),A1
MOVE.L #FontData,D2
LEA FontDataOffsets(PC),A0
MOVE.L A3,ShowTextPtr
MOVEQ #(8/2)-1,D1 ; 2x loop unroll
rploop2 MOVEQ #0,D0
MOVE.B (A3)+,D0
ADD.W D0,D0
MOVE.W (A0,D0.W),A2
ADD.L D2,A2
MOVE.B (A2)+,(A1)+
MOVE.B (A2)+,40-1(A1)
MOVE.B (A2)+,80-1(A1)
MOVE.B (A2)+,120-1(A1)
MOVE.B (A2),160-1(A1)
MOVEQ #0,D0
MOVE.B (A3)+,D0
ADD.W D0,D0
MOVE.W (A0,D0.W),A2
ADD.L D2,A2
MOVE.B (A2)+,(A1)+
MOVE.B (A2)+,40-1(A1)
MOVE.B (A2)+,80-1(A1)
MOVE.B (A2)+,120-1(A1)
MOVE.B (A2),160-1(A1)
DBRA D1,rploop2
ADD.W #8+1,TextOffset
SUBQ #8,A3
DBRA D7,rploop ; Next Channel
ADD.W #241,TextOffset
DBRA D6,rpnxpos ; Next PattPos
RTS
rplo MOVE.L #'??? ',(A3)
BRA.W rpskip2
CNOP 0,4
RedrawBuffer dc.b '---00000'
EVEN
ShowPosition
MOVE.L SongDataPtr(PC),A0
LEA 952(A0),A0
ADD.L CurrPos(PC),A0
MOVEQ #0,D1
MOVE.B (A0),D1
MOVE.W D1,WordNumber
TST.W CurrScreen
BEQ.B spokok
CMP.W #1,CurrScreen
BEQ.B spokok
CMP.W #6,CurrScreen
BEQ.B spokok
CMP.W #8,CurrScreen
BEQ.B spokok
RTS
spokok MOVE.W #$260,TextOffset
BSR.W Print4DecDigits
MOVE.W CurrPos+2(PC),WordNumber
MOVE.W #$A8,TextOffset
BRA.W Print4DecDigits
ShowSongLength CMP.W #2,CurrScreen
BEQ.B ShowSongName
CMP.W #3,CurrScreen
BEQ.B ShowSongName
CMP.W #4,CurrScreen
BEQ.W Return3
CMP.W #5,CurrScreen
BEQ.B ShowSongName
MOVE.L SongDataPtr(PC),A0
LEA sd_numofpatt(A0),A0
MOVE.L A0,CurrCmds
CLR.W WordNumber
MOVE.B (A0),WordNumber+1
MOVE.W #$418,TextOffset
BSR.W Print4DecDigits
MOVE.L CurrCmds(PC),A0
ShowSongName MOVE.L SongDataPtr(PC),A0
MOVE.W #$1025,D1
MOVEQ #$14,D0
BRA.W ShowText3
ShowSampleInfo
MOVEQ #0,D0
MOVE.W InsNum(PC),D0
MOVE.W D0,PlayInsNum
BNE.B ssiskipit
MOVE.W LastInsNum(PC),D0
ssiskipit
MOVE.W D0,D1
LSL.L #2,D0
LEA SongDataPtr(PC),A0
MOVE.L (A0,D0.W),si_pointer
MOVE.L SongDataPtr(PC),A0
LEA -10(A0),A0
MOVE.W D1,D0
MULU.W #30,D0
ADD.L D0,A0
MOVE.L A0,CurrCmds
MOVE.L 22(A0),SampleInfo
MOVE.L 26(A0),si_long
TST.B NoSampleInfo
BNE.W ssiskip
MOVE.L A0,-(SP)
MOVE.B #' ',FineTuneSign
MOVE.B 24(A0),D0
BEQ.B dopfitu
MOVE.B #'+',FineTuneSign
BTST #3,D0
BEQ.B dopfitu
MOVE.B #'-',FineTuneSign
MOVEQ #16,D1
SUB.B D0,D1
MOVE.B D1,D0
dopfitu MOVE.W #1491,TextOffset
BSR.W PrintHexDigit ; FineTune
LEA FineTuneSign(PC),A0
MOVE.W #1490,D1
MOVEQ #1,D0
BSR.W ShowText3 ; FineTuneSign
MOVE.L (SP)+,A0
CLR.W WordNumber
MOVE.B 25(A0),WordNumber+1
MOVE.W WordNumber(PC),VolumeEfx
OR.W #$0C00,VolumeEfx
MOVE.W #$940,TextOffset
BSR.W PrintHexWord ; Volume
MOVEQ #0,D0
MOVE.W SampleInfo(PC),D0
ADD.L D0,D0
MOVE.L D0,LongWordNumber
MOVE.L SamplePos(PC),D2
CMP.L D0,D2
BLS.B ShowLen
MOVE.L D0,SamplePos
BSR.W ShowPos
MOVEQ #0,D0
MOVE.W SampleInfo(PC),D0
ADD.L D0,D0
MOVE.L D0,LongWordNumber
ShowLen MOVE.W #2807,TextOffset
BSR.W Print5HexDigits ; Length
BSR.W CalculateChordLen
MOVEQ #0,D0
MOVE.W si_long(PC),D0
ADD.L D0,D0
MOVE.L D0,LongWordNumber
MOVE.W #3247,TextOffset
BSR.W Print5HexDigits ; Repeat
MOVEQ #0,D0
MOVE.W si_long+2(PC),D0
ADD.L D0,D0
MOVE.L D0,LongWordNumber
MOVE.W #3687,TextOffset
BSR.W Print5HexDigits ; RepLen
BSR.W ssiinst
ssiskip TST.B NoSampleInfo
BEQ.B ssiskp2
CMP.W #5,CurrScreen
BEQ.B ssiskp2
CMP.W #7,CurrScreen
BEQ.B ssiskp2
CMP.W #3,CurrScreen
BNE.W Return3
ssiskp2 MOVE.L CurrCmds(PC),A0
BSR.B lbC010290
MOVE.W #4573,D1
MOVEQ #22,D0
BRA.W ShowText3 ; SampleName
lbC010290
MOVE.L A0,A1
MOVEQ #22-1,D7
lbC010298
CMP.B #'.',(A1)+
BEQ.B lbC0102A4
DBRA D7,lbC010298
RTS
lbC0102A4
TST.L D7
BEQ.B lbC0102E6
CMP.B #'p',(A1)
BNE.B lbC0102EE
ADDQ #1,A1
SUBQ.L #1,D7
TST.L D7
BEQ.B lbC0102E0
CMP.B #'p',(A1)
BNE.B lbC0102EE
ADDQ #1,A1
SUBQ.L #1,D7
TST.L D7
BEQ.B lbC0102DA
TST.B (A1)
BNE.B lbC0102EE
lbC0102DA
CLR.B -3(A1)
lbC0102E0
CLR.B -2(A1)
lbC0102E6
CLR.B -1(A1)
RTS
lbC0102EE
SUBQ.L #1,D7
BEQ.W Return2
BRA.B lbC010298
ssiinst
TST.B NoSampleInfo
BNE.W Return3
MOVE.W InsNum(PC),WordNumber
MOVE.W #1928,TextOffset
BRA.W PrintHexWord ; SampleNumber
VolumeEfx dc.w 0
FineTuneSign dc.b ' '
EVEN
;---- Print Decimal Digits ----
Print2DecDigits ; 8bb: optimized
; we can safely trash D0/D1/A0/A1
MOVE.L A2,-(SP)
MOVE.W WordNumber(PC),D0
CMP.W #99,D0
BLS.B .OK
MOVEQ #99,D0
.OK ADD.W D0,D0 ; *2 for LUT index
MOVEQ #0,D1
LEA FontData,A2
MOVE.B (FastTwoDecTable+0,PC,D0.W),D1
LEA (A2,D1.W),A0
MOVE.B (FastTwoDecTable+1,PC,D0.W),D1
LEA (A2,D1.W),A1
LEA TextBitplane,A2
ADD.W TextOffset(PC),A2
ADDQ.W #2,TextOffset
MOVE.B (A0)+,(A2)+
MOVE.B (A0)+,40-1(A2)
MOVE.B (A0)+,80-1(A2)
MOVE.B (A0)+,120-1(A2)
MOVE.B (A0),160-1(A2)
MOVE.B (A1)+,(A2)+
MOVE.B (A1)+,40-1(A2)
MOVE.B (A1)+,80-1(A2)
MOVE.B (A1)+,120-1(A2)
MOVE.B (A1),160-1(A2)
MOVE.L (SP)+,A2
RTS
; (("00" .. "99" (split into two bytes)) - 32) * 8
FastTwoDecTable
dc.w $8080,$8088,$8090,$8098,$80A0,$80A8,$80B0,$80B8
dc.w $80C0,$80C8,$8880,$8888,$8890,$8898,$88A0,$88A8
dc.w $88B0,$88B8,$88C0,$88C8,$9080,$9088,$9090,$9098
dc.w $90A0,$90A8,$90B0,$90B8,$90C0,$90C8,$9880,$9888
dc.w $9890,$9898,$98A0,$98A8,$98B0,$98B8,$98C0,$98C8
dc.w $A080,$A088,$A090,$A098,$A0A0,$A0A8,$A0B0,$A0B8
dc.w $A0C0,$A0C8,$A880,$A888,$A890,$A898,$A8A0,$A8A8
dc.w $A8B0,$A8B8,$A8C0,$A8C8,$B080,$B088,$B090,$B098
dc.w $B0A0,$B0A8,$B0B0,$B0B8,$B0C0,$B0C8,$B880,$B888
dc.w $B890,$B898,$B8A0,$B8A8,$B8B0,$B8B8,$B8C0,$B8C8
dc.w $C080,$C088,$C090,$C098,$C0A0,$C0A8,$C0B0,$C0B8
dc.w $C0C0,$C0C8,$C880,$C888,$C890,$C898,$C8A0,$C8A8
dc.w $C8B0,$C8B8,$C8C0,$C8C8
Print3DecDigits
MOVE.W #3,TextLength
MOVEQ #0,D1
MOVE.W WordNumber(PC),D1
LEA NumberText(PC),A0
BRA.B pdig100
Print4DecDigits
MOVE.W #4,TextLength
MOVEQ #0,D1
MOVE.W WordNumber(PC),D1
LEA NumberText(PC),A0
DIVU.W #1000,D1
BSR.B DoOneDigit
pdig100 DIVU.W #100,D1
BSR.B DoOneDigit
pdig DIVU.W #10,D1
BSR.B DoOneDigit
BSR.B DoOneDigit
LEA NumberText(PC),A0
BRA.W ShowText2
DoOneDigit
ADD.B #'0',D1
MOVE.B D1,(A0)+
CLR.W D1
SWAP D1
RTS
Print6DecDigits ; fixed in PT2.3E to display big numbers correctly
LEA NumberText(PC),A0
; if number is zero, draw " 0"
TST.L D0
BNE.B p6ddskip
MOVE.B #'0',5(A0)
MOVE.B #' ',4(A0)
MOVE.B #' ',3(A0)
MOVE.B #' ',2(A0)
MOVE.B #' ',1(A0)
MOVE.B #' ',(A0)
BRA.W p6ddok
; number is not zero, let's do some math!
p6ddskip
MOVE.L D0,D1
CMP.L #1000000,D1
BHS.W toobig
; number is 0...999999
MOVEQ #0,D2
DIVU.W #1000,D1
SWAP D1
MOVE.W D1,D2
CLR.W D1
SWAP D1
; D1 = first 3 digits
; D2 = last 3 digits
DIVU.W #10,D2 ; sixth digit
SWAP D2
ADD.B #'0',D2
MOVE.B D2,5(A0)
CLR.W D2
SWAP D2
DIVU.W #10,D2 ; fifth digit
SWAP D2
ADD.B #'0',D2
MOVE.B D2,4(A0)
CLR.W D2
SWAP D2
DIVU.W #10,D2 ; fourth digit
SWAP D2
ADD.B #'0',D2
MOVE.B D2,3(A0)
CLR.W D2
SWAP D2
DIVU.W #10,D1 ; third digit
SWAP D1
ADD.B #'0',D1
MOVE.B D1,2(A0)
CLR.W D1
SWAP D1
DIVU.W #10,D1 ; second digit
SWAP D1
ADD.B #'0',D1
MOVE.B D1,1(A0)
CLR.W D1
SWAP D1
DIVU.W #10,D1 ; first digit
SWAP D1
ADD.B #'0',D1
MOVE.B D1,(A0)
; replace zeroes to the left with space
MOVE.L A0,A1
.loop CMP.B #'0',(A1)
BNE.B p6ddok
MOVE.B #' ',(A1)+
BRA.B .loop
p6ddok MOVE.W #6,TextLength
BRA ShowText2
toobig ; number is >999999. divide by 1000, then display space + 4 digits + 'K' at end
CMP.L #9999999,D0
BHI.B toobigoverflow
MOVE.L D0,-(SP)
MOVE.B #' ',D0 ; print space
BSR.B printch
MOVE.L (SP)+,D0
DIVU.W #1000,D0
MOVE.W D0,WordNumber
BSR Print4DecDigits
MOVE.B #'K',D0
printch LEA NumberText(PC),A0
MOVE.B D0,(A0)
MOVE.W #1,TextLength
BRA.W ShowText2
toobigoverflow
MOVE.B #'>',D0
BSR.B printch
MOVE.W #9999,WordNumber
BSR Print4DecDigits
MOVE.B #'K',D0
BRA.B printch
CNOP 0,4
NumberText dcb.b 6,0
EVEN
;---- Print Hex Digits ----
PrintHiInstrNum
MOVEQ #0,D0
TST.W CurrentPlayNote
BEQ.B phin2
MOVE.W InsNum(PC),D0
LSR.W #4,D0
BNE.B PrintHexDigit
phin2 TST.B BlankZeroFlag
BEQ.B PrintHexDigit
LEA BlankInsText(PC),A0
BRA.B phd2
PrintHexDigit AND.L #15,D0
ADD.L D0,D0
LEA FastHexTable+1(PC),A0
ADD.L D0,A0
phd2 MOVE.W #1,TextLength
BRA.W ShowText2
BlankInsText dc.b " "
EVEN
; this routine was coded by h0ffman and edited by 8bitbubsy
Print5HexDigits
MOVE.L D1,-(SP)
MOVE.L D7,-(SP)
LEA LongWordNumber(PC),A0
MOVE.L (A0),D0
LEA HexString+5(PC),A0 ; 4 (+1 for pre-sub suffix)
MOVEQ #5-1,D7
.hexlp MOVE.B D0,D1
AND.B #$0F,D1
CMP.B #9,D1
BLE.B .dec
ADDQ.B #7,D1
.dec ADD.B #'0',D1
MOVE.B D1,-(A0)
LSR.L #4,D0
DBRA D7,.hexlp
MOVE.L (SP)+,D7
MOVE.L (SP)+,D1
LEA HexString(PC),A0
MOVE.W #5,TextLength
BSR.B ShowText2
CLR.L LongWordNumber
RTS
HexString dc.b "00000"
EVEN
; ---------------------------------------------------------------
PrintHexWord
LEA WordNumber(PC),A0
MOVEQ #0,D0
MOVE.B (A0),D0
ADD.W D0,D0
LEA FastHexTable(PC),A0
ADD.W D0,A0
MOVE.W #2,TextLength
BSR.W ShowText2
PrintHexByte
LEA WordNumber(PC),A0
MOVEQ #0,D0
MOVE.B 1(A0),D0
ADD.W D0,D0
LEA FastHexTable(PC),A0
ADD.W D0,A0
MOVE.W #2,TextLength
BSR.B ShowText2
CLR.W WordNumber
RTS
;---- Text Output Routines ----
ShowText3
MOVE.W D0,TextLength
MOVE.W D1,TextOffset
ShowText2
MOVE.L A0,ShowTextPtr
ShowText
MOVEM.L A2-A4,-(SP)
LEA FontData,A4
LEA FontDataOffsets(PC),A3
MOVE.W TextLength(PC),D0
LEA TextBitplane,A1
ADD.W TextOffset(PC),A1
ADD.W D0,TextOffset
MOVE.L ShowTextPtr(PC),A0
SUBQ.W #1,D0
.loop MOVEQ #0,D1
MOVE.B (A0)+,D1
ADD.W D1,D1
MOVE.W (A3,D1.W),A2
ADD.L A4,A2
MOVE.B (A2)+,(A1)+
MOVE.B (A2)+,40-1(A1)
MOVE.B (A2)+,80-1(A1)
MOVE.B (A2)+,120-1(A1)
MOVE.B (A2),160-1(A1)
DBRA D0,.loop
MOVEM.L (SP)+,A2-A4
RTS
SpaceShowText
MOVEM.L A2-A4,-(SP)
LEA FontData,A4
LEA FontDataOffsets(PC),A3
MOVE.W TextLength(PC),D0
LEA TextBitplane,A1
ADD.W TextOffset(PC),A1
ADD.W D0,TextOffset
MOVE.L ShowTextPtr(PC),A0
SUBQ.W #1,D0
.loop MOVEQ #0,D1
MOVE.B (A0)+,D1
BNE.B .skip
MOVEQ #' ',D1
.skip ADD.W D1,D1
MOVE.W (A3,D1.W),A2
ADD.L A4,A2
MOVE.B (A2)+,(A1)+
MOVE.B (A2)+,40-1(A1)
MOVE.B (A2)+,80-1(A1)
MOVE.B (A2)+,120-1(A1)
MOVE.B (A2),160-1(A1)
DBRA D0,.loop
MOVEM.L (SP)+,A2-A4
RTS
FontDataOffsets
dc.w 504, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
dc.w 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
dc.w 0, 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96,104,112,120
dc.w 128,136,144,152,160,168,176,184,192,200,208,216,224,232,240,248
dc.w 256,264,272,280,288,296,304,312,320,328,336,344,352,360,368,376
dc.w 384,392,400,408,416,424,432,440,448,456,464,472,480,488,496,504
dc.w 552,264,272,280,288,296,304,312,320,328,336,344,352,360,368,376
dc.w 384,392,400,408,416,424,432,440,448,456,464,520,528,536,544,504
dc.w 552,560, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
dc.w 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
dc.w 0,512, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
dc.w 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
dc.w 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
dc.w 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
dc.w 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
dc.w 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
;---- Set Sprite Position ----
SetSpritePos
ADD.W #44,D1
ADD.W D1,D2
ROL.W #7,D2
ADD.W D2,D2
BCC.B sppskip
OR.W #2,D2
sppskip ROL.W #7,D1
ADD.W D1,D1
BCC.B sppskip2
OR.W #4,D2
sppskip2
ADD.W #125,D0
TST.B ScreenAdjustFlag
BEQ.B sppskip3
SUB.W #16,D0
sppskip3
ASR.W #1,D0
BHS.B sppskip4
OR.W #1,D2
sppskip4
OR.W D0,D1
MOVE.W D1,(A0)
MOVE.W D2,2(A0)
RTS
;---- DoLoad / DoSave Data ----
DoLoadData
TST.L DiskDataLength
BEQ.B dlsend
TST.L DiskDataPtr
BEQ.B dlsend
JSR SetDiskPtrCol
LEA LoadingText(PC),A0
BSR.W ShowStatusText
MOVE.L DOSBase(PC),A6
MOVE.L FileNamePtr(PC),D1
MOVE.L #1005,D2
JSR _LVOOpen(A6)
MOVE.L D0,FileHandle
BEQ.B CantOpenFile
MOVE.L FileHandle(PC),D1
MOVE.L DiskDataPtr(PC),D2
MOVE.L DiskDataLength(PC),D3
JSR _LVORead(A6)
MOVE.L FileHandle(PC),D1
JSR _LVOClose(A6)
dlsend CLR.L FileHandle
JSR SetNormalPtrCol
MOVEQ #-1,D0
RTS
CantOpenFile
LEA CantOpenFileText(PC),A0
caopfil BSR.W ShowStatusText
;JSR PTScreenToFront (8bitbubsy: this causes issues on exit!)
JSR SetErrorPtrCol
MOVEQ #0,D0
RTS
CantSaveFile
LEA CantSaveFileText(PC),A0
BRA.B caopfil
CantExamFile
LEA CantExamFileText(PC),A0
BRA.B caopfil
CantFindFile
LEA CantFindFileText(PC),A0
BRA.B caopfil
FileIsEmpty
LEA FileIsEmptyText(PC),A0
BRA.B caopfil
CantOpenFileText dc.b "can't open file !",0
CantSaveFileText dc.b "can't save file !",0
CantExamFileText dc.b "examine error !",0
CantFindFileText dc.b "can't find file !",0
FileIsEmptyText dc.b "file is empty !",0
EVEN
DoSaveData
JSR SetDiskPtrCol
LEA SavingText(PC),A0
BSR.W ShowStatusText
MOVE.L DOSBase(PC),A6
MOVE.L FileNamePtr(PC),D1
MOVE.L #1006,D2
JSR _LVOOpen(A6)
MOVE.L D0,FileHandle
BEQ.W CantOpenFile
MOVE.L FileHandle(PC),D1
MOVE.L DiskDataPtr(PC),D2
MOVE.L DiskDataLength(PC),D3
JSR _LVOWrite(A6)
CMP.L DiskDataLength(PC),D3
BEQ.B dsdskip
BSR.W CantSaveFile
dsdskip MOVE.L FileHandle(PC),D1
JSR _LVOClose(A6)
CLR.L FileHandle
JMP SetNormalPtrCol
;---- PLST ----
PLST CLR.B RawKeyCode
CMP.W #6,CurrScreen
BEQ.W ExitPLST
CMP.W #1,CurrScreen
BNE.W Return3
JSR WaitForButtonUp
MOVE.W #6,CurrScreen
JSR ClearRightArea
JSR ClearAnalyzerColors
BSR.B DrawPLSTScreen
BEQ.W ExitPLST
BSR.W RedrawPLST
PLST_rts
RTS
DrawPLSTScreen
LEA PLSTData,A0
MOVE.L #PLSTSize,D0
DecompactPLST
BSR.W Decompact
BEQ.W Return3
LEA TopMenusPos,A0
MOVEQ #99-1,D0
dplstloop1
MOVEQ #25-1,D1
dplstloop2
MOVE.B 2574(A1),10240(A0)
MOVE.B (A1)+,(A0)+
DBRA D1,dplstloop2
LEA 15(A0),A0
ADDQ #1,A1
DBRA D0,dplstloop1
BSR.W FreeDecompMem
MOVEQ #-1,D0
RTS
ShowDiskNames
MOVE.W #616,TextOffset
MOVE.W #5,TextLength
LEA STText1(PC),A0
BSR.W ShowText2
ADDQ.W #1,TextOffset
LEA STText2(PC),A0
BSR.W ShowText2
ADDQ.W #1,TextOffset
LEA STText3(PC),A0
BRA.W ShowText2
PLSTCheckNum
TST.L PLSTmem
BEQ.W NoPLST
TST.L MaxPLSTOffset
BEQ.W NoPLST
MOVE.L PLSTmem(PC),A0
MOVE.W PresetTotal(PC),D7
SUBQ.W #1,D7
TST.B STText1Number
BNE.B plstsskip
TST.B STText2Number
BNE.B plstsskip
TST.B STText3Number
BEQ.B PLSTMarkAll
plstsskip
MOVE.L STText1Number-1(PC),A3
MOVE.L STText2Number-1(PC),A4
MOVE.L STText3Number-1(PC),A5
MOVEQ #0,D6
PLSTmarkloop
MOVE.W #'st',(A0) ; Set lowercase 'st'
MOVE.B 3(A0),D0
CMP.B #'a',D0
BLO.B pmlskp1
SUB.B #32,D0
pmlskp1 MOVE.B D0,3(A0)
MOVE.B 4(A0),D0
CMP.B #'a',D0
BLO.B pmlskp2
SUB.B #32,D0
pmlskp2 MOVE.B D0,4(A0)
MOVE.L 2(A0),D0 ; Get number ('-01:' etc)
PLSTchk1
CMP.L A3,D0
BNE.B PLSTchk2
MOVE.W #'ST',(A0)
ADDQ.W #1,D6
BRA.B PLSTmarknext
PLSTchk2
CMP.L A4,D0
BNE.B PLSTchk3
MOVE.W #'ST',(A0)
ADDQ.W #1,D6
BRA.B PLSTmarknext
PLSTchk3
CMP.L A5,D0
BNE.B PLSTmarknext
MOVE.W #'ST',(A0)
ADDQ.W #1,D6
PLSTmarknext
LEA 30(A0),A0
DBRA D7,PLSTmarkloop
MOVE.W D6,PresetMarkTotal
CLR.W PLSTpos
CLR.L PLSTOffset
RTS
PLSTMarkAll
MOVE.W #'ST',(A0) ; Set uppercase 'ST'
LEA 30(A0),A0
DBRA D7,PLSTMarkAll
MOVE.W PresetTotal(PC),PresetMarkTotal
CLR.W PLSTpos
CLR.L PLSTOffset
RTS
NoPLST
CLR.W PresetMarkTotal
CLR.W PLSTpos
CLR.L PLSTOffset
RTS
RedrawPLST
MOVE.W PresetMarkTotal(PC),WordNumber
MOVE.W #189,TextOffset
BSR.W Print4DecDigits
BSR.W ShowDiskNames
TST.L PLSTmem
BEQ.W PLST_rts
TST.L MaxPLSTOffset
BEQ.W PLST_rts
MOVE.L PLSTOffset(PC),D6
MOVE.L PLSTmem(PC),A6
MOVE.W #976,A5 ; TextOffset
LEA PLSTOffset(PC),A4
MOVEQ #12-1,D7 ; Number of lines to print
TST.L D6
BMI.B EndOfPLST
dtplstloop
CMP.W #'ST',(A6,D6.L) ; Check for 'ST'
BNE.B PLSTNext
MOVE.L D6,(A4)+
MOVE.W A5,TextOffset
MOVE.W #18,TextLength
LEA (A6,D6.L),A3
ADDQ #3,A3
MOVE.L A3,ShowTextPtr
MOVEM.L D0-D7/A0-A6,-(SP)
BSR.W SpaceShowText
MOVEM.L (SP)+,D0-D7/A0-A6
MOVE.W 22(A6,D6.L),WordNumber
MOVE.W WordNumber(PC),D0
ADD.W D0,D0
MOVE.W D0,WordNumber
MOVEM.L D0-D7/A0-A6,-(SP)
BSR.W PrintHexWord
MOVEM.L (SP)+,D0-D7/A0-A6
ADD.L #$1E,D6
CMP.L MaxPLSTOffset(PC),D6
BHI.B EndOfPLST
LEA 240(A5),A5 ; Next Screen position
DBRA D7,dtplstloop
RTS
PLSTNext
ADD.L #30,D6
CMP.L MaxPLSTOffset(PC),D6
BHI.B EndOfPLST
BRA.B dtplstloop
EndOfPLST
MOVE.L #$FFFFFFFF,(A4)+
MOVE.W A5,TextOffset
MOVE.W #23,TextLength
MOVE.L #EmptyLineText,ShowTextPtr
MOVEM.L D0-D7/A0-A6,-(SP)
BSR.W SpaceShowText
MOVEM.L (SP)+,D0-D7/A0-A6
LEA 240(A5),A5
DBRA D7,EndOfPLST
RTS
TypeInDisk1
LEA STText1Number(PC),A6
MOVE.W #156,LineCurX
BRA.B DoTypeInDisk
TypeInDisk2
LEA STText2Number(PC),A6
MOVE.W #204,LineCurX
BRA.B DoTypeInDisk
TypeInDisk3
LEA STText3Number(PC),A6
MOVE.W #252,LineCurX
DoTypeInDisk
MOVE.W #1,lbW010D56
CLR.B (A6)
CLR.B 1(A6)
JSR StorePtrCol
JSR SetWaitPtrCol
BSR.W ShowDiskNames
MOVE.W #20,LineCurY
JSR UpdateLineCurPos
JSR GetHexKey
TST.B RawKeyCode
BNE.W ClearDiskNum
BTST #2,$DFF016 ; right mouse button
BEQ.W ClearDiskNum
CMP.B #128,D1
BEQ.W ClearDiskNum
ADD.W D1,D1
LEA FastHexTable+1(PC),A0
MOVE.B (A0,D1.W),(A6)
ADDQ.W #8,LineCurX
BSR.W ShowDiskNames
JSR UpdateLineCurPos
JSR GetHexKey
TST.B RawKeyCode
BNE.W ClearDiskNum
BTST #2,$DFF016 ; right mouse button
BEQ.W ClearDiskNum
CMP.B #128,D1
BEQ.W ClearDiskNum
ADD.W D1,D1
LEA FastHexTable+1(PC),A0
MOVE.B (A0,D1.W),1(A6)
JSR RestorePtrCol
BSR.W PLSTCheckNum
BSR.W RedrawPLST
CLR.W LineCurX
MOVE.W #270,LineCurY
JMP UpdateLineCurPos
ClearAllDisks
CLR.W lbW010D56
BSR.B DoClearDisks
BSR.W PLSTCheckNum
BRA.W RedrawPLST
DoClearDisks
MOVEQ #0,D0
MOVE.B D0,STText1Number
MOVE.B D0,STText1Number+1
MOVE.B D0,STText2Number
MOVE.B D0,STText2Number+1
MOVE.B D0,STText3Number
MOVE.B D0,STText3Number+1
RTS
MountList
MOVE.W #1,lbW010D56
JSR StorePtrCol
JSR SetDiskPtrCol
MOVE.L PTProcess,A0
MOVE.L 184(A0),lbL010D58
MOVE.L #$FFFFFFFF,184(A0)
BSR.B DoClearDisks
MOVE.W #1,MountFlag
LEA df0text(PC),A4
BSR.B lbC010C98
LEA PEdDefaultVol(PC),A0
BSR.W CheckMountName
LEA df1text(PC),A4
BSR.B lbC010C98
LEA STText2(PC),A0
BSR.W CheckMountName
LEA df2text(PC),A4
BSR.B lbC010C98
LEA STText3(PC),A0
BSR.W CheckMountName
CLR.W MountFlag
JSR RestorePtrCol
BSR.B lbC010C72
BSR.W cdisknum2
MOVE.L PTProcess,A0
MOVE.L lbL010D58(PC),184(A0)
RTS
lbC010C72
TST.B STText1Number
BNE.W Return2
TST.B STText2Number
BNE.W Return2
TST.B STText3Number
BNE.W Return2
CLR.W lbW010D56
RTS
lbC010C98
CLR.L FIB_FileName
CLR.L FIB_FileName+4
CLR.L FIB_FileName+8
MOVE.L DOSBase(PC),A6
MOVE.L A4,D1
MOVEQ #-2,D2
JSR _LVOLock(A6)
MOVE.L D0,FileLock
BEQ.B MountError
MOVE.L FileLock(PC),D1
MOVE.L #FileInfoBlock,D2
JSR _LVOExamine(A6)
TST.L D0
BEQ.B MountError
MOVE.L FileLock(PC),D1
JSR _LVOUnLock(A6)
MountError
MOVEQ #-1,D0
RTS
CheckMountName
MOVE.W FIB_FileName,D0
BEQ.B MountError
MOVE.W #'ST',D1 ; Check for ST
AND.W #$1F1F,D0
AND.W #$1F1F,D1
CMP.W D0,D1
BNE.B ClearDiskNum
MOVE.B FIB_FileName+3,D0
LSL.W #8,D0
MOVE.B FIB_FileName+4,D0
CMP.W #'00',D0
BEQ.B ClearDiskNum
MOVE.B D0,4(A0) ; Put disk number into ST-xx
LSR.W #8,D0
MOVE.B D0,3(A0)
MOVEQ #0,D0
RTS
ClearDiskNum
CLR.B RawKeyCode
JSR RestorePtrCol
CLR.B (A6)
CLR.B 1(A6)
CLR.W LineCurX
MOVE.W #270,LineCurY
JSR UpdateLineCurPos
cdisknum2
BSR.W PLSTCheckNum
BRA.W RedrawPLST
CNOP 0,4
lbL010D58 dc.l 0
lbW010D56 dc.w 0
df0text dc.b 'DF0:',0
df1text dc.b 'DF1:',0
df2text dc.b 'DF2:',0
EVEN
CheckPLSTGadgs
MOVE.W MouseX2(PC),D0
MOVE.W MouseY2(PC),D1
CMP.W #120,D0
BLO.B cplstend
CMP.W #23,D1
BHS.W PLSTPressed
CMP.W #12,D1
BHS.B PLSTLine2
PLSTLine1
CMP.W #268,D0
BHS.B ExitPLST
CMP.W #172,D0
BHS.B cplstend
CMP.W #120,D0
BHS.W ClearAllDisks
RTS
PLSTLine2
CMP.W #268,D0
BHS.W MountList
CMP.W #220,D0
BHS.W TypeInDisk3
CMP.W #172,D0
BHS.W TypeInDisk2
BRA.W TypeInDisk1
cplstend
RTS
ExitPLST
JSR WaitForButtonUp
CLR.B RawKeyCode
JSR ClearRightArea
JMP DisplayMainScreen
lbC010DC2
CMP.W #$63,D1
BHI.W Return3
CMP.W #$59,D1
BHS.W lbC010E78
CMP.W #$4E,D1
BHS.B lbC010DF4
CMP.W #$2D,D1
BHS.B ExitPLST
CMP.W #$22,D1
BHS.B lbC010DE6
BRA.B lbC010E02
lbC010DE6
TST.W PresetMarkTotal
BEQ.W Return3
BRA.W lbC010F12
lbC010DF4
TST.W PresetMarkTotal
BEQ.W Return3
BRA.W lbC010F56
lbC010E02
TST.W PresetMarkTotal
BEQ.W Return3
BTST #2,$DFF016 ; right mouse button
BEQ.B lbC010E1C
lbC010E16
MOVEQ #0,D0
BRA.W lbC010F82
lbC010E1C
TST.W lbW010D56
BNE.B lbC010E16
MOVE.L PLSTmem(PC),A1
MOVE.W PLSTpos(PC),D0
MULU.W #30,D0
MOVE.B 6(A1,D0.L),D1
lbC010E38
JSR lbC0039E8
SUB.L #$1E,D0
BMI.B lbC010E16
MOVE.B 6(A1,D0.L),D2
JSR lbC0039F0
CMP.B D1,D2
BEQ.B lbC010E38
MOVE.B D2,D1
lbC010E56
SUB.L #$1E,D0
BMI.B lbC010E16
MOVE.B 6(A1,D0.L),D2
JSR lbC0039F0
CMP.B D1,D2
BEQ.B lbC010E56
DIVU.W #$1E,D0
ADDQ.W #1,D0
BRA.W lbC010F82
lbC010E78
TST.W PresetMarkTotal
BEQ.W Return3
BTST #2,$DFF016 ; right mouse button
BEQ.B lbC010E98
lbC010E8C
MOVE.W PresetMarkTotal(PC),D0
SUB.W #12,D0
BRA.W lbC010F82
lbC010E98
TST.W lbW010D56
BNE.B lbC010E8C
MOVE.L PLSTmem(PC),A1
MOVE.W PLSTpos(PC),D0
MULU.W #30,D0
MOVE.B 6(A1,D0.L),D1
lbC010EB4
JSR lbC0039E8
ADD.L #$1E,D0
MOVE.W PresetMarkTotal(PC),D2
SUB.W #12,D2
BMI.W Return2
MULU.W #30,D2
CMP.L D2,D0
BLS.B lbC010EE0
MOVE.L D2,D0
DIVU.W #$1E,D0
BRA.W lbC010F82
lbC010EE0
MOVE.B 6(A1,D0.L),D2
JSR lbC0039F0
CMP.B D1,D2
BEQ.B lbC010EB4
DIVU.W #$1E,D0
BRA.W lbC010F82
PLSTOneUp
ST SetSignalFlag
TST.W PresetMarkTotal
BEQ.W Return3
BTST #6,$BFE001 ; left mouse button
BEQ.W PLST_rts
lbC010F12
MOVE.W PLSTpos(PC),D0
MOVE.W D0,D2
SUBQ.W #1,D0
TST.W ShiftKeyStatus
BNE.B lbC010F2E
BTST #2,$DFF016 ; right mouse button
BNE.B lbC010F32
lbC010F2E
SUB.W #9,D0
lbC010F32
TST.W D0
BPL.B lbC010F82
CLR.W D0
BRA.B lbC010F82
PLSTOneDown
ST SetSignalFlag
TST.W PresetMarkTotal
BEQ.W Return3
BTST #6,$BFE001 ; left mouse button
BEQ.W PLST_rts
lbC010F56
MOVE.W PLSTpos(PC),D0
MOVE.W D0,D2
ADDQ.W #1,D0
TST.W ShiftKeyStatus
BNE.B lbC010F70
BTST #2,$DFF016 ; right mouse button
BNE.B lbC010F74
lbC010F70
ADD.W #9,D0
lbC010F74
MOVE.W PresetMarkTotal(PC),D1
SUB.W #12,D1
CMP.W D0,D1
BHS.B lbC010F82
MOVE.W D1,D0
lbC010F82
BSR.B lbC010F88
BRA.W RedrawPLST
lbC010F88
MOVE.W PLSTpos(PC),D1
MOVE.W D0,PLSTpos
CMP.W D0,D1
BEQ.W Return3
TST.W D0
BEQ.B lbC010FC6
SUBQ.W #1,D0
MOVE.L PLSTmem(PC),A0
MOVEQ #0,D6
lbC010FA4
CMP.W #$5354,(A0,D6.L)
BEQ.B lbC010FB4
ADD.L #$1E,D6
BRA.B lbC010FA4
lbC010FB4
ADD.L #$1E,D6
DBRA D0,lbC010FA4
MOVE.L D6,PLSTOffset
RTS
lbC010FC6
CLR.L PLSTOffset
RTS
PLSTPressed
CMP.W #$18,D1
BLO.W Return3
CMP.W #$134,D0
BHS.W lbC010DC2
CMP.W #$5F,D1
BHI.W Return3
SUB.W #$18,D1
AND.L #$FFFF,D1
DIVU.W #6,D1
LSL.W #2,D1
LEA PLSTOffset(PC),A0
MOVE.L (A0,D1.W),D1
BMI.W Return3
DIVU.W #$1E,D1
ADDQ.W #1,D1
MOVE.W D1,CurrentPreset
JSR WaitForButtonUp
BRA.W UsePreset
;---- Preset Editor/PED ----
PresetEditor
JSR WaitForButtonUp
MOVE.W #4,CurrScreen
ST DisableAnalyzer
ST NoSampleInfo
BSR.B SwapPresEdScreen
BEQ.W pedexi2
PED_Refresh
CLR.W PED_Action
LEA TextBitplane,A0
MOVE.W #1220-1,D0
MOVEQ #0,D1
pedloop MOVE.L D1,(A0)+
DBRA D0,pedloop
JSR SetNormalPtrCol
JSR ClearAnalyzerColors
BSR.W ShowPEDnumbers
BRA.W ShowPresetNames
ClearPEDText
LEA TextBitplane+2240,A0
MOVE.W #660-1,D0
MOVEQ #0,D1
cpedtextloop
MOVE.L D1,(A0)+
DBRA D0,cpedtextloop
RTS
SwapPresEdScreen
MOVE.L DecompMemPtr(PC),D0
BEQ.B speds2
MOVE.L D0,A1
BSR.B speds3
BRA.W FreeDecompMem
speds2 LEA PresetEdData,A0
MOVE.L #PresetEdSize,D0
BSR.W Decompact
BEQ.W Return3
speds3 LEA BitplaneData,A0
MOVEQ #2-1,D2
spesloop1
MOVE.W #1220-1,D0
spesloop2
MOVE.L (A0),D1
MOVE.L (A1),(A0)+
MOVE.L D1,(A1)+
DBRA D0,spesloop2
LEA $14F0(A0),A0
DBRA D2,spesloop1
MOVEQ #-1,D0
RTS
CheckPresEdGadgs
MOVE.W MouseX2(PC),D0
MOVE.W MouseY2(PC),D1
CMP.W #45,D1
BHS.W CheckPEDnames
CLR.W PED_Action
JSR SetNormalPtrCol
CMP.W #308,D0
BHS.B PED_GotoPLST
PED_Menu1
CMP.W #102,D0
BHS.B PED_Menu2
CMP.W #34,D1
BHS.W PED_DeleteDisk
CMP.W #23,D1
BHS.W PED_Delete
CMP.W #12,D1
BHS.W PED_Insert
BRA.W PED_AddPathGadg
PED_Menu2
CMP.W #210,D0
BHS.B PED_Menu3
CMP.W #34,D1
BHS.W PED_ClearPLST
CMP.W #23,D1
BHS.W Return3
CMP.W #12,D1
BHS.W PED_Disk
BRA.W PED_EnterPath
PED_Menu3
CMP.W #34,D1
BHS.W PED_Print
CMP.W #23,D1
BHS.W WritePLST
CMP.W #12,D1
BHS.B xLoadPLST
BRA.W PED_EnterPath
xLoadPLST
BSR.W LoadPLST
CLR.W PEDpos
BRA.W PED_Refresh
PED_GotoPLST
BSR.B PED_Exit
BRA.W PLST
PED_Exit
JSR WaitForButtonUp
BSR.W PLSTCheckNum
BSR.W SwapPresEdScreen
LEA TextBitplane,A0
MOVE.W #1220-1,D0
MOVEQ #0,D1
pedeloop
MOVE.L D1,(A0)+
DBRA D0,pedeloop
CLR.B RawKeyCode
pedexi2 JSR ClearAnalyzerColors
JMP DisplayMainAll
PED_AddPathGadg
TST.L PLSTmem
BNE.B pedawok
BSR.W AllocPLST
TST.L PLSTmem
BEQ.W PLSTMemErr
pedawok MOVE.L DOSBase(PC),A6
MOVE.L #PEdDefaultPath,D1
MOVEQ #-2,D2
JSR _LVOLock(A6)
MOVE.L D0,FileLock
BEQ.W UnlockReadPath
JSR SetDiskPtrCol
LEA AddingPathText(PC),A0
BSR.W ShowStatusText
MOVE.L DOSBase(PC),A6
MOVE.L FileLock(PC),D1
MOVE.L #FileInfoBlock,D2
JSR _LVOExamine(A6)
TST.L D0
BPL.W UnlockReadPath
TST.L FIB_EntryType
BPL.B CheckPathDirName
BSR.W AddPreset
BRA.B IsPLSTfull
CheckPathDirName
CMP.B #'-',FIB_FileName+2
BNE.B IsPLSTfull
MOVE.B FIB_FileName+3,SndDiskNum0
MOVE.B FIB_FileName+4,SndDiskNum1
BSR.W ShowPEDnumbers
IsPLSTfull
MOVE.W PresetTotal(PC),D0
CMP.W MaxPLSTEntries,D0
BLO.B ReadPathNext
BSR.W PLSTisFull
BRA.W ReadPathEnd
ReadPathNext
MOVE.L DOSBase(PC),A6
MOVE.L FileLock(PC),D1
MOVE.L #FileInfoBlock,D2
JSR _LVOExNext(A6)
TST.L D0
BPL.W ReadPathEnd
BTST #2,$DFF016 ; right mouse button
BEQ.W ReadPathEnd
TST.L FIB_EntryType
BPL.B IsPLSTfull
CMP.L #'.inf',FIB_FileName
BEQ.W IsPLSTfull
CMP.L #'.inf',FIB_FileName+4
BEQ.W IsPLSTfull
LEA FIB_FileName,A0
MOVEQ #29-1,D0
repalop CMP.B #'.',(A0)+
BEQ.W CouldBeInfo
DBRA D0,repalop
rpnskip CLR.W PresetRepeat
MOVE.W #1,PresetReplen
TST.B IFFLoopFlag ; name is ok, test for IFF
BEQ.W rpnskp2
LEA PEdDefaultPath(PC),A0
JSR CopyPath
LEA FIB_FileName,A0
rpncpfn MOVE.B (A0)+,(A1)+
BNE.B rpncpfn
MOVE.L #FileName,D1
MOVE.L #1005,D2
MOVE.L DOSBase(PC),A6
JSR _LVOOpen(A6)
MOVE.L D0,FileHandle
BEQ.B rpnskp2
MOVE.L D0,D1
LEA chkiffbuffer(PC),A2
CLR.L (A2)
MOVE.L A2,D2
MOVEQ #12,D3
JSR _LVORead(A6)
CMP.L #"FORM",(A2)
BNE.B rpnclse
CMP.L #"8SVX",8(A2)
BNE.B rpnclse
rpnvhdr MOVE.L FileHandle(PC),D1
MOVE.L A2,D2
MOVEQ #4,D3
JSR _LVORead(A6)
TST.L D0
BEQ.B rpnclse
CMP.L #"VHDR",(A2)
BNE.B rpnvhdr
MOVE.L FileHandle(PC),D1
MOVE.L A2,D2
MOVEQ #12,D3
JSR _LVORead(A6)
MOVE.L 8(A2),D0
BEQ.B rpnclse
LSR.W #1,D0
MOVE.W D0,PresetReplen
MOVE.L 4(A2),D0
LSR.W #1,D0
MOVE.W D0,PresetRepeat
rpnclse MOVE.L FileHandle(PC),D1
JSR _LVOClose(A6)
rpnskp2 BSR.B AddPreset
BSR.W ShowPEDnumbers
BRA.W IsPLSTfull
CNOP 0,4
chkiffbuffer
dc.l 0,0,0
CouldBeInfo
CMP.B #'i',(A0)+
BNE.W rpnskip
CMP.B #'n',(A0)+
BNE.W rpnskip
CMP.B #'f',(A0)+
BNE.W rpnskip
CMP.B #'o',(A0)+
BNE.W rpnskip
TST.B (A0)+
BNE.W rpnskip
BRA.W IsPLSTfull
ReadPathEnd
MOVE.L DOSBase(PC),A6
MOVE.L FileLock(PC),D1
BEQ.B rpeskip
JSR _LVOUnLock(A6)
rpeskip JSR SetNormalPtrCol
BSR.W ShowPresetNames
BRA.W ShowAllRight
UnlockReadPath
MOVE.L DOSBase(PC),A6
MOVE.L FileLock(PC),D1
BEQ.B urpend
JSR _LVOUnLock(A6)
urpend JMP SetErrorPtrCol
AddPreset
LEA PEdDefaultVol(PC),A0
LEA PresetName(PC),A1
MOVEQ #6-1,D0 ; Disk ST-XX:
aploop MOVE.B (A0)+,(A1)+
DBRA D0,aploop
LEA FIB_FileName,A0
MOVEQ #15-1,D0 ; Name 16 letters.
aploop2 MOVE.B (A0)+,(A1)+
BNE.B .skip
SUBQ.L #1,A0
.skip DBRA D0,aploop2
CLR.B (A1)
MOVE.L FIB_FileSize,D0
CMP.L #$FFFE,D0
BLS.B apskip2
MOVE.W #$FFFE,D0
apskip2 LSR.W #1,D0
MOVE.W D0,PresetLength
CLR.W PresetFineTune
LEA PresetName(PC),A6
BSR.W PED_CheckAdd
ADDQ.W #1,PresetTotal
ADD.L #30,MaxPLSTOffset
RTS
PED_Insert
TST.L PLSTmem
BNE.B pediwok
BSR.W AllocPLST
TST.L PLSTmem
BEQ.W PLSTMemErr
pediwok MOVE.W PresetTotal(PC),D0
CMP.W MaxPLSTEntries2(PC),D0
BHS.W PLSTisFull
LEA InsertPsetText(PC),A0
LEA PresetName(PC),A1
MOVEQ #40-1,D0
pediloop
MOVE.B (A0)+,(A1)+
DBRA D0,pediloop
PossibleEdit
JSR StorePtrCol
JSR SetWaitPtrCol
LEA TextBitplane+2320,A0
MOVEQ #60-1,D0
MOVEQ #0,D1
pediloop2
MOVE.L D1,(A0)+
DBRA D0,pediloop2
LEA EnterDataText(PC),A0
BSR.W ShowStatusText
MOVE.W #63,LineCurY
LEA PresetName(PC),A6
MOVEQ #3,D7
MOVE.B #4,EnterTextFlag
ShowPsetText
LEA PresetName+3(PC),A0
MOVEQ #37,D0
MOVE.W #2321,D1
BSR.W ShowText3
MOVE.W D7,D0
SUBQ.W #3,D0
LSL.W #3,D0
ADD.W #12,D0
MOVE.W D0,LineCurX
JSR UpdateLineCurPos
pediwaitkey
JSR DoKeyBuffer
MOVE.B RawKeyCode(PC),D0
BEQ.B pediwaitkey
CLR.B RawKeyCode
BTST #7,D0
BNE.B pediwaitkey
AND.W #$FF,D0
CMP.B #69,D0
BEQ.W PED_ESCkey
CMP.B #65,D0
BEQ.W PED_BkspaceKey
CMP.B #68,D0
BEQ.B PED_ReturnKey
CMP.B #79,D0
BEQ.W PED_LeftArrowKey
CMP.B #78,D0
BEQ.W PED_RightArrowKey
CMP.B #64,D0
BHI.B pediwaitkey
CMP.W #40,D7
BEQ.B pediwaitkey
CMP.W #22,D7
BEQ.B pediwaitkey
LEA UnshiftedKeymap(PC),A0
TST.W ShiftKeyStatus
BEQ.B ShiftKeySkip
LEA ShiftedKeymap(PC),A0
ShiftKeySkip
MOVE.B (A0,D0.W),D1
BEQ.B pediwaitkey
CMP.W #6,D7
BLO.B hexchk2
CMP.W #25,D7
BLO.B PED_PrintChar
hexchk2 CMP.B #'0',D1
BLO.B pediwaitkey
CMP.B #'f',D1
BHI.W pediwaitkey
CMP.B #'9',D1
BLS.B PED_PrintChar
CMP.B #'a',D1
BHS.B PED_PrintChar
BRA.W pediwaitkey
PED_PrintChar
MOVE.B D1,(A6,D7.W)
BRA.W PED_RightArrowKey
PED_ReturnKey
CMP.B #' ',PsetNameText
BEQ.B PED_ESCkey
LEA PsetVolText(PC),A0
LEA fitutexttab+32(PC),A1
MOVE.B (A0)+,D1
LSL.W #8,D1
MOVE.B (A0),D1
MOVEQ #16-1,D0
vofloop CMP.W -(A1),D1
BEQ.B vofound
DBRA D0,vofloop
MOVEQ #0,D0
vofound MOVE.W D0,PresetFineTune
LEA PsetLenText(PC),A0
BSR.W HexToInteger
LSR.W #1,D0
MOVE.W D0,PresetLength
LEA PsetRepeatText(PC),A0
BSR.W HexToInteger
LSR.W #1,D0
MOVE.W D0,PresetRepeat
LEA PsetReplenText(PC),A0
BSR.W HexToInteger
LSR.W #1,D0
MOVE.W D0,PresetReplen
BSR.W PED_CheckAdd
ADDQ.W #1,PresetTotal
PED_ESCkey
CLR.W LineCurX
MOVE.W #270,LineCurY
JSR UpdateLineCurPos
BSR.W ShowAllRight
CLR.B EnterTextFlag
BRA.W PED_Refresh
PED_BkspaceKey
CMP.W #23,D7
BHS.B pedbsend
CMP.W #6,D7
BLS.B pedbsend
SUBQ.W #1,D7
MOVE.B #' ',(A6,D7.W)
pedbsend
BRA.W ShowPsetText
PED_LeftArrowKey
SUBQ.W #1,D7
CMP.W #2,D7
BLS.B pedlakskip2
CMP.W #5,D7
BEQ.B pedlakskip
CMP.W #22,D7
BEQ.B pedlakskip
CMP.W #25,D7
BEQ.B pedlakskip
CMP.W #30,D7
BEQ.B pedlakskip
CMP.W #35,D7
BEQ.B pedlakskip
BRA.W ShowPsetText
pedlakskip
SUBQ.W #1,D7
BRA.W ShowPsetText
pedlakskip2
MOVEQ #3,D7
BRA.W ShowPsetText
PED_RightArrowKey
ADDQ.W #1,D7
CMP.W #5,D7
BEQ.B pedrakskip
CMP.W #22,D7
BEQ.B pedrakskip
CMP.W #25,D7
BEQ.B pedrakskip
CMP.W #30,D7
BEQ.B pedrakskip
CMP.W #35,D7
BEQ.B pedrakskip
CMP.W #40,D7
BHS.B pedrakskip2
BRA.W ShowPsetText
pedrakskip
ADDQ.W #1,D7
BRA.W ShowPsetText
pedrakskip2
MOVEQ #39,D7
BRA.W ShowPsetText
PED_CheckAdd
MOVEQ #23,D0
pedcaloop
SUBQ.W #1,D0
CMP.B #' ',(A6,D0.W)
BEQ.B pedcaloop
CLR.B 1(A6,D0.W)
MOVE.L PLSTmem(PC),A5
pedccnextloop
MOVEQ #6,D0
TST.B 6(A5)
BEQ.B PED_AddPreset
PED_ConvertLoop
MOVE.B (A5,D0.W),D2
BNE.B PED_ConvertCase
TST.B (A6,D0.W)
BNE.B PED_ConvertCase
CLR.B 6(A5)
SUBQ.W #1,PresetTotal
BRA.B PED_AddPreset
PED_ConvertCase
CMP.B #'A',D2
BLO.B pedccskip
CMP.B #'Z',D2
BHI.B pedccskip
ADD.B #32,D2
pedccskip
MOVE.B (A6,D0.W),D1
CMP.B #' ',D1
BEQ.B pedccskip3
CMP.B #'A',D1
BLO.B pedccskip2
CMP.B #'Z',D1
BHI.B pedccskip2
ADD.B #32,D1
pedccskip2
CMP.B D2,D1
BEQ.B pedccnext
BHI.B pedccskip3
BRA.B PED_AddPreset
pedccnext
ADDQ.W #1,D0
CMP.W #22,D0
BNE.B PED_ConvertLoop
pedccskip3
LEA 30(A5),A5
BRA.B pedccnextloop
PED_AddPreset
TST.B 6(A5)
BEQ.B pedapskip
MOVE.L PLSTmem(PC),A1
MOVE.W PresetTotal(PC),D0
BEQ.B pedapskip
MULU.W #30,D0
ADD.L D0,A1
LEA 30(A1),A1
CLR.B 31(A1)
pedaploop
MOVE.W (A1),30(A1)
SUBQ.L #2,A1
CMP.L A1,A5
BLS.B pedaploop
pedapskip
MOVEQ #22-1,D0
pedaploop2
MOVE.B (A6,D0.W),D1
CMP.B #'A',D1
BLO.B pedapskip2
CMP.B #'Z',D1
BHI.B pedapskip2
ADD.B #32,D1
pedapskip2
CMP.B #' ',D1
BNE.B pedapskip3
MOVEQ #0,D1
pedapskip3
MOVE.B D1,(A5,D0.W)
DBRA D0,pedaploop2
MOVE.W PresetLength(PC),22(A5)
MOVE.B PresetFineTune+1(PC),24(A5)
MOVE.B #$40,25(A5)
MOVE.W PresetRepeat(PC),26(A5)
MOVE.W PresetReplen(PC),28(A5)
RTS
HexToInteger
MOVEQ #0,D0
BSR.B Single_hti
LSL.W #8,D1
LSL.W #4,D1
OR.W D1,D0
BSR.B Single_hti
LSL.W #8,D1
OR.W D1,D0
HexToInteger2
BSR.B Single_hti
LSL.W #4,D1
OR.W D1,D0
BSR.B Single_hti
OR.W D1,D0
RTS
Single_hti
MOVEQ #0,D1
MOVE.B (A0)+,D1
CMP.B #$60,D1
BLO.B shtiskip
SUB.B #$20,D1
shtiskip
SUB.B #$30,D1
CMP.B #9,D1
BLS.W Return3
SUBQ.B #7,D1
RTS
PED_Delete
JSR SetDeletePtrCol
MOVE.W #1,PED_Action
LEA SelectEntryText(PC),A0
BRA.W ShowStatusText
PED_ClearPLST
LEA ClearPLSTText(PC),A0
JSR AreYouSure
BNE.W Return3
BSR.W FreePLST
BRA.W PED_Refresh
ClearPLSTText dc.b 'clear plst ?',0
EVEN
PED_Print
LEA PrintPLSTText(PC),A0
JSR AreYouSure
BNE.W Return3
JSR StorePtrCol
MOVE.L DOSBase(PC),A6
MOVE.L #PrintPath,D1
MOVE.L #1006,D2
JSR _LVOOpen(A6)
MOVE.L D0,FileHandle
BEQ.W CantOpenFile
JSR SetDiskPtrCol
MOVE.L D0,D1
MOVE.L #PsetPLSTtext,D2
MOVEQ #56,D3
JSR _LVOWrite(A6)
LEA PrintingPLSTText(PC),A0
BSR.W ShowStatusText
CLR.W PsetNumTemp
pedpmloop
MOVE.W PsetNumTemp(PC),D0
LEA PsetPrtNumText(PC),A0
BSR.W IntToDecASCII
MOVE.L PLSTmem(PC),A0
MOVE.W PsetNumTemp(PC),D0
MULU.W #30,D0
ADD.L D0,A0
MOVE.L A0,PsetPtrTemp
LEA PsetPrtNameText(PC),A1
MOVE.L A1,A2
MOVEQ #20-1,D1
FillSpaceLoop
MOVE.B #' ',(A2)+
DBRA D1,FillSpaceLoop
MOVEQ #20-1,D1
pedploop
TST.B (A0)
BEQ.B pedpskip
MOVE.B (A0)+,(A1)+
DBRA D1,pedploop
pedpskip
MOVE.L PsetPtrTemp(PC),A1
MOVE.W 22(A1),D0
LEA PsetPrtLenText(PC),A0
BSR.W IntToHexASCII
MOVE.L PsetPtrTemp(PC),A1
MOVE.W 26(A1),D0
LEA PsetPrtRepeatText(PC),A0
BSR.W IntToHexASCII
MOVE.L PsetPtrTemp(PC),A1
MOVE.W 28(A1),D0
ADD.W D0,D0
LEA PsetPrtRepLenText(PC),A0
BSR.B IntToHexASCII
MOVE.L FileHandle(PC),D1
MOVE.L #PsetPrtNumText,D2
MOVEQ #53,D3
JSR _LVOWrite(A6)
BTST #2,$DFF016 ; right mouse button
BEQ.B AbortPLSTPrint
ADDQ.W #1,PsetNumTemp
MOVE.W PsetNumTemp(PC),D0
CMP.W PresetTotal(PC),D0
BNE.W pedpmloop
BRA.B pedpend
AbortPLSTPrint
LEA OprAbortedText(PC),A0
BSR.W ShowStatusText
JSR SetErrorPtrCol
pedpend MOVE.L FileHandle(PC),D1
JSR _LVOClose(A6)
BSR.W ShowAllRight
JMP RestorePtrCol
IntToDecASCII
MOVEQ #4-1,D3
MOVE.L #1000,D2
itdloop EXT.L D0
DIVU.W D2,D0
ADD.B #'0',D0
MOVE.B D0,(A0)+
DIVU.W #10,D2
SWAP D0
DBRA D3,itdloop
RTS
IntToHex2
MOVEQ #1,D2
BRA.B ithaloop
IntToHexASCII
MOVEQ #4-1,D2
ithaloop
MOVE.W D0,D1
AND.B #15,D1
CMP.B #10,D1
BLO.B ithaskip
ADDQ.B #7,D1
ithaskip
ADD.B #'0',D1
MOVE.B D1,-(A0)
ROR.W #4,D0
DBRA D2,ithaloop
RTS
WritePLST
LEA SavePLSTText(PC),A0
JSR AreYouSure
BNE.W Return3
JSR StorePtrCol
JSR SetDiskPtrCol
LEA SavingPLSTText(PC),A0
BSR.W ShowStatusText
LEA PTPath,A0
JSR CopyPath
LEA PLSTname(PC),A0
MOVEQ #5-1,D0
dsploop MOVE.B (A0)+,(A1)+
DBRA D0,dsploop
MOVE.L #FileName,D1
MOVE.L #1006,D2
MOVE.L DOSBase(PC),A6
JSR _LVOOpen(A6)
MOVE.L D0,D7
BEQ.W CantOpenFile
MOVE.L D0,D1
MOVE.L PLSTmem(PC),D2
MOVE.W PresetTotal(PC),D3
MULU.W #30,D3
MOVE.L D3,-(SP)
JSR _LVOWrite(A6)
CMP.L (SP)+,D3
BEQ.B wplstskip
BSR.W CantSaveFile
wplstskip
MOVE.L D7,D1
JSR _LVOClose(A6)
BSR.W ShowAllRight
JMP RestorePtrCol
xDoCheckGadgets2 JMP DoCheckGadgets2
CheckPEDnames
CMP.W #307,D0
BLO.W PED_PsetHit
CLR.W PED_Action
JSR SetNormalPtrCol
CMP.W #122,D1
BHS.B xDoCheckGadgets2
CMP.W #111,D1
BHS.W PED_Bottom
CMP.W #100,D1
BHS.W PED_OneDown
CMP.W #67,D1
BHS.W PED_Exit
CMP.W #56,D1
BHS.B PED_OneUp
BTST #2,$DFF016 ; right mouse button
BEQ.B lbC0119AE
PED_Top
CLR.W PEDpos
BRA.W ShowPresetNames
lbC0119AE
MOVE.L PLSTmem(PC),A1
MOVE.W PEDpos(PC),D0
MULU.W #30,D0
MOVE.B 6(A1,D0.L),D1
lbC0119C0
SUB.L #30,D0
BMI.B PED_Top
MOVE.B 6(A1,D0.L),D2
CMP.B D1,D2
BEQ.B lbC0119C0
MOVE.B D2,D1
lbC0119D2
SUB.L #30,D0
BMI.B PED_Top
MOVE.B 6(A1,D0.L),D2
CMP.B D1,D2
BEQ.B lbC0119D2
DIVU.W #30,D0
ADDQ.W #1,D0
BRA.B pdodsx
PED_OneUp
ST SetSignalFlag
SUBQ.W #1,PEDpos
TST.W ShiftKeyStatus
BNE.B poup2
BTST #2,$DFF016 ; right mouse button
BNE.B pdouskip
poup2 SUBQ.W #7,PEDpos
pdouskip
TST.W PEDpos
BGE.W ShowPresetNames
BRA.B PED_Top
PED_OneDown
ST SetSignalFlag
CMP.W #10,PresetTotal
BLO.W ShowPresetNames
ADDQ.W #1,PEDpos
TST.W ShiftKeyStatus
BNE.B podn2
BTST #2,$DFF016 ; right mouse button
BNE.B pdodskip
podn2 ADDQ.W #7,PEDpos
pdodskip
MOVE.W PresetTotal(PC),D0
SUB.W #10,D0
CMP.W PEDpos(PC),D0
BHS.B ShowPresetNames
pdodsx MOVE.W D0,PEDpos
BRA.B ShowPresetNames
PED_Bottom
BTST #2,$DFF016 ; right mouse button
BEQ.B .L0
MOVE.W PresetTotal(PC),D0
SUB.W #11,D0
BMI.W PED_Top
ADDQ.W #1,D0
BRA.B pdodsx
.L0 MOVE.L PLSTmem(PC),A1
MOVE.W PEDpos(PC),D0
MULU.W #30,D0
MOVE.B 6(A1,D0.L),D1
.loop ADD.L #30,D0
MOVE.W PresetTotal(PC),D2
SUB.W #10,D2
BMI.W Return3
MULU.W #30,D2
CMP.L D2,D0
BLS.B .L1
MOVE.L D2,D0
DIVU.W #30,D0
BRA.B pdodsx
.L1 MOVE.B 6(A1,D0.L),D2
CMP.B D1,D2
BEQ.B .loop
DIVU.W #30,D0
MOVE.W D0,PEDpos
ShowPresetNames
MOVE.W #2321,D6
MOVEQ #10-1,D7
MOVE.L PLSTmem(PC),D0
BEQ.W Return3
MOVE.L D0,A5
MOVE.W PEDpos(PC),D0
MULU.W #30,D0
ADD.L D0,A5
spndploop
TST.B (A5)
BEQ.W Return3
LEA PresetNameText,A1
MOVEQ #22-1,D0
spnloop MOVE.B #' ',(A1)+
DBRA D0,spnloop
MOVE.L A5,A0
ADDQ #3,A0
LEA -22(A1),A1
spnloop2
MOVE.B (A0)+,D0
BEQ.B DisplayPreset
MOVE.B D0,(A1)+
BRA.B spnloop2
fitutexttab
dc.b " 0+1+2+3+4+5+6+7-8-7-6-5-4-3-2-1"
EVEN
DisplayPreset
MOVEQ #19,D0
LEA PresetNameText,A0
MOVE.W D6,D1
BSR.W ShowText3
ADD.W #20,D6
MOVE.W D6,TextOffset
MOVEQ #0,D0
MOVE.B 24(A5),D0
AND.B #$0F,D0
ADD.W D0,D0
LEA fitutexttab(PC,D0.W),A0
MOVE.W #2,TextLength
BSR.W ShowText2
MOVE.W 22(A5),D0
ADD.W D0,D0
MOVE.W D0,WordNumber
ADDQ.W #1,TextOffset
BSR.W PrintHexWord
MOVE.W 26(A5),D0
ADD.W D0,D0
MOVE.W D0,WordNumber
ADDQ.W #1,TextOffset
BSR.W PrintHexWord
MOVE.W 28(A5),D0
ADD.W D0,D0
MOVE.W D0,WordNumber
ADDQ.W #1,TextOffset
BSR.W PrintHexWord
ADD.W #220,D6 ; 218
LEA 30(A5),A5
DBRA D7,spndploop
RTS
PED_EnterPath
JSR StorePtrCol
JSR SetWaitPtrCol
CLR.L EditMode
LEA PEdDefaultPath(PC),A6
JSR UpdateLineCurPos
MOVE.L A6,TextEndPtr
MOVE.L A6,ShowTextPtr
ADD.L #31,TextEndPtr
MOVE.W #20,TextLength
MOVEA.W #178,A4
BSR.W GetTextLine
CLR.L TextEndPtr
JMP RestorePtrCol
PED_Disk
JSR SetWaitPtrCol
CLR.L EditMode
MOVE.W #621,TextOffset
JSR GetHexByte
TST.W AbortHexFlag
BNE.B peddskip
MOVE.W D0,D1
LSR.W #4,D0
AND.W #15,D1
LEA HexTable(PC),A0
MOVE.B (A0,D0.W),SndDiskNum0
MOVE.B (A0,D1.W),SndDiskNum1
MOVE.B #':',SndDiskNum0+2
CLR.B EnterTextFlag
peddskip
BSR.B ShowPEDnumbers
JMP SetNormalPtrCol
ShowPEDnumbers
MOVE.W PresetTotal(PC),WordNumber
MOVE.W #1061,TextOffset
BSR.W Print4DecDigits
LEA PEdDefaultPath(PC),A0
MOVE.W #178,D1
MOVEQ #20,D0
BSR.W ShowText3
LEA PEdDefaultVol(PC),A0
MOVE.W #618,D1
MOVEQ #6,D0
BRA.W ShowText3
PED_PsetHit
CMP.W #122,D1
BHS.W xDoCheckGadgets2
TST.W PresetTotal
BEQ.B pedphend
MOVEQ #0,D0 ; --PT2.3D bug fix: fix PSED mouse weirdness
MOVE.W MouseY2(PC),D0
CMP.W #58,D0 ; --PT2.3D bug fix: 58, not 59
BLO.B pedphend
CMP.W #119,D0
BHS.B pedphend
SUB.W #58,D0 ; --PT2.3D bug fix: 58, not 59
AND.L #$FFFF,D0
DIVU.W #6,D0
MOVE.L D0,D1
SWAP D1
CMP.W #5,D1
BEQ.B pedphend
MOVE.W D0,D2
ADD.W PEDpos(PC),D2
CMP.W PresetTotal(PC),D2
BGE.B pedphend
MULU.W #30,D0
MOVE.L PLSTmem(PC),A5
ADD.L D0,A5
MOVE.W PEDpos(PC),D0
MULU.W #30,D0
ADD.L D0,A5
TST.W PED_Action
BEQ.B PED_CopyName
CMP.W #1,PED_Action
BEQ.B PED_DoDelete
pedphend
RTS
PED_CopyName
LEA PresetName(PC),A0
MOVEQ #22-1,D0
pedcnloop
MOVE.B (A5)+,D1
BNE.B pedcnskip
MOVE.B #' ',D1
pedcnskip
MOVE.B D1,(A0)+
DBRA D0,pedcnloop
MOVEQ #0,D0
MOVE.B 2(A5),D0
AND.B #$0F,D0
ADD.W D0,D0
LEA fitutexttab(PC),A1
LEA (A1,D0.W),A1
LEA PsetVolText(PC),A0
MOVE.B #' ',-1(A0)
MOVE.B (A1)+,(A0)+
MOVE.B (A1),(A0)
MOVE.W (A5),D0
ADD.W D0,D0
ADDQ #6,A0
BSR.W IntToHexASCII
MOVE.W 4(A5),D0
ADD.W D0,D0
LEA 9(A0),A0
BSR.W IntToHexASCII
LEA 9(A0),A0
MOVE.W 6(A5),D0
ADD.W D0,D0
BSR.W IntToHexASCII
BRA.W PossibleEdit
PED_DoDelete
CLR.W PED_Action
LEA DeletePresetText(PC),A0
JSR AreYouSure
BNE.B pedddno ; --PT2.3D bug fix: set normal cursor
MOVE.L PLSTmem(PC),A1
MOVE.W PresetTotal(PC),D0
MULU.W #30,D0
ADD.L D0,A1
pedddloop
MOVE.W 30(A5),(A5)
ADDQ #2,A5
CMP.L A5,A1
BHI.B pedddloop
CLR.B (A5)
SUBQ.W #1,PresetTotal
SUB.L #30,MaxPLSTOffset
MOVE.W PEDpos(PC),D0
ADD.W #9,D0
CMP.W PresetTotal(PC),D0
BHI.B pedddskip
SUBQ.W #1,PEDpos
TST.W PEDpos
BPL.B pedddskip
CLR.W PEDpos
pedddskip
BSR.W ClearPEDText
BSR.W ShowPEDnumbers
BSR.W ShowPresetNames
JSR SetNormalPtrCol
JMP StorePtrCol
pedddno JMP SetNormalPtrCol
PLSTisFull
LEA PLSTFullText(PC),A0
BSR.W ShowStatusText
JMP SetErrorPtrCol
PED_DeleteDisk
LEA DelDiskText(PC),A0
MOVE.B SndDiskNum0(PC),10(A0)
MOVE.B SndDiskNum1(PC),11(A0)
JSR AreYouSure
BNE.W Return3
JSR StorePtrCol
JSR SetWaitPtrCol
MOVE.L PLSTmem(PC),A0
MOVE.L A0,A1
MOVE.W PresetTotal(PC),D0
MULU.W #30,D0
ADD.L D0,A1
MOVE.L SndDiskNum0-1(PC),D1
MOVE.L #$FF5F5FFF,D2
AND.L D2,D1
peddslo MOVE.L 2(A0),D0
AND.L D2,D0
CMP.L D1,D0
BNE.B peddsno
MOVE.L A0,A2
peddslp MOVE.W 30(A0),(A0)+
CMP.L A1,A0
BLO.B peddslp
SUBQ.W #1,PresetTotal
SUB.L #$1E,MaxPLSTOffset
MOVE.L A2,A0
BRA.B peddsn1
peddsno LEA 30(A0),A0
peddsn1 CMP.L A1,A0
BLO.B peddslo
CLR.W PEDpos
BSR.W ClearPEDText
BSR.W ShowPEDnumbers
BSR.W ShowPresetNames
JMP RestorePtrCol
DelDiskText dc.b "Delete ST-.. ?",0
EVEN
;************ MIDI Routines ************
; * Apollon MIDI Routines V0.2 *
; * V0.2 04/07-1991 First version *
_RVOAllocMiscResource = -6
_RVOFreeMiscResource = -12
OpenMIDI
TST.L MIDIinBuffer
BNE.B omidisk
MOVE.L #256,D0
MOVE.L #MEMF_PUBLIC!MEMF_CLEAR,D1
JSR PTAllocMem
MOVE.L D0,MIDIinBuffer
BEQ.W Return3
omidisk CLR.B MIDIinTo
CLR.B MIDIinFrom
BSR.B .GetSer2 ;got the port?
BEQ.B .end ;yes
MOVE.L 4.W,A6 ;no..try to flush serial.device:
JSR _LVOForbid(A6)
LEA 350(A6),A0 ;ExecBase->DeviceList
LEA SerDevName(PC),A1 ;"serial.device"
JSR _LVOFindName(A6)
TST.L D0
BEQ.B .notfnd ;no serial.device!!
MOVE.L D0,A1
JSR _LVORemDevice(A6)
.notfnd JSR _LVOPermit(A6)
BSR.B .GetSer2 ;now try it again...
.end RTS
.GetSer2
MOVE.L 4.W,A6
MOVEQ #0,D0
LEA MiscResName(PC),A1
JSR _LVOOpenResource(A6)
MOVE.L D0,MiscResBase
BEQ.B .gs_err
MOVE.L D0,A6
LEA rb_Progname,A1
MOVEQ #0,D0 ;serial port
JSR _RVOAllocMiscResource(A6)
TST.L D0
BNE.B .gs_err
ST SerPortAlloc
CLR.W PrevBits
MOVE.W $DFF01C,D0
BTST #0,D0
SNE PrevBits
BTST #11,D0
SNE PrevBits+1
MOVEQ #0,D0 ;TBE
LEA MIDIOutInterrupt(PC),A1
MOVE.L 4.W,A6
JSR _LVOSetIntVector(A6)
MOVE.L D0,PrevTBE
MOVEQ #11,D0 ;RBF
LEA MIDIInInterrupt(PC),A1
JSR _LVOSetIntVector(A6)
MOVE.L D0,PrevRBF
MOVE.W #114,$DFF032 ;set baud rate 114/31250 (SERPER)
MOVE.W #$8801,$DFF09A ;RBF & TBE on!!
MOVEQ #0,D0
RTS
.gs_err MOVEQ #-1,D0
RTS
;----- Close MIDI and release serial port -----
CloseMIDI
MOVE.L MIDIinBuffer(PC),D0
BEQ.B clmskip
MOVE.L D0,A1
MOVE.L #256,D0
JSR PTFreeMem
CLR.L MIDIinBuffer
clmskip
TST.L MiscResBase
BEQ.B .fs_end
TST.B SerPortAlloc
BEQ.B .fs_end
MOVE.W #$0801,$DFF09A ;disable RBF & TBE
MOVE.L PrevTBE(PC),A1
MOVEQ #0,D0
MOVE.L 4.W,A6
JSR _LVOSetIntVector(A6)
MOVE.L PrevRBF(PC),A1
MOVEQ #11,D0
JSR _LVOSetIntVector(A6)
MOVE.W #$8000,D0
TST.B PrevBits
BEQ.B .fs1
BSET #0,D0
.fs1 TST.B PrevBits+1
BEQ.B .fs2
BSET #11,D0
.fs2 MOVE.W D0,$DFF09A ;set RBF & TBE to their prev. values
MOVE.L MiscResBase(PC),A6
MOVEQ #0,D0 ;serial port
JSR _RVOFreeMiscResource(A6)
CLR.B SerPortAlloc
CLR.B lastcmdbyte
.fs_end RTS
;----- Every time we receive a MIDI byte -----
MIDIInIntHandler
MOVE.W $DFF018,D0 ; read from serdatr
MOVE.W #$0800,$DFF09C ; intreq
MOVE.L D1,-(SP)
MOVE.L D2,-(SP)
MOVEQ #0,D1
MOVE.B 4(A1),D1 ; in to
MOVE.L D1,D2
ADDQ.B #1,D2
CMP.B 5(A1),D2 ; in from
BEQ.B gmiexit ; Buffer overflow
MOVE.L (A1),A0 ; midi in buffer
MOVE.B D0,(A0,D1.W)
MOVE.B D2,4(A1) ; MIDIinTo
MOVE.L #$40000000,D0
MOVE.L PTProcess,A1
JSR _LVOSignal(A6)
gmiexit MOVE.L (SP)+,D2
MOVE.L (SP)+,D1
RTS
;----- MIDI Transmit Buffer Empty Interrupt (Output) -----
MIDIOutIntHandler
MOVE.W #$4000,intena(A0) ;disable int.
MOVE.W #1,intreq(A0) ;clear intreq bit
RTS
CNOP 0,4
MIDIOutInterrupt
dc.l 0,0
dc.b 2,0
dc.l MIDIOutName,buffptr,MIDIOutIntHandler
CNOP 0,4
MIDIInInterrupt
dc.l 0,0
dc.b 2,0
dc.l MIDIInName,MIDIinBuffer,MIDIInIntHandler
CNOP 0,4
buffptr dc.l SerPortAlloc
PrevTBE dc.l 0
PrevRBF dc.l 0
MiscResBase dc.l 0
SerPortAlloc dc.b 0
lastcmdbyte dc.b 0
PrevBits dc.b 0
MIDIOutName dc.b 'PT MIDI Out',0
MIDIInName dc.b 'PT MIDI In',0
MiscResName dc.b 'misc.resource',0
SerDevName dc.b 'serial.device',0
EVEN
;----- read from input buffer -----
MIDIin
MOVE.B MIDIinFrom(PC),D0
CMP.B MIDIinTo(PC),D0
BNE.B migetbyt
MOVEQ #2,D1
RTS
migetbyt
MOVE.L MIDIinBuffer(PC),A0
MOVE.B (A0,D0.W),D0
ADDQ.B #1,MIDIinFrom
MOVEQ #0,D1
RTS
CheckMIDIin
TST.B MIDIFlag
BEQ.W Return3
mic_loop
BSR.B MIDIin
TST.L D1
BNE.B mic_error
BSR.B mic_ok
BRA.B mic_loop
mic_error
MOVE.B #1,MIDIError
RTS
mic_ok
CLR.B MIDIError
TST.B D0
BPL.B mic_databyte
;statusbyte here
CMP.B #$F0,D0
BHS.W MIDISysMessage
MOVE.B D0,MIDIRunStatus
MOVE.B D0,D1
AND.B #$F0,D1
MOVE.B D1,MIDIRunCommand
AND.B #$0F,D0
MOVE.B D0,MIDIRunChannel
CLR.B MIDIByteCount
RTS
mic_databyte
MOVE.B MIDIRunCommand(PC),D1
CMP.B #$80,D1
BEQ.B M_NoteOff
CMP.B #$90,D1
BEQ.B M_NoteOn
CMP.B #$A0,D1
BEQ.W M_PolyTouch
CMP.B #$B0,D1
BEQ.W M_Control
CMP.B #$C0,D1
BEQ.W M_ProgChange
CMP.B #$D0,D1
BEQ.W M_MonoTouch
CMP.B #$E0,D1
BEQ.W M_PitchBend
CMP.B #$F0,D1
BEQ.W M_SysExData
RTS
M_NoteOff
TST.B MIDIByteCount
BNE.B mnf_veloc
MOVE.B D0,MIDINote
ADDQ.B #1,MIDIByteCount
RTS
mnf_veloc
CLR.B MIDIByteCount
MOVE.B D0,MIDIVelocity
RTS
M_NoteOn
TST.B MIDIByteCount
BNE.B mno_veloc
MOVE.B D0,MIDINote
ADDQ.B #1,MIDIByteCount
RTS
mno_veloc
CLR.B MIDIByteCount
MOVE.B D0,MIDIVelocity
BEQ.B mnf_veloc
;* MidiPlay *
MOVE.B MIDINote(PC),D0
CMP.B MIDIinTrans(PC),D0
BLO.B miplskip
SUB.B MIDIinTrans(PC),D0
CMP.B #36,D0
BLS.B J_nkp
RTS
miplskip
CMP.B XMIDI_Play(PC),D0
BEQ.B J_PlaySong
CMP.B XMIDI_Pattern(PC),D0
BEQ.B J_PlayPattern
CMP.B XMIDI_Edit(PC),D0
BEQ.B J_Edit
CMP.B XMIDI_Record(PC),D0
BEQ.B J_RecordPattern
CMP.B XMIDI_Stop(PC),D0
BEQ.B J_StopIt
CMP.B XMIDI_SampleDown(PC),D0
BEQ.B J_SampleDown
CMP.B XMIDI_SampleUp(PC),D0
BEQ.B J_SampleUp
RTS
J_nkp JMP nkpskip
J_PlaySong
JMP PlaySong
J_PlayPattern
JMP PlayPattern
J_Edit JMP Edit
J_RecordPattern
JMP RecordPattern
J_StopIt
JMP StopIt
J_SampleDown JMP SampleNumDown
J_SampleUp JMP SampleNumUp
MIDIinTrans dc.b 48,0
XMIDI_Play dc.b 40 ; E
XMIDI_Pattern dc.b 38 ; D
XMIDI_Edit dc.b 43 ; G
XMIDI_Record dc.b 41 ; F
XMIDI_Stop dc.b 36 ; C
XMIDI_SampleDown dc.b 45 ; A
XMIDI_SampleUp dc.b 47 ; B
dc.b 0 ; free 0
EVEN
M_PolyTouch
TST.B MIDIByteCount
BNE.B mpt_touch
MOVE.B D0,MIDINote
ADDQ.B #1,MIDIByteCount
RTS
mpt_touch
CLR.B MIDIByteCount
MOVE.B D0,MIDITouch
RTS
M_Control
TST.B MIDIByteCount
BNE.B mc_value
MOVE.B D0,MIDIController
ADDQ.B #1,MIDIByteCount
RTS
mc_value
CLR.B MIDIByteCount
MOVE.B D0,MIDIlsb
RTS
M_ProgChange
MOVE.B D0,MIDIProgram
RTS
M_MonoTouch
MOVE.B D0,MIDITouch
RTS
M_PitchBend
TST.B MIDIByteCount
BNE.B mp_msb
MOVE.B D0,MIDIlsb
ADDQ.B #1,MIDIByteCount
RTS
mp_msb CLR.B MIDIByteCount
MOVE.B D0,MIDImsb
EXT.W D0
SUB.W #128,D0
MOVE.W CurrentPlayNote(PC),D1
SUB.W D0,D1
CMP.W #113,D1
BLS.B mp_2
MOVE.W #113,D1
mp_2 MOVE.L NoteAddr(PC),A0
MOVE.W D1,6(A0)
RTS
CNOP 0,4
NoteAddr dc.l 0
M_rts RTS
MIDISysMessage
CMP.B #$F0,D0
BEQ.B M_SysEx ; System Exclusive
CMP.B #$F1,D0
BEQ.B M_rts ; Quarter Frame (MIDI Time Code)
CMP.B #$F2,D0
BEQ.B M_SongPos ; Song Position Pointer
CMP.B #$F3,D0
BEQ.B M_SongSelect ; Song Select
CMP.B #$F4,D0
BEQ.B M_rts ; -Reserved-
CMP.B #$F5,D0
BEQ.B M_rts ; -Reserved-
CMP.B #$F6,D0
BEQ.B M_rts ; -Reserved-
CMP.B #$F7,D0
BEQ.B M_EOX ; End of System Exclusive
CMP.B #$F8,D0
BEQ.B M_rts ; MIDI Timing Clock
CMP.B #$F9,D0
BEQ.B M_rts ; -Reserved-
CMP.B #$FA,D0
BEQ.B M_Start ; Start Message
CMP.B #$FB,D0
BEQ.B M_Continue ; Continue Message
CMP.B #$FC,D0
BEQ.B M_Stop ; Stop Message
CMP.B #$FD,D0
BEQ.B M_rts ; --- Reserved ---
CMP.B #$FE,D0
BEQ.B M_rts ; Active Sensing (Each 300ms if on)
CMP.B #$FF,D0
BRA.B M_rts ; System Reset Message
M_SysEx RTS
M_SysExData RTS
M_SongPos RTS
M_SongSelect RTS
M_EOX RTS
M_Start JMP PlaySong
M_Continue RTS
M_Stop JMP StopIt
CNOP 0,4
MIDIinBuffer dc.l 0
MIDIinTo dc.b 0
MIDIinFrom dc.b 0
MIDIRunStatus dc.b $80
MIDIRunChannel dc.b 0
MIDIRunCommand dc.b 8
MIDIByteCount dc.b 0
MIDINote dc.b 0
MIDIVelocity dc.b 0
MIDITouch dc.b 0
MIDIController dc.b 0
MIDImsb dc.b 0
MIDIlsb dc.b 0
MIDIProgram dc.b 0
MIDIError dc.b 0
EVEN
;---- Sampler Screen ----
SamplerScreen
CLR.B RawKeyCode
JSR WaitForButtonUp
TST.W SamScrEnable
BNE.B ExitFromSam
MOVE.W #1,SamScrEnable
MOVE.L EditMode(PC),SaveEditMode
CLR.L EditMode
MOVE.L #TextBitplane+5560,D0
LEA CopList2Bpl4Ptr,A1
MOVE.W D0,6(A1)
SWAP D0
MOVE.W D0,2(A1)
MOVEQ #0,D0
MOVE.W #270,D1
MOVEQ #14,D2
LEA CursorSpriteData,A0
BSR.W SetSpritePos
JSR SetSamSpritePtrs
MOVE.W CopCol0+16,CopperList2+18
BSR.W SwapSamScreen
BEQ.B exisam2
BSR.W ClearSamScr
JSR DoShowFreeMem
BSR.W ShowSamNote
BSR.W ShowResamNote
BRA.W RedrawSample
ExitFromSam
JSR WaitForButtonUp
MOVE.L SamMemPtr(PC),D0
BEQ.B exisam2
MOVE.L D0,A1
BSR.W Bjarne
BSR.B FreeDecompMem2
exisam2 JSR SetDefSpritePtrs
CLR.B RawKeyCode
CLR.W SamScrEnable
MOVEQ #-1,D0
MOVE.L D0,MarkStartOfs
MOVE.L SaveEditMode(PC),EditMode
JSR SetScreenColors2
JSR SetupVUCols
BSR.W SetScrPatternPos
BSR.W ClearSamScr
JSR UpdateCursorPos
JSR SetTempo
BRA.W RedrawPattern
FreeDecompMem2
MOVE.L SamMemPtr(PC),D0
BEQ.W Return3
MOVE.L D0,A1
MOVE.L SamMemSize(PC),D0
CLR.L SamMemPtr
JSR PTFreeMem
RTS
Decompact2
MOVE.L A0,CompPtr
MOVE.L D0,CompLen
BSR.B FreeDecompMem2
MOVE.L CompPtr,A0
MOVE.L (A0),D0
MOVE.L D0,SamMemSize
MOVEQ #MEMF_PUBLIC,D1
JSR PTAllocMem
MOVE.L D0,SamMemPtr
BEQ.W OutOfMemErr
MOVE.L D0,A1
MOVE.L CompPtr,A0
MOVE.L CompLen,D0
ADDQ #4,A0
SUBQ.L #4,D0
MOVE.L D3,-(SP)
MOVEQ #-75,D3 ; 181 signed (compactor code)
dcmlop3 MOVE.B (A0)+,D1
CMP.B D3,D1
BEQ.B DecodeIt3
MOVE.B D1,(A1)+
decom3 SUBQ.L #1,D0
BGT.B dcmlop3
MOVE.L (SP)+,D3
MOVE.L SamMemPtr(PC),A1
MOVEQ #-1,D0
RTS
DecodeIt3
MOVEQ #0,D1
MOVE.B (A0)+,D1
MOVE.B (A0)+,D2
dcdlop3 MOVE.B D2,(A1)+
DBRA D1,dcdlop3
SUBQ.L #2,D0
BRA.B decom3
SwapSamScreen
LEA SampScreenData,A0
MOVE.L #SampScreenSize,D0
BSR.B Decompact2
BEQ.W Return3
bjasize=134*10
Bjarne LEA SamScrPos,A0
MOVEQ #2-1,D2
BjaLop1 MOVE.W #bjasize-1,D1 ; 134
BjaLop2 MOVE.L (A0),D0
MOVE.L (A1),(A0)+
MOVE.L D0,(A1)+
DBRA D1,BjaLop2
LEA 10240-bjasize*4(A0),A0
DBRA D2,BjaLop1
LEA CopListInsPos,A0
LEA CopperList2,A1
MOVEQ #30-1,D1
BjaLoop MOVE.W (A0),D0
MOVE.W (A1),(A0)+
MOVE.W D0,(A1)+
DBRA D1,BjaLoop
MOVEQ #-1,D0
RTS
ClearSamScr
MOVE.W #5121,TextOffset
MOVE.W #2,TextLength
MOVE.L #blnktxt,ShowTextPtr
BSR.W ShowText
MOVE.W #4964,TextOffset
MOVE.W #3,TextLength
BSR.W ShowText
MOVE.L #(130*10)-1,D0
LEA TextBitplane+5560,A0
MOVE.L A0,LineScreenPtr
MOVEQ #0,D1
clrsslp
MOVE.L D1,(A0)+
DBRA D0,clrsslp
RTS
blnktxt dc.b " "
EVEN
; --PT2.3D change: heavily modified + some optimizations
ClearSamArea
MOVEM.L ClearRegs(PC),D0-D7
; clear scrollbar background
LEA TextBitplane+(5560+2760+(40*3)),A0
MOVEM.L D0-D7,-(A0)
MOVEM.L D0-D7,-(A0)
MOVEM.L D0-D7,-(A0)
MOVEM.L D0-D7,-(A0)
MOVEM.L D0-D7,-(A0)
; clear dotted center pattern (different bitplanes)
LEA BitplaneData+6800+40,A0
LEA BitplaneData+10240+6800+40,A1
MOVEM.L D0-D4,-(A0)
MOVEM.L D0-D4,-(A1)
MOVEM.L D0-D4,-(A0)
MOVEM.L D0-D4,-(A1)
; fix trashed frame pixels on left and right edge
MOVE.B #%00000101,39(A0)
MOVE.B #%00000011,39(A1)
MOVE.B #%10100000,(A0)
MOVE.B #%01100000,(A1)
; clear sample view
MOVE.W #((64*10)/8)/4,ClearCounter
LEA TextBitplane+5560,A0
MOVE.L A0,LineScreenPtr
LEA 64*10*4(A0),A0
clrsare MOVEM.L D0-D7,-(A0)
MOVEM.L D0-D7,-(A0)
MOVEM.L D0-D7,-(A0)
MOVEM.L D0-D7,-(A0)
SUBQ.W #1,ClearCounter
BNE.W clrsare
RTS
CNOP 0,4
ClearRegs dcb.l 8,0
ClearCounter dc.w 0
CheckSamGadgets
MOVE.W MouseX2(PC),D0
MOVE.W MouseY2(PC),D1
CMP.W #139,D1
BLO.B SamTopBar
CMP.W #139+64,D1
BLO.W SamplePressed
CMP.W #201+11,D1
BLO.W SamDragBar
CMP.W #201+22,D1
BLO.B SamMenu1
CMP.W #201+33,D1
BLO.B SamMenu2
CMP.W #201+44,D1
BLO.B SamMenu3
CMP.W #201+66,D1
BLO.W SamMenu4
RTS
SamTopBar
CMP.W #32,D0
BLO.W ExitFromSam
RTS
SamMenu1
CMP.W #32,D0
BLO.W Return3
CMP.W #96,D0
BLO.W PlayWaveform
CMP.W #176,D0
BLO.W ShowRange
CMP.W #246,D0
BLO.W ZoomOut
BRA.W DispBox
SamMenu2
CMP.W #32,D0
BLO.W StopPlaying
CMP.W #96,D0
BLO.W PlayDisplay
CMP.W #176,D0
BLO.W ShowAll
CMP.W #246,D0
BLO.W RangeAll
BRA.W LoopToggle
SamMenu3
CMP.W #32,D0
BLO.W StopPlaying
CMP.W #96,D0
BLO.W PlayRange
CMP.W #116,D0
BLO.W CurToStart
CMP.W #136,D0
BLO.W CurToEnd
CMP.W #176,D0
BLO.W SwapBuffer
CMP.W #246,D0
BLO.W Sampler
BRA.W SetSamNote
SamMenu4
CMP.W #32,D0
BLO.W SamCut
CMP.W #64,D0
BLO.W SamCopy
CMP.W #96,D0
BLO.W SamPaste
CMP.W #136,D0
BLO.W RampVolume
CMP.W #176,D0
BLO.W TuningTone
CMP.W #246,D0
BLO.W Resample
BRA.W SetResamNote
PlayWaveform
; --PT2.3D bug fix: instant channel muting
LEA audchan1toggle,A0
MOVEQ #0,D0
MOVE.W PattCurPos(PC),D0
DIVU.W #6,D0
LSL.B #3,D0
MOVE.W (A0,D0.W),D0
BEQ.B pwskip
JSR PlayNote
pwskip JMP WaitForButtonUp
PlayDisplay
; --PT2.3D bug fix: instant channel muting
LEA audchan1toggle,A0
MOVEQ #0,D0
MOVE.W PattCurPos(PC),D0
DIVU.W #6,D0
LSL.B #3,D0
MOVE.W (A0,D0.W),D0
BNE.B pdskip
JMP WaitForButtonUp
pdskip ; ----------------------------------------
LEA SampleInfo(PC),A0
MOVE.L SamOffset(PC),StartOfs
MOVE.L SamDisplay(PC),D0
LSR.L #1,D0
MOVE.W D0,0(A0) ; length
CLR.W 4(A0) ; repeat
MOVE.W #1,6(A0) ; replen
MOVE.W PlayInsNum,D0
MOVE.W D0,-(SP)
MOVE.B D0,PlayInsNum2
CLR.W PlayInsNum
JSR PlayNote
MOVE.W (SP)+,PlayInsNum
BSR.W ShowSampleInfo
JMP WaitForButtonUp
PlayRange
; --PT2.3D bug fix: instant channel muting
LEA audchan1toggle,A0
MOVEQ #0,D0
MOVE.W PattCurPos(PC),D0
DIVU.W #6,D0
LSL.B #3,D0
MOVE.W (A0,D0.W),D0
BNE.B prskip
JMP WaitForButtonUp
prskip ; ----------------------------------------
MOVE.L MarkStartOfs(PC),D1
BMI.W NoRangeError
MOVE.L MarkEndOfs(PC),D0
CMP.L D0,D1
BEQ.W LargerRangeError
LEA SampleInfo(PC),A0
MOVE.L D1,StartOfs
SUB.L D1,D0
LSR.L #1,D0
MOVE.W D0,0(A0) ; length
CLR.W 4(A0) ; repeat
MOVE.W #1,6(A0) ; replen
MOVE.W PlayInsNum,D0
MOVE.W D0,-(SP)
MOVE.B D0,PlayInsNum2
CLR.W PlayInsNum
JSR PlayNote
MOVE.W (SP)+,PlayInsNum
BSR.W ShowSampleInfo
JMP WaitForButtonUp
StopPlaying
BRA.W TurnOffVoices
CNOP 0,4
StartOfs dc.l 0
; This is only called once when the sample view size changes,
; so speed is not a concern here.
SetSamPosDelta
MOVEM.L D0-D1,-(SP)
MOVE.L SamDisplay(PC),D0 ; 17 bits
MOVEQ #15,D1 ; max fractional bits (32-17)
LSL.L D1,D0
MOVE.L #314,D1
JSR DIVU32
MOVE.L D0,SamPosDelta ; sample pos delta (17.15 fixed-point)
MOVEM.L (SP)+,D0-D1
RTS
ShowRange
; --PT2.3D bug fix: Show error if trying to zoom on empty sample
TST.B EmptySampleFlag
BNE.W EmptySampleError
srskip ; --------------------------------------------------------------
MOVE.L MarkStartOfs(PC),D0
BMI.W NoRangeError
MOVE.L MarkEndOfs(PC),D1
CMP.L D1,D0
BEQ.W LargerRangeError
SUB.L D0,D1
BNE.B shorano
MOVEQ #1,D1
shorano MOVE.L D1,SamDisplay
MOVE.L D0,SamOffset
BSR.W SetSamPosDelta
MOVEQ #-1,D0
MOVE.L D0,MarkStartOfs
CLR.W MarkStart
BSR.W DisplaySample
JMP WaitForButtonUp
ZoomOut
MOVE.L SamDisplay(PC),D0
MOVE.L SamLength(PC),D1
CMP.L D0,D1
BEQ.W Return3 ; don't attempt to zoom out if already 100% zoomed out
MOVE.L SamOffset(PC),D2
MOVE.L D0,D3
ADD.L D3,D3
CMP.L D1,D3
BHI.B ShowAll
LSR.L #1,D0
CMP.L D2,D0
BLO.B zoomou2
MOVEQ #0,D0
zoomou2 SUB.L D0,D2
MOVE.L D2,D0
ADD.L D3,D0
CMP.L D1,D0
BLS.B zoomou3
SUB.L D3,D1
MOVE.L D1,D2
zoomou3 MOVE.L D2,SamOffset
MOVE.L D3,SamDisplay
BSR.W SetSamPosDelta
BSR.W OffsetToMark
MOVE.L MarkStartOfs(PC),D0
CMP.L MarkEndOfs(PC),D0
BNE.B zoomouo
MOVEQ #-1,D0
MOVE.L D0,MarkStartOfs
zoomouo BSR.W DisplaySample
JMP WaitForButtonUp
ShowAll
CLR.L SamOffset
MOVE.L SamLength(PC),SamDisplay
BSR.W SetSamPosDelta
BSR.W OffsetToMark
MOVE.L MarkStartOfs(PC),D0
CMP.L MarkEndOfs(PC),D0
BNE.B shoallo
MOVEQ #-1,D0
MOVE.L D0,MarkStartOfs
CLR.W MarkStart
shoallo BSR.W DisplaySample
JMP WaitForButtonUp
RangeAll
BSR.W InvertRange
MOVE.W #3,MarkStart
MOVE.W #316,MarkEnd
BSR.W MarkToOffset
ranall2 BSR.W InvertRange
JMP WaitForButtonUp
CurToStart
BSR.W InvertRange
MOVEQ #3,D0
MOVE.W D0,MarkStart
MOVE.W D0,MarkEnd
MOVE.L SamOffset(PC),D0
MOVE.L D0,MarkStartOfs
MOVE.L D0,MarkEndOfs
BRA.B ranall2
CurToEnd
BSR.W InvertRange
MOVE.W #316,D0
MOVE.W D0,MarkStart
MOVE.W D0,MarkEnd
MOVE.L SamOffset(PC),D0
ADD.L SamDisplay(PC),D0
MOVE.L D0,MarkStartOfs
MOVE.L D0,MarkEndOfs
BRA.B ranall2
SwapBuffer
MOVE.W InsNum(PC),D1
BEQ.W NotSampleNull
LSL.W #2,D1
LEA SongDataPtr(PC),A0
LEA (A0,D1.W),A0
MOVE.L CopyBufPtr(PC),D0
MOVE.L (A0),CopyBufPtr
MOVE.L D0,(A0)
MOVE.L D0,A1
CLR.W (A1)
MOVE.L CopyBufSize(PC),D0
MOVE.L 124(A0),CopyBufSize
MOVE.L D0,124(A0)
MOVE.L SongDataPtr(PC),A0
MOVE.W InsNum(PC),D1
MULU.W #30,D1
LEA 12(A0,D1.W),A0
LSR.L #1,D0
MOVE.W D0,(A0)
MOVE.L RepBuf(PC),D0
MOVE.L 4(A0),RepBuf
MOVE.L D0,4(A0)
MOVE.W RepBuf2(PC),D0
MOVE.W 2(A0),RepBuf2
TST.B D0
BNE.B swabuf2
MOVEQ #$40,D0
swabuf2 MOVE.W D0,2(A0)
BSR.W TurnOffVoices
BSR.W ValidateLoops
BSR.W ShowSampleInfo
JSR UpdateRepeats
BSR.W RedrawSample
JMP WaitForButtonUp
CNOP 0,4
RepBuf dc.l 1
RepBuf2 dc.w $0040
;----
NoRangeError
LEA NoRangeText(PC),A0
nres2 BSR.W ShowStatusText
JMP SetErrorPtrCol
LargerRangeError
LEA LargerRangeText(PC),A0
BRA.B nres2
SetCursorError
LEA SetCursorText(PC),A0
BRA.B nres2
BufIsEmptyError
LEA BufIsEmptyText(PC),A0
BRA.B nres2
EmptySampleError
LEA EmptySampleText(PC),A0
BRA.B nres2
NoRangeText dc.b "no range selected",0
LargerRangeText dc.b "set larger range",0
SetCursorText dc.b "set cursor pos",0
BufIsEmptyText dc.b "buffer is empty",0
EmptySampleText dc.b "sample is empty",0
;----
DispBox
RTS
LoopToggle
JSR WaitForButtonUp
MOVE.W InsNum(PC),D1
BEQ.W NotSampleNull
MOVE.L SongDataPtr(PC),A0
MULU.W #30,D1
LEA 12(A0,D1.W),A0
TST.W (A0) ; sample length == 0?
BEQ.B LTSmpEmpty ; yup, don't allow loop toggle...
TST.W LoopOnOffFlag
BEQ.B loopton
MOVE.L 4(A0),SavSamInf
MOVEQ #1,D0
MOVE.L D0,4(A0)
BSR.W TurnOffVoices
looptlo BSR.W ShowSampleInfo
JSR UpdateRepeats
BRA.W DisplaySample
loopton BSR.W TurnOffVoices
MOVE.L SavSamInf(PC),D0
BNE.B loopto2
MOVE.W (A0),D0
loopto2 MOVE.L D0,4(A0)
BRA.B looptlo
LTSmpEmpty RTS
ShowLoopToggle
LEA ToggleOFFText,A0
TST.W LoopOnOffFlag
BEQ.B sltskip
LEA ToggleONText,A0
sltskip MOVEQ #3,D0
MOVE.W #9076,D1
BRA.W ShowText3
CNOP 0,4
SavSamInf dc.l 0
LoopOnOffFlag dc.w 0
SetSamNote
BSR.W ShowResamNote
MOVE.W #9516,TextOffset
MOVE.W #3,TextLength
MOVE.L #SpcNoteText,ShowTextPtr
BSR.W ShowText
MOVE.W #1,SamNoteType
MOVE.L #SampleNote,SplitAddress
JMP WaitForButtonUp
SetResamNote
BSR.W ShowSamNote
MOVE.W #9956,TextOffset
MOVE.W #3,TextLength
MOVE.L #SpcNoteText,ShowTextPtr
BSR.W ShowText
MOVE.W #2,SamNoteType
MOVE.L #ResampleNote,SplitAddress
JMP WaitForButtonUp
ResampleText dc.b "Resample?",0
ResamplingText dc.b "Resampling...",0
EVEN
; 128kB compatible and optimized by 8bitbubsy.
; Almost twice as fast as the original routine,
; and has slightly better resampling precision.
Resample
LEA ResampleText(PC),A0
JSR AreYouSure
BNE.W Return3
JSR StorePtrCol
JSR SetWaitPtrCol
LEA ResamplingText(PC),A0
BSR.W ShowStatusText
LEA SongDataPtr(PC),A0
MOVE.W InsNum(PC),D1
BEQ.W NotSampleNull
LSL.W #2,D1
LEA (A0,D1.W),A0
MOVE.L (A0),D0
BEQ.W ERC2
MOVE.L D0,A2
MOVE.L 124(A0),D6
CMP.L #2,D6
BLS.W ERC2
; get resample (target) period from selected note + finetune
MOVE.L SongDataPtr(PC),A0
MOVE.W InsNum(PC),D1
BNE.B rssmpok
MOVE.W LastInsNum(PC),D1
rssmpok
MULU.W #30,D1
MOVEQ #0,D0
MOVE.B 12+2(A0,D1.W),D0 ; finetune
AND.B #$0F,D0
LSL.B #2,D0
LEA ftunePerTab(PC),A0
MOVE.L (A0,D0.W),A0
MOVEQ #0,D1
MOVE.W ResampleNote(PC),D1
ADD.W D1,D1
MOVE.W (A0,D1.W),D1
BEQ.W ERC2 ; can't have a resample period of 0!
; D1.L = resample period (108..907)
; get reference period from tuning note
LEA PeriodTable(PC),A0
MOVEQ #0,D5
MOVE.W TuneNote,D5
ADD.W D5,D5
MOVE.W (A0,D5.W),D5
BEQ.W ERC2 ; can't have a reference period of 0!
; D5.L = reference period (113..856)
; calculate resample delta
MOVE.L D5,D0
SWAP D0
CLR.W D0
JSR DIVU32
MOVE.L D0,D4
; D4.L = 16.16fp resampling delta
; calculate new sample length (write length)
MOVE.L D6,D0
JSR MULU32
MOVE.L D5,D1
JSR DIVU32
MOVE.L D0,D7
AND.L #~1,D7 ; evenify
CMP.L #$1FFFE,D7
BHI.B resamskip
CMP.L #2,D7
BLO.W ERC2 ; can't have a sample length of 2 or shorter!
BRA.B resamok
resamskip
MOVE.L #$1FFFE,D7 ; max sample length
resamok
; D7 = (oldSampleLen * resamplePeriod) / referencePeriod
; allocate memory for new sample
MOVE.L D7,D0
MOVE.L #MEMF_CHIP,D1
JSR PTAllocMem
TST.L D0
BEQ.W SamMemError
MOVE.L D0,A1
MOVE.L D0,A3
; clear last byte (just in case)
CLR.B -1(A1,D7.L)
MOVE.L A2,A0 ; old sample data pointer
MOVE.L D6,A6 ; old sample length
MOVE.L A1,A5
ADD.L D7,A5 ; new end-of-sample address
MOVEQ #0,D1 ; set frac to 0
MOVEQ #0,D6 ; set pos to 0
MOVE.W D4,D3 ; D3.W = delta lo (16-bit)
CLR.W D4
SWAP D4 ; D4.L = delta hi (16-bit)
BSR.W TurnOffVoices
resampleloop
MOVE.B (A0,D6.L),D2 ; linear interpolation
EXT.W D2
MOVE.B 1(A0,D6.L),D0
EXT.W D0
SUB.W D2,D0
MOVE.W D1,D5
LSR.W #1,D5 ; D5.W = frac/2 (0..32767)
MULS.W D5,D0
SWAP D0
ROL.L #1,D0
ADD.W D0,D2
MOVE.B D2,(A1)+
ADD.W D3,D1
ADDX.L D4,D6
CMP.L A5,A1 ; destination address beyond end?
BHS.B resampledone ; yes, we're done
CMP.L A6,D6 ; source address beyond end?
BLO.B resampleloop ; nope, keep resampling
resampledone
; free old sample memory
MOVE.L A2,A1
MOVE.L A6,D0
JSR PTFreeMem
; update sample attributes and redraw sample
MOVE.W InsNum(PC),D1
LSL.W #2,D1
LEA SongDataPtr(PC),A0
LEA (A0,D1.W),A0
MOVE.L A3,(A0)
MOVE.L D7,124(A0)
MOVE.L SongDataPtr(PC),A0
MOVE.W InsNum(PC),D1
MULU.W #30,D1
LEA 12(A0,D1.W),A0
LSR.L #1,D7 ; len/2 -> (A0)
MOVE.W D7,(A0)
CLR.B 2(A0) ; clear finetune
CLR.W 4(A0) ; clear repeat
MOVE.W #1,6(A0) ; replen=1
JSR RestorePtrCol
BSR.W ClearSamStarts
BSR.W ShowSampleInfo
BSR.W ShowAllRight
BRA.W RedrawSample
ERC2
JMP ErrorRestoreCol
SamCut ; fixed in PT2.3E to be 128kB compatible
CLR.B RawKeyCode
MOVE.L MarkStartOfs(PC),D0
BMI.W NoRangeError
CMP.L MarkEndOfs(PC),D0
BEQ.W LargerRangeError
TST.B CutToBufFlag
BEQ.B samcut2
BSR.W SamCopy
samcut2 BSR.W TurnOffVoices
LEA SongDataPtr(PC),A0
MOVE.W InsNum(PC),D1
BEQ.W NotSampleNull
LSL.W #2,D1
LEA (A0,D1.W),A0
MOVE.L (A0),D0
BEQ.W EmptySampleError
MOVE.L 124(A0),D2
CMP.L #2,D2
BLO.W EmptySampleError
MOVE.L D0,A1
MOVE.L D0,A2 ; sample start
MOVE.L D0,A3
MOVE.L D0,A4
MOVE.L D0,A5
ADD.L MarkStartOfs(PC),A3 ; mark start
MOVE.L MarkEndOfs(PC),D0
SUB.L MarkStartOfs(PC),D0
CMP.L D2,D0
BHS.W Destroy
MOVE.L MarkEndOfs(PC),D0
CMP.L D2,D0
BLO.B samsome
MOVE.L D2,D0
SUBQ.L #1,D0
samsome ADD.L D0,A4 ; mark end
ADD.L D2,A5 ; sample end
MOVE.L A3,D0
SUB.L A2,D0
ADD.L A5,D0
SUB.L A4,D0
BNE.B sacoklen
MOVEQ #0,D3
MOVEQ #0,D4
BRA.B sacfree
sacoklen
MOVE.L D0,D3
MOVEQ #MEMF_CHIP,D1
JSR PTAllocMem
MOVE.L D0,D4
BEQ.W OutOfMemErr ; No memory
MOVE.L D0,A0
MOVE.L A2,A1
MOVE.L A3,D0
SUB.L A2,D0
BRA.B sacskp1
saclop1 MOVE.B (A2)+,(A0)+
sacskp1
SUBQ.L #1,D0
BPL.B saclop1
MOVE.L A5,D0
SUB.L A4,D0
BRA.B sacskp2
smclop2 MOVE.B (A4)+,(A0)+
sacskp2
SUBQ.L #1,D0
BPL.B smclop2
sacfree MOVE.L D2,D0
JSR PTFreeMem
MOVE.W InsNum(PC),D1
LSL.W #2,D1
LEA SongDataPtr(PC),A0
LEA (A0,D1.W),A0
MOVE.L D4,(A0)
MOVE.L D3,124(A0)
MOVE.L D4,SamStart
MOVE.L D3,SamLength
MOVE.L SamOffset(PC),D4
ADD.L SamDisplay(PC),D4
CMP.L D3,D4
BLO.B samcuto ; display ok
MOVE.L SamDisplay(PC),D4
CMP.L D3,D4
BLO.B samnils ; if display < length, move offset
samsall CLR.L SamOffset ; else show all
MOVE.L D3,SamDisplay
BSR.W SetSamPosDelta
BRA.B samcuto
samnils MOVE.L D3,D4
SUB.L SamDisplay(PC),D4
BMI.B samsall ; if offset < 0, show all
MOVE.L D4,SamOffset
samcuto MOVE.L SongDataPtr(PC),A0
MOVE.W InsNum(PC),D1
MULU.W #30,D1
LEA 12(A0,D1.W),A0
MOVE.L D3,D4
LSR.L #1,D3
MOVE.W D3,(A0)
MOVE.W 4(A0),D0
CMP.W D3,D0
BLS.B samcuxx
MOVEQ #1,D0
MOVE.L D0,4(A0)
BRA.B samcuex
samcuxx ADD.W 6(A0),D0
CMP.W D3,D0
BLS.B samcuex
SUB.W 4(A0),D3
MOVE.W D3,6(A0)
samcuex
MOVE.L MarkStartOfs(PC),MarkEndOfs
BSR.W ClearSamStarts
BSR.W ValidateLoops
BSR.W ShowSampleInfo
BRA.W DisplaySample
SamCopy ; was already 128kB compliant (wow)
CLR.B RawKeyCode
MOVE.L MarkStartOfs(PC),D0
BMI.W NoRangeError
CMP.L MarkEndOfs(PC),D0
BEQ.W LargerRangeError
LEA SongDataPtr(PC),A0
MOVE.W InsNum(PC),D1
BEQ.W NotSampleNull
LSL.W #2,D1
LEA (A0,D1.W),A0
MOVE.L (A0),D0
BEQ.W EmptySampleError
MOVE.L 124(A0),D2
BEQ.W EmptySampleError
MOVE.L D0,A3
MOVE.L D0,A4
ADD.L MarkStartOfs(PC),A3 ; mark start
MOVE.L MarkEndOfs(PC),D0 ; mark end
CMP.L D2,D0
BLO.B csamsom
MOVE.L D2,D0
SUBQ.L #1,D0
csamsom ADD.L D0,A4
BSR.B FreeCopyBuf
MOVE.L A4,D0
SUB.L A3,D0
ADDQ.L #1,D0
MOVE.L D0,CopyBufSize
MOVEQ #MEMF_CHIP,D1
JSR PTAllocMem
MOVE.L D0,CopyBufPtr
BEQ.W OutOfMemErr ; No memory
MOVE.L D0,A5
csamlop MOVE.B (A3)+,(A5)+
CMP.L A4,A3
BLS.B csamlop
BSR.W InvertRange
BSR.W InvertRange
JMP WaitForButtonUp
FreeCopyBuf
MOVE.L CopyBufPtr(PC),D0
BEQ.W Return3
MOVE.L D0,A1
MOVE.L CopyBufSize(PC),D0
JSR PTFreeMem
CLR.L CopyBufPtr
RTS
CNOP 0,4
CopyBufPtr dc.l 0
CopyBufSize dc.l 0
SamPaste ; fixed in PT2.3E to be 128kB compatible
CLR.B RawKeyCode
LEA SongDataPtr(PC),A0
MOVE.W InsNum(PC),D1
BEQ.W NotSampleNull
LSL.W #2,D1
LEA (A0,D1.W),A0
MOVEQ #0,D2
MOVE.L (A0),D0
BEQ.B sapanul
MOVE.L 124(A0),D2
sapanul MOVE.L D0,A2
TST.L D0
BEQ.B sepaskip
MOVE.L MarkStartOfs(PC),D0
BMI.W SetCursorError
sepaskip
MOVE.L CopyBufPtr(PC),D3
BEQ.W BufIsEmptyError
MOVE.L D3,A3
MOVE.L CopyBufSize(PC),D3
BEQ.W BufIsEmptyError
MOVE.L D3,D4 ; copysize
ADD.L D2,D4 ; + origsize
CMP.L #$1FFFE,D4 ; 128kb patch
BLO.B sapaok
MOVE.L #$1FFFE,D4 ; 128kb patch
sapaok MOVE.L D4,D0
MOVE.L #MEMF_CHIP!MEMF_CLEAR,D1
JSR PTAllocMem
TST.L D0
BEQ.W OutOfMemErr
MOVE.L D0,A4
MOVEQ #0,D0
TST.L D2
BEQ.B sapask1
MOVE.L MarkStartOfs(PC),D0
sapask1 MOVE.L D0,MarkStartOfs
MOVE.L A2,A1
MOVE.L D2,D1
MOVE.L A4,A5
MOVE.L A4,A0
ADD.L D4,A0
; D0 = paste position
; A0 = end of new sample
; A1/D1 = copy of A2/D2
; A2/D2 = original sample
; A3/D3 = copy buffer
; A4/D4 = new sample
; A5 = copy of A4
BRA.B sapask2
sapalp1 MOVE.B (A2)+,(A4)+ ; copy first part
CMP.L A0,A4
BHS.B sapaski
SUBQ.L #1,D2
sapask2
SUBQ.L #1,D0
BPL.B sapalp1
BRA.B sapask3
sapalp2 MOVE.B (A3)+,(A4)+ ; copy from buffer
CMP.L A0,A4
BHS.B sapaski
sapask3
SUBQ.L #1,D3
BPL.B sapalp2
TST.L D2
BEQ.B sapaski
BMI.B sapaski
sapalp3 MOVE.B (A2)+,(A4)+ ; copy last part
CMP.L A0,A4
BHS.B sapaski
SUBQ.L #1,D2
BNE.B sapalp3
sapaski MOVE.L D1,D0
BEQ.B .skip
JSR PTFreeMem
.skip MOVE.W InsNum(PC),D1
LSL.W #2,D1
LEA SongDataPtr(PC),A0
LEA (A0,D1.W),A0
MOVE.L A5,(A0)
MOVE.L D4,124(A0)
MOVE.L SongDataPtr(PC),A0
MOVE.W InsNum(PC),D1
MULU.W #30,D1
LEA 12(A0,D1.W),A0
LSR.L #1,D4
MOVE.W D4,(A0)
MOVE.L MarkStartOfs(PC),MarkEndOfs
BSR.W OffsetToMark
BSR.W ClearSamStarts
BSR.W ShowSampleInfo
BRA.W RedrawSample
RampVolume
BSR.W HideLoopSprites ; -PT2.3D bug fix
ST VolToolBoxShown ; --
LEA TextBitplane+6209,A0
MOVEQ #33-1,D3
ravlap2 MOVEQ #17-1,D2
ravlap1 CLR.B (A0)+
DBRA D2,ravlap1
LEA 23(A0),A0
DBRA D3,ravlap2
LEA VolBoxPos,A0
LEA VolBoxData,A1
MOVEQ #2-1,D4
ravlop3 MOVEQ #33-1,D3
ravlop2 MOVEQ #17-1,D2
ravlop1 MOVE.B (A1)+,(A0)+
DBRA D2,ravlop1
ADDQ #1,A1
LEA 23(A0),A0
DBRA D3,ravlop2
LEA 8920(A0),A0
DBRA D4,ravlop3
BSR.W ShowVolSliders
JSR WaitForButtonUp
ravloop
TST.W AbortDecFlag ; --PT2.3D bug fix
BNE.B ravskip ; --
BTST #2,$DFF016 ; right mouse button
BEQ.B ExitVolBox
ravskip ; --
JSR WaitForButtonUp ; --
CLR.W AbortDecFlag
ravskip2 ; --
JSR DoKeyBuffer
MOVE.B RawKeyCode(PC),D2
CMP.B #68,D2
BEQ.B ExitVolBox
BTST #6,$BFE001 ; left mouse button
BNE.B ravloop
MOVE.W MouseX(PC),D0
MOVE.W MouseY(PC),D1
; -PT2.3D bug fix: toggle vol toolbox with same button
CMP.W #245,D1
BLO.B ravskip3
CMP.W #96,D0
BLO.B ravskip3
CMP.W #135,D0
BHI.B ravskip3
BRA.B ExitVolBox
ravskip3
; ----------------------------------------------------
CMP.W #72,D0
BLO.B ravloop
CMP.W #72+136,D0
BHS.B ravloop
CMP.W #155,D1
BLO.B ravloop
CMP.W #166,D1
BLO.B Vol1Slider
CMP.W #177,D1
BLO.W Vol2Slider
CMP.W #188,D1
BLO.W VolGadgs
BRA.B ravloop
ExitVolBox
LEA VolBoxPos,A0
MOVEQ #2-1,D2
revlap3 MOVEQ #33-1,D1
revlap2 MOVEQ #17-1,D0
revlap1 CLR.B (A0)+
DBRA D0,revlap1
LEA 23(A0),A0
DBRA D1,revlap2
LEA 8920(A0),A0
DBRA D2,revlap3
SF VolToolBoxShown ; --PT2.3D bug fix
BRA.W DisplaySample
Vol1Slider
CMP.W #167,D0
BHI.B v1skip
LEA Vol1(PC),A4
MOVEQ #0,D7
v1loop1 BTST #6,$BFE001 ; left mouse button
BNE.W ravloop
MOVE.W MouseX(PC),D0
CMP.W D7,D0
BEQ.B v1loop1
MOVE.W D0,D7
SUB.W #107,D0
BPL.B v1skp2
MOVEQ #0,D0
v1skp2 CMP.W #60,D0
BLS.B v1skp3
MOVEQ #60,D0
v1skp3 MULU.W #200,D0
DIVU.W #60,D0
MOVE.W D0,(A4)
shvosl BSR.W ShowVolSliders
BRA.B v1loop1
v1skip MOVE.W #180,LineCurX
MOVE.W #163,LineCurY
MOVE.W #6342,TextOffset
JSR GetDec3Dig
TST.W AbortDecFlag
BNE.B shvosl
CMP.W #200,D0
BLS.B v1sk2
MOVE.W #200,D0
v1sk2 MOVE.W D0,Vol1
BRA.B shvosl
Vol2Slider
CMP.W #167,D0
BHI.B v2skip
LEA Vol2(PC),A4
MOVEQ #0,D7
BRA.B v1loop1
v2skip MOVE.W #180,LineCurX
MOVE.W #174,LineCurY
MOVE.W #6782,TextOffset
JSR GetDec3Dig
TST.W AbortDecFlag
BNE.B shvosl
CMP.W #200,D0
BLS.B v2sk2
MOVE.W #200,D0
v2sk2 MOVE.W D0,Vol2
BRA.W shvosl
VolGadgs
CMP.W #100,D0
BLO.W DoRampVol
CMP.W #144,D0
BLO.W Normalize
CMP.W #154,D0
BLO.B SetRampDown
CMP.W #164,D0
BLO.B SetRampUp
CMP.W #174,D0
BLO.B SetRampUnity
BRA.W ExitVolBox
SetRampDown
MOVE.W #100,Vol1
CLR.W Vol2
BRA.B sru2
SetRampUp
CLR.W Vol1
MOVE.W #100,Vol2
BRA.B sru2
SetRampUnity
MOVE.W #100,Vol1
MOVE.W #100,Vol2
sru2 BSR.B ShowVolSliders
JSR WaitForButtonUp
BRA.W ravloop
ShowVolSliders
LEA TextBitplane+6209,A0
MOVEQ #22-1,D3
ravlip2 MOVEQ #13-1,D2
ravlip1 CLR.B (A0)+
DBRA D2,ravlip1
LEA 27(A0),A0
DBRA D3,ravlip2
MOVEQ #0,D4
MOVE.W Vol1(PC),D4
MOVEQ #20,D5
BSR.B OneSlider
MOVEQ #0,D4
MOVE.W Vol2(PC),D4
MOVEQ #31,D5
BSR.B OneSlider
MOVE.W Vol1(PC),WordNumber
MOVE.W #6342,TextOffset
BSR.W Print3DecDigits
MOVE.W Vol2(PC),WordNumber
MOVE.W #6782,TextOffset
BRA.W Print3DecDigits
OneSlider
MOVE.W D4,D6
ADD.W D4,D4
ADD.W D6,D4
AND.L #$FFFF,D4
DIVU.W #10,D4
ADD.W #105,D4
MOVEQ #3-1,D6
oneslop MOVE.W D4,D0
MOVE.W D4,D2
ADDQ.W #5,D2
MOVE.W D5,D1
MOVE.W D5,D3
BSR.W DrawLine
ADDQ.W #1,D5
DBRA D6,oneslop
RTS
; 128kB compatible, and heavily optimized by 8bitbubsy.
; Uses 10.22fp deltas instead of several DIV+MULs.
;
; Benchmark:
; - Before: ~18 seconds (128kB sample) on stock Amiga 500
; - Now: ~4 seconds
DoRampVol
CLR.B RawKeyCode
LEA SongDataPtr(PC),A0
MOVE.W InsNum(PC),D1
BEQ.W nozerr1
LSL.W #2,D1
LEA (A0,D1.W),A0
MOVEQ #0,D2
MOVE.L (A0),D0
BEQ.W nozerr2
MOVE.L D0,A2
MOVE.L 124(A0),D2
BEQ.W nozerr2
MOVE.L MarkStartOfs(PC),D0
BMI.B drvskip
MOVE.L MarkEndOfs(PC),D1
SUB.L D0,D1
BEQ.B drvskip
ADD.L D0,A2
MOVE.L D1,D2
ADDQ.L #1,D2
drvskip JSR StorePtrCol
JSR SetWaitPtrCol
; --------------------
MOVE.L D2,D7
; --------------------
; Prepare some stuff...
; --------------------
MOVEQ #0,D5 ; Rescale volume range (for DIV -> ASR)
MOVEQ #0,D6
MOVE.W Vol1(PC),D5
MOVE.W Vol2(PC),D6
LSL.L #7,D5
LSL.L #7,D6
DIVU.W #100,D5
DIVU.W #100,D6
AND.L #$FFFF,D5 ; D5.L = Vol1 (0..256)
AND.L #$FFFF,D6 ; D6.L = Vol2 (0..256)
; --------------------
MOVEQ #22,D3 ; fractional bits (max)
; --------------------
MOVE.L D6,D0
LSL.L D3,D0
MOVE.L D7,D1
JSR DIVU32
MOVE.L D0,A5 ; 10.22fp delta from Vol2
; --------------------
MOVE.L D5,D0
LSL.L D3,D0
MOVE.L D7,D1
JSR DIVU32
MOVE.L D0,A6 ; 10.22fp delta from Vol1
; --------------------
MOVE.L D5,D6
LSL.L D3,D6
MOVEQ #0,D5
MOVEQ #127,D4
MOVEQ #-128,D2
; --------------------
drvloop MOVE.L D5,D1
ADD.L D6,D1
SWAP D1
LSR.W #6,D1
MOVE.B (A2),D0
EXT.W D0
MULS.W D1,D0
ASR.W #7,D0
CMP.W D4,D0
BGT.B drvhi
CMP.W D2,D0
BLT.B drvlo
drvset MOVE.B D0,(A2)+
ADD.L A5,D5
SUB.L A6,D6
SUBQ.L #1,D7
BNE.B drvloop
; --------------------
JSR RestorePtrCol
BRA.W ExitVolBox
; --------------------
drvhi MOVE.B D4,D0
BRA.B drvset
drvlo MOVE.B D2,D0
BRA.B drvset
nozerr1 BSR.W NotSampleNull
BRA.W ravloop
nozerr2 BSR.W EmptySampleError
BRA.W ravloop
Normalize
CLR.B RawKeyCode
LEA SongDataPtr(PC),A0
MOVE.W InsNum(PC),D1
BEQ.B nozerr1
LSL.W #2,D1
LEA (A0,D1.W),A0
MOVEQ #0,D2
MOVE.L (A0),D0
BEQ.B nozerr2
MOVE.L D0,A2
MOVE.L 124(A0),D2
BEQ.B nozerr2
MOVE.L MarkStartOfs(PC),D0
BMI.B nozskip
MOVE.L MarkEndOfs(PC),D1
SUB.L D0,D1
BEQ.B nozskip
ADD.L D0,A2
MOVE.L D1,D2
ADDQ.L #1,D2
nozskip JSR StorePtrCol
JSR SetWaitPtrCol
MOVEQ #0,D0
nozloop MOVE.B (A2)+,D1
EXT.W D1
BPL.B nozskp2
NEG.W D1
nozskp2 CMP.W D0,D1
BLO.B nozskp3
MOVE.W D1,D0
nozskp3 SUBQ.L #1,D2
BNE.B nozloop
JSR RestorePtrCol
TST.W D0
BEQ.W SetRampUnity
CMP.W #127,D0
BHI.W SetRampUnity
CMP.W #64,D0
BLO.B nozmax
MOVE.L #127*100,D1
DIVU.W D0,D1
MOVE.W D1,Vol1
MOVE.W D1,Vol2
BRA.W sru2
nozmax MOVE.W #200,Vol1
MOVE.W #200,Vol2
BRA.W sru2
Vol1 dc.w 100
Vol2 dc.w 100
TuningTone
JSR WaitForButtonUp
CLR.B RawKeyCode
TST.W TToneFlag
BNE.W TToneOff
TST.L RunMode
BNE.W ttrts
MOVE.W #1,TToneFlag
MOVEQ #0,D2
MOVE.W PattCurPos(PC),D2
DIVU.W #6,D2
ADDQ.W #1,D2
AND.L #3,D2
LEA TToneCh1Flag(PC),A0
ADD.L D2,A0
ST (A0)
MOVEQ #1,D0
LSL.W D2,D0
MOVE.W D0,TToneBit
LEA $DFF0A0,A0
LSL.W #4,D2
LEA (A0,D2.W),A0
MOVE.L A0,TToneChPtr
LEA PeriodTable(PC),A1
MOVE.W TuneNote,D1
ADD.W D1,D1
MOVE.W (A1,D1.W),D1
LEA TToneData,A2
MOVE.W D0,$DFF096 ; turn off DMA
MOVE.L A2,(A0)
MOVE.W #16,4(A0) ; 32 bytes
MOVE.W D1,6(A0)
MOVE.W TToneVol,8(A0)
JSR WaitForPaulaLatch
BSET #15,D0
MOVE.W D0,$DFF096 ; turn DMA on
ttrts
RTS
TToneOff
CLR.W TToneFlag
CLR.L TToneCh1Flag ; clear all four
MOVE.W TToneBit(PC),$DFF096
MOVE.L TToneChPtr(PC),A0
CLR.W 8(A0)
RTS
CNOP 0,4
TToneChPtr dc.l 0
TToneFlag dc.w 0
TToneBit dc.w 0
TToneCh1Flag dc.b 0
TToneCh2Flag dc.b 0
TToneCh3Flag dc.b 0
TToneCh4Flag dc.b 0
SamplePressed
CMP.W #144,D1
BHS.B spruskp
MOVE.W LoopStartPos(PC),D2
BEQ.B sprusk5
SUBQ.W #3,D2
CMP.W D2,D0
BLT.B sprusk5
ADDQ.W #4,D2
CMP.W D2,D0
BLO.W LoopStartDrag
sprusk5 MOVE.W LoopEndPos(PC),D2
BEQ.B spruskp
SUBQ.W #3,D2
CMP.W D2,D0
BLT.B spruskp
ADDQ.W #4,D2
CMP.W D2,D0
BLO.W LoopEndDrag
spruskp CMP.W #3,D0
BLO.W Return3
CMP.W #317,D0
BHS.W Return3
MOVE.W D0,LastSamPos
BSR.W InvertRange
MOVE.W LastSamPos(PC),D0
MOVE.W D0,MarkStart
MOVE.W D0,MarkEnd
BSR.B InvertRange
BSR.W MarkToOffset
MOVE.L MarkEndOfs(PC),SamplePos
BSR.W ShowPos
sprulop BTST #6,$BFE001 ; left mouse button
BNE.B spruend
MOVE.W MouseX(PC),D0
CMP.W #3,D0
BLO.B sprusk3
CMP.W #317,D0
BHS.B sprusk2
BRA.B sprusk4
sprusk2 MOVE.W #316,D0
BRA.B sprusk4
sprusk3 MOVEQ #3,D0
sprusk4 CMP.W LastSamPos(PC),D0
BEQ.B sprulop
MOVE.W D0,LastSamPos
BSR.B InvertRange
MOVE.W LastSamPos(PC),MarkEnd
BSR.B InvertRange
BSR.W MarkToOffset
MOVE.L MarkEndOfs(PC),SamplePos
BSR.W ShowPos
BRA.B sprulop
spruend MOVE.W MarkStart(PC),D0
MOVE.W MarkEnd(PC),D1
CMP.W D0,D1
BHS.W MarkToOffset
MOVE.W D0,MarkEnd
MOVE.W D1,MarkStart
BRA.W MarkToOffset
InvertRange ; taken from PT315.s and changed a bit
MOVE.W MarkStart(PC),D0
BEQ.W Return3
MOVE.W MarkEnd(PC),D2
CMP.W D0,D2
BPL.B ivok
EXG.L D0,D2
ivok ADDQ.W #1,D2 ; this is needed for the new invertrange routine
CMP.W #317,D2 ; -
BLS.B ivok2 ; -
MOVE.W #317,D2 ; -
ivok2 MOVEQ #0,D1
MOVEQ #64,D3
MOVE.L A4,-(SP)
MOVE.L A5,-(SP)
MOVE.L GfxBase(PC),A6
JSR _LVOOwnBlitter(A6)
JSR _LVOWaitBlit(A6)
MOVE.L LineScreenPtr(PC),A4
LEA $DFF000,A6
ivwait1 BTST #6,2(A6)
BNE.B ivwait1
MOVE.L A4,A5
ADD.W #16,D2
MOVE.W #$035A,$40(A6) ; EOR
CLR.W $42(A6)
MOVE.W D2,D4
AND.W #$000F,D4
MOVEQ #-1,D5
LSR.W D4,D5
NOT.W D5
MOVE.W D5,$46(A6)
MOVE.W D0,D4
AND.W #$000F,D4
MOVEQ #-1,D5
LSR.W D4,D5
MOVE.W D5,$44(A6)
SUB.W D1,D3
MULU.W #40,D1
ADD.L D1,A5
ADD.W D4,D2
SUB.W D0,D2
LSR.W #3,D0
AND.W #$00FE,D0
EXT.L D0
ADD.L D0,A5
LSR.W #3,D2
AND.W #$FFFE,D2
MOVEQ #40,D4
NEG.W D2
ADD.W D2,D4
MOVE.W D4,$60(A6)
MOVE.W D2,$64(A6)
MOVE.W D4,$66(A6)
NEG.W D2
MOVE.L A5,$48(A6)
MOVE.W #$FFFF,$74(A6)
MOVE.L A5,$54(A6)
LSL.W #6,D3
LSR.W #1,D2
ADD.W D2,D3
MOVE.W D3,$58(A6)
ivwait2 BTST #6,2(A6)
BNE.B ivwait2
MOVE.L GfxBase(PC),A6
JSR _LVODisownBlitter(A6)
MOVEA.L (SP)+,A5
MOVEA.L (SP)+,A4
RTS
LoopStartPos dc.w 0
LoopEndPos dc.w 0
LoopStartDrag
CLR.W DragType
LopDrgLop
MOVE.L SongDataPtr(PC),A0
MOVE.W InsNum(PC),D0
BEQ.W Return3
MULU.W #30,D0
LEA 12(A0,D0.W),A0
MOVE.W MouseX(PC),D0
lsdlop1 BTST #6,$BFE001 ; left mouse button
BNE.B lsdexit
MOVE.W MouseX(PC),D1
CMP.W D0,D1
BEQ.B lsdlop1
SUB.W DragType(PC),D1
BPL.B lsdmsk1
MOVEQ #0,D1
lsdmsk1 CMP.W #314,D1
BLO.B lsdmsk2
MOVE.W #314,D1
lsdmsk2 MOVE.L SamDisplay(PC),D0
JSR MULU32
MOVE.L #314,D1
JSR DIVU32
MOVE.L D0,D1
MOVE.L SamOffset(PC),D0
ADD.L D1,D0 ; new repeat
BCLR #0,D0 ; even'ify
MOVEQ #0,D1
MOVE.W 4(A0),D1 ; old repeat
ADD.L D1,D1
TST.W DragType
BNE.B drgrepl
MOVE.L D1,D3
SUB.L D1,D0 ; offset
ADD.L D0,D1
MOVEQ #0,D2
MOVE.W 6(A0),D2
ADD.L D2,D2
ADD.L D2,D3
SUBQ.L #2,D3
SUB.L D0,D2
CMP.L D3,D1
BLS.B lsdok
MOVE.L D3,D1
MOVEQ #2,D2
lsdok LSR.L #1,D1
MOVE.W D1,4(A0)
LSR.L #1,D2
MOVE.W D2,6(A0)
BSR.B lsdexit
BRA.W LopDrgLop
lsdexit BSR.W ShowSampleInfo
JSR UpdateRepeats
BRA.W SetLoopSprites2
LoopEndDrag
MOVE.W #3,DragType
BRA.W LopDrgLop
drgrepl MOVE.L D0,D2 ; repend
SUB.L D1,D2 ; subtract repstart
CMP.L #2,D2
BGT.B ledskp1
MOVEQ #2,D2
BRA.B lsdok
ledskp1 MOVE.L D1,D0 ; 128kB-fixed by 8bitbubsy
ADD.L D2,D0
MOVEQ #0,D3
MOVE.W (A0),D3
ADD.L D3,D3
CMP.L D3,D0
BLS.B lsdok
SUB.L D1,D3
MOVE.L D3,D2
BRA.B lsdok
DragType dc.w 0
SamDragBar
CMP.W #4,D0
BLO.W Return3
CMP.W #316,D0
BHS.W Return3
CMP.W DragStart(PC),D0
BLO.B draglo
CMP.W DragEnd(PC),D0
BHS.B draghi
MOVE.W MouseX(PC),D0
MOVE.W D0,LastMouseX
SUB.W DragStart(PC),D0
ADDQ.W #3,D0
MOVE.W D0,DragOffset
sdrlop1 BTST #6,$BFE001 ; left mouse button
BNE.W Return3
MOVEQ #0,D0
MOVE.W MouseX(PC),D0
CMP.W LastMouseX(PC),D0
BEQ.B sdrlop1
MOVE.W D0,LastMouseX
SUB.W DragOffset(PC),D0
BPL.B sdrskp1
MOVEQ #0,D0
sdrskp1 MOVE.L SamLength(PC),D1
BEQ.W Return3
JSR MULU32
MOVE.L #311,D1
JSR DIVU32
BSR.B dragchk
BRA.B sdrlop1
draglo MOVE.L SamOffset(PC),D0
SUB.L SamDisplay(PC),D0
BPL.B draglo2
MOVEQ #0,D0
draglo2 CMP.L SamOffset(PC),D0
BEQ.W Return3
MOVE.L D0,SamOffset
BRA.W DisplaySampleNoTextUpdate
draghi MOVE.L SamOffset(PC),D0
ADD.L SamDisplay(PC),D0
dragchk MOVE.L D0,D1
ADD.L SamDisplay(PC),D1
CMP.L SamLength(PC),D1
BLS.B draglo2
MOVE.L SamLength(PC),D0
SUB.L SamDisplay(PC),D0
BRA.B draglo2
DragOffset dc.w 0
LastMouseX dc.w 0
;----
MarkToOffset
MOVEQ #0,D0
MOVE.W MarkStart(PC),D0
BEQ.W Return3
SUBQ.W #3,D0
MOVE.L SamDisplay(PC),D1
JSR MULU32
MOVE.L #314,D1
JSR DIVU32
ADD.L SamOffset(PC),D0
MOVE.L D0,MarkStartOfs
; ------------------------
MOVEQ #0,D0
MOVE.W MarkEnd(PC),D0
CMP.W #316,D0
BLO.B mtosome
MOVE.L SamOffset(PC),D0
ADD.L SamDisplay(PC),D0
BRA.B mtoexit
mtosome SUBQ.W #3,D0
MOVE.L SamDisplay(PC),D1
JSR MULU32
MOVE.L #314,D1
JSR DIVU32
ADD.L SamOffset(PC),D0
mtoexit MOVE.L D0,MarkEndOfs
RTS
OffsetToMark
MOVE.L D2,-(SP)
; ------------------------
MOVE.L MarkStartOfs(PC),D0
BMI.B otmout
MOVE.W #3,MarkStart
MOVE.W #3,MarkEnd
MOVE.L SamDisplay(PC),D2
BEQ.W otmend
SUB.L SamOffset(PC),D0
BMI.B otmskip ; set to start if before offset
MOVE.L #314,D1
JSR MULU32
MOVE.L D2,D1
JSR DIVU32
CMP.W #314,D0
BHI.B otmout ; if start after display
ADD.W D0,MarkStart
otmskip ; ------------------------
MOVE.L MarkEndOfs(PC),D0
SUB.L SamOffset(PC),D0
BMI.B otmout ; if end before offset
MOVE.L #314,D1
JSR MULU32
MOVE.L D2,D1
JSR DIVU32
CMP.W #313,D0
BLS.B otmok
MOVE.W #313,D0 ; set to end if after display
otmok ADD.W D0,MarkEnd
otmend ; ------------------------
MOVE.L (SP)+,D2
RTS
otmout CLR.W MarkStart
CLR.W MarkEnd
BRA.B otmend
CNOP 0,4
MarkStartOfs dc.l 0
MarkEndOfs dc.l 0
SamMemPtr dc.l 0
SamMemSize dc.l 0
SamScrEnable dc.w 0
LastSamPos dc.w 0
MarkStart dc.w 0
MarkEnd dc.w 0
;---- Sample graphing stuff ----
DisplaySample
TST.W SamScrEnable
BEQ.W Return3
BSR.W rdsskip
TST.L MarkStartOfs
BMI.W Return3
BSR.W OffsetToMark
BRA.W InvertRange
DisplaySampleNoTextUpdate
TST.W SamScrEnable
BEQ.W Return3
BSR.W rdsdoit
TST.L MarkStartOfs
BMI.W Return3
BSR.W OffsetToMark
BRA.W InvertRange
; fall-through
RedrawSample
TST.W SamScrEnable
BEQ.W Return3
MOVEQ #-1,D0
MOVE.L D0,MarkStartOfs
CLR.W MarkStart
SF EmptySampleFlag
MOVE.W InsNum(PC),D0
BEQ.B rdsblnk
LEA SampleStarts(PC),A1
SUBQ.W #1,D0
LSL.W #2,D0
MOVE.L (A1,D0.W),SamStart
BEQ.B rdsblnk
MOVE.L 124(A1,D0.W),D1
BEQ.B rdsblnk
MOVE.L D1,SamLength
CLR.L SamOffset
MOVE.L D1,SamDisplay
BSR.W SetSamPosDelta
BRA.B rdsskip
rdsblnk ST EmptySampleFlag
LEA BlankSample,A0
MOVE.L A0,SamStart
MOVE.L #314,SamLength
CLR.L SamOffset
MOVE.L #314,SamDisplay
BSR.W SetSamPosDelta
rdsskip MOVE.L SamDisplay(PC),D0
LEA BlankSample,A0
CMP.L SamStart(PC),A0
BNE.B rdsslwo
MOVEQ #0,D0
rdsslwo MOVE.W #215*40+33,TextOffset
BSR.W Print6DecDigits
rdsdoit
BSR.W ClearSamArea
BSR.W SetDragBar
; --PT2.3D change:
; Slightly optimized sample draw routine, which also supports
; 128kB samples. This one doesn't use DIVU & MULU per pixel.
;
; This is still awfully slow (because of blitter line drawing..?)
;
MOVE.L SamStart(PC),A0
MOVE.L SamDisplay(PC),D3
MOVE.L SamOffset(PC),D2
MOVE.L D2,D7
MOVE.L A0,D0
ADD.L D2,D0
MOVE.L D0,SamDrawStart
ADD.L D3,D0
MOVE.L D0,SamDrawEnd
ADD.L D2,A0
MOVE.L SamPosDelta(PC),D7
MOVEQ #0,D6 ; starting sample pos (17.15 fixed-point)
; If we're zoomed out, adjust sample start pos/frac so
; that the waveform doesn't "wiggle" while scrolling it.
;
CMP.L #314,D3 ; SamDisplay (2..131070)
BLS.B rdsskp3 ; not zoomed out, no adjustment needed
TST.L D2 ; SamOffset (0..131068)
BEQ.B rdsskp3 ; not scrolled, no adjustment needed
SUB.L D2,A0
MOVE.L D2,D0
MOVE.L #314,D1
JSR MULU32
MOVE.L D3,D1
JSR DIVU32
MOVE.L D0,D3
MOVE.L D7,D1
AND.L #32767,D1 ; D1.L = sample delta frac
JSR MULU32
MOVE.L D0,D6
MOVEQ #15,D2
MOVE.L D7,D1
LSR.L D2,D1 ; D1.L = sample delta integer
MOVE.L D3,D0
JSR MULU32
LSL.L D2,D0
ADD.L D0,D6
rdsskp3
MOVE.L D6,-(SP)
MOVE.L D7,-(SP)
MOVE.L GfxBase(PC),A6
JSR _LVOOwnBlitter(A6)
JSR _LVOWaitBlit(A6)
BSR.W DrawDragBar ; (also uses blitter, so do it now)
MOVE.L (SP)+,D7
MOVE.L (SP)+,D6
MOVEQ #0,D4
MOVE.L #$1FFFF,D5
rdsloop MOVE.L D6,D0 ; D0.L = current sample pos (17.15fp)
SWAP D0 ;
ROL.L #1,D0 ;
AND.L D5,D0 ; D0.L = current sample pos (integer)
MOVEQ #127,D1
SUB.B (A0,D0.L),D1
LSR.W #2,D1
MOVE.W D4,D0
ADDQ.W #3,D0
TST.W D4
BNE.B rdsdraw
BSR.W MoveTo
BRA.B rdsupdt
rdsdraw BSR.W DrawTo
rdsupdt ADD.L D7,D6
ADDQ.W #1,D4
CMP.W #314,D4
BLO.B rdsloop
JSR _LVODisownBlitter(A6)
BRA.W SetLoopSprites
CNOP 0,4
SamPosDelta dc.l 0
SamStart dc.l 0
SamLength dc.l 0
SamOffset dc.l 0
SamDisplay dc.l 0
SavSamIns dc.w 0
SamFracBits dc.w 0
EmptySampleFlag dc.b 0
EVEN
SetDragBar
SF DragBarShown
; ------------------------
MOVE.L SamLength(PC),D3
BEQ.B .end
MOVE.L SamOffset(PC),D4
MOVE.L SamDisplay(PC),D5
CMP.L D3,D5
BEQ.B .end
ADD.L D4,D5
; ------------------------
MOVE.L D4,D0
MOVE.L #311,D1
JSR MULU32
MOVE.L D3,D1
JSR DIVU32
ADDQ.W #4,D0
MOVE.W D0,DragStart
; ------------------------
MOVE.L D5,D0
MOVE.L #311,D1
JSR MULU32
MOVE.L D3,D1
JSR DIVU32
ADDQ.W #5,D0
MOVE.W D0,DragEnd
; ------------------------
ST DragBarShown
.end RTS
DrawDragBar
TST.B DragBarShown
BEQ.B .end
MOVE.W DragStart,D4
MOVE.W DragEnd,D5
MOVEQ #68,D6
MOVEQ #4-1,D7
.loop MOVE.W D4,D0
MOVE.W D6,D1
MOVE.W D5,D2
MOVE.W D6,D3
BSR.B DrawLine
ADDQ.W #1,D6
DBRA D7,.loop
.end RTS
DragStart dc.w 0
DragEnd dc.w 0
DragBarShown dc.b 0
EVEN
;---- Line Routine ----
ScrWidth = 40
DrawInvertLine
MOVE.B #$48,MinTerm
BSR.B DrawLine
MOVE.B #$C8,MinTerm
RTS
MoveTo
MOVE.W D0,PenX
MOVE.W D1,PenY
RTS
DrawTo
MOVE.W PenX(PC),D2
MOVE.W PenY(PC),D3
MOVE.W D0,PenX
MOVE.W D1,PenY
CMP.W D0,D2
BNE.B DrawLine
CMP.W D1,D3
BEQ.W dlrts
; fall-through
DrawLine
MOVE.L D4,-(SP)
MOVE.L D5,-(SP)
MOVEQ #0,D4
SUB.W D1,D3
BGE.B dypos
NEG.W D3
BRA.B dyneg
dypos BSET #0,D4
dyneg SUB.W D0,D2
BGE.B dxpos
NEG.W D2
BRA.B dxneg
dxpos BSET #1,D4
dxneg MOVE.W D2,D5
SUB.W D3,D5
BGE.B dxdypos
EXG D2,D3
BRA.B dxdyneg
dxdypos BSET #2,D4
dxdyneg MOVEQ #0,D5
ROR.W #4,D0
OR.W #$0B00,D0
MOVE.B D0,D5
MOVE.B MinTerm(PC),D0
ADD.W D5,D5
MULU.W #ScrWidth,D1
ADD.W D5,D1
ADD.L LineScreenPtr(PC),D1
blitrdy BTST #14-8,$DFF002
BNE.B blitrdy
MOVE.W #$4000,$DFF09A
MOVE.B Octants(PC,D4),D4
ADD.W D3,D3
MOVE.W D3,$DFF062 ; BLTBMOD
SUB.W D2,D3
BGE.B dldspos
OR.B #$40,D4
dldspos MOVE.L D3,$DFF050 ; BLTAPTR
SUB.W D2,D3
MOVE.W D3,$DFF064 ; BLTAMOD
MOVE.W D4,$DFF042 ; BLTCON1
MOVE.W D0,$DFF040 ; BLTCON0
MOVE.L D1,$DFF048 ; BLTCPTR
MOVE.L D1,$DFF054 ; BLTDPTR
MOVE.W #ScrWidth,$DFF060 ; BLTCMOD
MOVE.W #ScrWidth,$DFF066 ; BLTDMOD
MOVE.W #$8000,$DFF074 ; BLTADAT
MOVE.W #$FFFF,$DFF044 ; BLTAFWM
MOVE.W LinMask(PC),$DFF072 ; BLTBDAT
LSL.W #6,D2
ADDQ.W #2,D2
MOVE.W D2,$DFF058 ; BLTSIZE
MOVE.W #$C000,$DFF09A
MOVE.L (SP)+,D5
MOVE.L (SP)+,D4
dlrts RTS
Octants dc.b 3*4+1,2*4+1,1*4+1,0*4+1,7*4+1,5*4+1,6*4+1,4*4+1
CNOP 0,4
LineScreenPtr dc.l 0
LinMask dc.w $FFFF
PenX dc.w 0
PenY dc.w 0
MinTerm dc.b $C8,0
;---- Loop Sprites ----
SetLoopSprites
MOVEQ #-1,D6
MOVEQ #-1,D7
MOVE.W InsNum(PC),D0
BEQ.W slsset
MULU.W #30,D0
MOVE.L SongDataPtr(PC),A0
LEA 12(A0,D0.W),A0
SetLoopSprites2
TST.W SamScrEnable
BEQ.W Return3
CLR.W LoopOnOffFlag
MOVEQ #-1,D6
MOVEQ #-1,D7
MOVEQ #0,D0
MOVE.W 4(A0),D0
ADD.L D0,D0
MOVEQ #0,D1
MOVE.W 6(A0),D1
ADD.L D1,D1
MOVE.L D0,D5
ADD.L D1,D5
CMP.W #2,D5
BLS.B slsset
MOVE.W #1,LoopOnOffFlag
MOVE.L SamOffset(PC),D2
MOVE.L SamDisplay(PC),D3
MOVE.L D2,D4
ADD.L D3,D4
CMP.L D2,D0
BLO.B .l1
CMP.L D4,D0
BHI.B .l1
SUB.L D2,D0
MOVE.L D3,-(SP)
LSR.L #1,D0
LSR.L #1,D3
MULU.W #314,D0
DIVU.W D3,D0
MOVE.L (SP)+,D3
ADDQ.W #3,D0
MOVE.W D0,D6
.l1 CMP.L D2,D5
BLO.B slsset
CMP.L D4,D5
BHI.B slsset
SUB.L D2,D5
MOVE.L D3,-(SP)
LSR.L #1,D3
LSR.L #1,D5
MULU.W #314,D5
DIVU.W D3,D5
MOVE.L (SP)+,D3
ADDQ.W #6,D5
MOVE.W D5,D7
slsset MOVE.W #139,D1
MOVE.W D6,D0
BPL.B .l2
MOVEQ #0,D0
MOVE.W #270,D1
.l2 MOVEQ #64,D2
LEA LoopSpriteData1,A0
MOVE.W D0,LoopStartPos
BSR.W SetSpritePos
MOVE.W #139,D1
MOVE.W D7,D0
BPL.B .l3
MOVEQ #0,D0
MOVE.W #270,D1
.l3 MOVEQ #64,D2
LEA LoopSpriteData2,A0
MOVE.W D0,LoopEndPos
BSR.W SetSpritePos
BRA.W ShowLoopToggle
HideLoopSprites ; new PT2.3E routine
MOVEM.L D0-D2/A0,-(SP)
MOVEQ #0,D0
MOVE.W #270,D1
MOVEQ #64,D2
LEA LoopSpriteData1,A0
BSR SetSpritePos
LEA LoopSpriteData2,A0
BSR SetSpritePos
MOVEM.L (SP)+,D0-D2/A0
RTS
;---- Playroutine ----
CNOP 0,4
audchan1temp
dcb.b 24
dc.w $0001 ; voice #1 DMA bit
dcb.b 34
audchan2temp
dcb.b 24
dc.w $0002 ; voice #2 DMA bit
dcb.b 34
audchan3temp
dcb.b 24
dc.w $0004 ; voice #3 DMA bit
dcb.b 34
audchan4temp
dcb.b 24
dc.w $0008 ; voice #4 DMA bit
dcb.b 34
IntMusic
MOVEM.L D0-D7/A0-A6,-(SP)
MOVE.L RunMode(PC),D0
BEQ.W NoNewPositionYet
CMP.L #'patt',D0
BEQ.B .l1
MOVE.L SongPosition(PC),CurrPos
.l1
MOVE.L SongDataPtr(PC),A0
TST.W StepPlayEnable
BNE.B .l2
ADDQ.L #1,Counter
MOVE.L Counter(PC),D0
CMP.L CurrSpeed(PC),D0
BLO.B NoNewNote
.l2 CLR.L Counter
TST.B PattDelayTime2
BEQ.B GetNewNote
BSR.B NoNewAllChannels
BRA.W dskip
NoNewNote
BSR.B NoNewAllChannels
BRA.W NoNewPositionYet
NoNewAllChannels
LEA audchan1temp(PC),A6
LEA $DFF0A0,A5
BSR.W CheckEffects
LEA audchan2temp(PC),A6
LEA $DFF0B0,A5
BSR.W CheckEffects
LEA audchan3temp(PC),A6
LEA $DFF0C0,A5
BSR.W CheckEffects
LEA audchan4temp(PC),A6
LEA $DFF0D0,A5
BRA.W CheckEffects
GetNewNote
LEA 12(A0),A3
LEA sd_pattpos(A0),A2
LEA sd_patterndata(A0),A0
MOVEQ #0,D1
MOVE.L SongPosition(PC),D0
MOVE.B (A2,D0.W),D1
CMP.L #'patt',RunMode
BNE.B .l1
MOVE.L PatternNumber(PC),D1
.l1 LSL.L #8,D1
LSL.L #2,D1
ADD.L PatternPosition(PC),D1
CLR.W DMACONtemp
LEA $DFF0A0,A5
LEA audchan1temp(PC),A6
MOVEQ #1,D2
BSR.W PlayVoice
TST.B n_muted(A6) ; --PT2.3D bug fix: instant channel muting
BNE.W .l2
MOVEQ #0,D0
MOVE.B n_volume(A6),D0
MOVE.W D0,8(A5)
MOVE.B D0,n_volumeout(A6) ; set quadrascope volume
.l2
LEA $DFF0B0,A5
LEA audchan2temp(PC),A6
MOVEQ #2,D2
BSR.W PlayVoice
TST.B n_muted(A6) ; --PT2.3D bug fix: instant channel muting
BNE.W .l3
MOVEQ #0,D0
MOVE.B n_volume(A6),D0
MOVE.W D0,8(A5)
MOVE.B D0,n_volumeout(A6) ; set quadrascope volume
.l3
LEA $DFF0C0,A5
LEA audchan3temp(PC),A6
MOVEQ #3,D2
BSR.W PlayVoice
TST.B n_muted(A6) ; --PT2.3D bug fix: instant channel muting
BNE.W .l4
MOVEQ #0,D0
MOVE.B n_volume(A6),D0
MOVE.W D0,8(A5)
MOVE.B D0,n_volumeout(A6) ; set quadrascope volume
.l4
LEA $DFF0D0,A5
LEA audchan4temp(PC),A6
MOVEQ #4,D2
BSR.W PlayVoice
TST.B n_muted(A6) ; --PT2.3D bug fix: instant channel muting
BNE.W .l5
MOVEQ #0,D0
MOVE.B n_volume(A6),D0
MOVE.W D0,8(A5)
MOVE.B D0,n_volumeout(A6) ; set quadrascope volume
.l5
BRA.W SetDMA
SetVUMeterHeight ; - PT2.3D change: perfect VU-meters (never buggy at high BPMs)
TST.B RealVUMetersFlag ; real VU-meters mode?
BNE.B vuend ; yes, don't use this routine
; -------------------------
TST.B n_muted(A6) ; is this channel muted?
BNE.B vuend ; yes, don't set VU-meter height for this channel
MOVEQ #0,D0
MOVE.B n_dmabit+1(A6),D0 ; check temp dmacon to find out what channel we're on
AND.B #$0F,D0
BEQ.B vuend ; no active channel...
; -------------------------
MOVE.L A0,-(SP)
MOVE.L D1,-(SP)
BTST #0,D0 ; are we on channel #1?
BEQ.B notch1 ; no
LEA VUSpriteData1,A0 ; yes, get current sprite
BRA.B vuskip
notch1 BTST #1,D0 ; are we on channel #2?
BEQ.B notch2 ; no
LEA VUSpriteData2,A0 ; yes, get current sprite
BRA.B vuskip
notch2 BTST #2,D0 ; are we on channel #3?
BEQ.B notch3 ; no
LEA VUSpriteData3,A0 ; yes, get current sprite
BRA.B vuskip
notch3 LEA VUSpriteData4,A0 ; we are on channel #4
vuskip MOVE.B n_cmd(A6),D0 ; get channel effect
AND.B #$0F,D0 ; mask
CMP.B #$0C,D0 ; is current effect 'C' (set vol)?
BNE.B vuskip2 ; no
MOVE.B n_cmdlo(A6),D0 ; yes, use parameter as VU-meter volume
BRA.B vuskip3
vuskip2 MOVE.B n_volume(A6),D0 ; get channel volume instead
vuskip3 CMP.B #64,D0 ; higher than $40?
BLS.B vuskip4 ; no, safe for use!
MOVEQ #64,D0 ; yes, set to $40
vuskip4 MOVE.B (VUmeterHeights,PC,D0.W),(A0)
MOVE.L (SP)+,D1
MOVE.L (SP)+,A0
vuend RTS
; ------------------
; This table is also used for the "real" VU meter mode.
;
; for (i = 0 to 64) x = 233 - round[i * (47/64)]
VUmeterHeights
dc.b 233,232,232,231,230,229,229,228,227,226,226,225,224,223,223,222
dc.b 221,221,220,219,218,218,217,216,215,215,214,213,212,212,211,210
dc.b 209,209,208,207,207,206,205,204,204,203,202,201,201,200,199,198
dc.b 198,197,196,196,195,194,193,193,192,191,190,190,189,188,187,187
dc.b 186
EVEN
CheckMetronome
TST.B MetroFlag
BEQ.W Return3
CMP.B MetroChannel(PC),D2
BNE.W Return3
MOVE.B MetroSpeed(PC),D2
BEQ.W Return3
MOVE.L PatternPosition(PC),D3
LSR.L #4,D3
DIVU.W D2,D3
SWAP D3
TST.W D3
BNE.W Return3
CLR.W D3
SWAP D3
DIVU.W D2,D3
SWAP D3
TST.W D3
BNE.B MetroNotFirst
AND.L #$00000FFF,(A6)
OR.L #$10A0F000,(A6) ; Play sample $1F at period $0A0 (160)
RTS
MetroNotFirst
AND.L #$00000FFF,(A6)
OR.L #$10D6F000,(A6) ; Play sample $1F at period $0D6 (214)
RTS
PlayVoice
MOVE.L D2,D7 ; D7 = channel number
TST.L (A6)
BNE.B plvskip
BSR.W PerNop
plvskip MOVE.L (A0,D1.L),(A6) ; Read note from pattern
BSR.B CheckMetronome
ADDQ.L #4,D1
MOVEQ #0,D2
MOVE.B n_cmd(A6),D2 ; Get lower 4 bits of instrument
AND.B #$F0,D2
LSR.B #4,D2
MOVE.B (A6),D0 ; Get higher 4 bits of instrument
AND.B #$F0,D0
OR.B D0,D2
AND.B #31,D2 ; PT2.3D bugfix: mask instrument
TST.B D2
BEQ.W SetRegisters ; Instrument was zero
MOVEQ #0,D3
LEA SampleStarts(PC),A1
MOVE.W D2,D4
MOVE.B D2,n_samplenum(A6)
SUBQ.L #1,D2
LSL.L #2,D2
MULU.W #30,D4
MOVE.L (A1,D2.L),n_start(A6)
MOVE.L n_start(A6),n_oldstart(A6) ; for quadrascope
MOVE.W (A3,D4.L),n_length(A6)
MOVEQ #0,D0
MOVE.B 2(A3,D4.L),D0
AND.B #$0F,D0
MOVE.B D0,n_finetune(A6)
; ----------------------------------
LSL.B #2,D0 ; update n_peroffset
LEA ftunePerTab(PC),A4
MOVE.L (A4,D0.W),n_peroffset(A6)
; ----------------------------------
AND.B #$0F,n_finetune(A6) ; --PT2.3D bug fix: mask finetune...
MOVE.B 3(A3,D4.L),n_volume(A6)
MOVE.W 4(A3,D4.L),D3 ; Get repeat
MOVE.W D3,n_repeat(A6)
TST.W D3
BEQ.B NoLoop
MOVE.L n_start(A6),D2 ; Get start
ADD.L D3,D3 ; PT2.3D bug fix: 128kB support
ADD.L D3,D2 ; Add repeat
MOVE.L D2,n_loopstart(A6)
MOVE.L D2,n_wavestart(A6)
MOVE.W 4(A3,D4.L),D0 ; Get repeat
ADD.W 6(A3,D4.L),D0 ; Add replen
MOVE.W D0,n_length(A6)
MOVE.W D0,n_oldlength(A6) ; for quadrascope
MOVE.W 6(A3,D4.L),n_replen(A6) ; Save replen
BRA.B SetRegisters
NoLoop
MOVE.W n_length(A6),n_oldlength(A6) ; for quadrascope
MOVE.L n_start(A6),D2
ADD.L D3,D2
MOVE.L D2,n_loopstart(A6)
MOVE.L D2,n_wavestart(A6)
MOVE.W 6(A3,D4.L),n_replen(A6) ; Save replen
SetRegisters
MOVE.W (A6),D0
AND.W #$0FFF,D0
BEQ.W CheckMoreEffects ; If no note
MOVE.W 2(A6),D0
AND.W #$FF0,D0
CMP.W #$E50,D0 ; finetune
BEQ.B DoSetFineTune
MOVE.B 2(A6),D0
AND.B #$0F,D0
CMP.B #3,D0 ; TonePortamento
BEQ.B ChkTonePorta
CMP.B #5,D0 ; TonePortamento + VolSlide
BEQ.B ChkTonePorta
CMP.B #9,D0 ; Sample Offset
BNE.B SetPeriod
BSR.W CheckMoreEffects
BRA.B SetPeriod
DoSetFineTune
BSR.W SetFineTune
BRA.B SetPeriod
ChkTonePorta
BSR.W SetVUMeterHeight ; set VU-meter height now as well
BSR.W SetTonePorta
BRA.W CheckMoreEffects
SetPeriod
MOVEM.L D0/D1/A0/A1,-(SP)
MOVE.W (A6),D1
AND.W #$0FFF,D1
LEA PeriodTable(PC),A1
MOVEQ #0,D0
MOVEQ #37-1,D7
ftuloop CMP.W (A1,D0.W),D1
BHS.B ftufound
ADDQ.W #2,D0
DBRA D7,ftuloop
ftufound
MOVE.L n_peroffset(A6),A1
MOVE.W (A1,D0.W),n_period(A6)
MOVEM.L (SP)+,D0/D1/A0/A1
MOVE.W 2(A6),D0
AND.W #$FF0,D0
CMP.W #$ED0,D0 ; Notedelay
BEQ.W CheckMoreEffects
MOVE.W n_dmabit(A6),$DFF096
BTST #2,n_wavecontrol(A6)
BNE.B vibnoc
CLR.B n_vibratopos(A6)
vibnoc BTST #6,n_wavecontrol(A6)
BNE.B trenoc
CLR.B n_tremolopos(A6)
trenoc
MOVE.W n_length(A6),4(A5) ; Set length
MOVE.L n_start(A6),(A5) ; Set start
BNE.B sdmaskp
CLR.L n_loopstart(A6)
CLR.L n_wavestart(A6)
MOVEQ #1,D0
MOVE.W D0,4(A5)
MOVE.W D0,n_replen(A6)
sdmaskp
MOVE.W n_period(A6),D0
MOVE.W D0,6(A5) ; Set period
MOVE.W D0,n_periodout(A6) ; Set quadrascope period
ST n_trigger(A6) ; Trigger quadrascope
JSR SpectrumAnalyzer ; Do the analyzer
BSR.W SetVUMeterHeight ; Set VU-meter height
MOVE.W n_dmabit(A6),D0
OR.W D0,DMACONtemp
BRA.W CheckMoreEffects
SetDMA
JSR WaitForPaulaLatch
MOVE.W DMACONtemp(PC),D0
OR.W #$8000,D0 ; Set DMA bits
MOVE.W D0,$DFF096
JSR WaitForPaulaLatch
LEA $DFF000,A5
LEA audchan4temp(PC),A6
MOVE.L n_loopstart(A6),$D0(A5)
MOVE.W n_replen(A6),$D4(A5)
LEA audchan3temp(PC),A6
MOVE.L n_loopstart(A6),$C0(A5)
MOVE.W n_replen(A6),$C4(A5)
LEA audchan2temp(PC),A6
MOVE.L n_loopstart(A6),$B0(A5)
MOVE.W n_replen(A6),$B4(A5)
LEA audchan1temp(PC),A6
MOVE.L n_loopstart(A6),$A0(A5)
MOVE.W n_replen(A6),$A4(A5)
dskip TST.L RunMode
BEQ.B dskipx
JSR SetPatternPos
dskipx MOVE.L PatternPosition(PC),D0
LSR.L #4,D0
MOVE.W D0,ScrPattPos
ADD.L #16,PatternPosition
MOVE.B PattDelayTime(PC),D0
BEQ.B dskpc
MOVE.B D0,PattDelayTime2
CLR.B PattDelayTime
dskpc TST.B PattDelayTime2
BEQ.B dskpa
SUBQ.B #1,PattDelayTime2
BEQ.B dskpa
SUB.L #16,PatternPosition
dskpa TST.B PBreakFlag
BEQ.B nnpysk
SF PBreakFlag
MOVEQ #0,D0
MOVE.B PBreakPosition(PC),D0
LSL.W #4,D0
MOVE.L D0,PatternPosition
CLR.B PBreakPosition
nnpysk TST.W StepPlayEnable
BEQ.B nnpysk2
JSR DoStopIt
CLR.W StepPlayEnable
MOVE.L PatternPosition(PC),D0
LSR.L #4,D0
AND.W #63,D0
MOVE.W D0,ScrPattPos
nnpysk2 CMP.L #1024,PatternPosition
BNE.B NoNewPositionYet
NextPosition
MOVEQ #0,D0
MOVE.B PBreakPosition(PC),D0
LSL.W #4,D0
MOVE.L D0,PatternPosition
CLR.B PBreakPosition
CLR.B PosJumpAssert
CMP.L #'patp',RunMode
BNE.B NoNewPositionYet
ST PattRfsh
ADDQ.L #1,SongPosition
AND.L #$7F,SongPosition
MOVE.L SongPosition(PC),D1
MOVE.L SongDataPtr(PC),A0
CMP.B sd_numofpatt(A0),D1
BLO.B NoNewPositionYet
CLR.L SongPosition
TST.W StepPlayEnable
BEQ.B NoNewPositionYet
JSR DoStopIt
CLR.W StepPlayEnable
MOVE.L PatternPosition(PC),D0
LSR.L #4,D0
MOVE.W D0,ScrPattPos
NoNewPositionYet
TST.B PosJumpAssert
BNE.B NextPosition
MOVEM.L (SP)+,D0-D7/A0-A6
RTS
CheckEffects
BSR.B chkefx2
TST.B n_muted(A6) ; --PT2.3D bug fix: instant muting
BNE.B ceend
MOVEQ #0,D0
MOVE.B n_volume(A6),D0
MOVE.W D0,8(A5)
MOVE.B D0,n_volumeout(A6) ; Set scope volume
ceend RTS
CNOP 0,4
JumpList1
dc.l Arpeggio ; 0xy (Arpeggio)
dc.l PortaUp ; 1xx (Portamento Up)
dc.l PortaDown ; 2xx (Portamento Down)
dc.l TonePortamento ; 3xx (Tone Portamento)
dc.l Vibrato ; 4xy (Vibrato)
dc.l TonePlusVolSlide ; 5xy (Tone Portamento + Volume Slide)
dc.l VibratoPlusVolSlide ; 6xy (Vibrato + Volume Slide)
dc.l SetBack ; 7 - not used here
dc.l SetBack ; 8 - unused!
dc.l SetBack ; 9 - not used here
dc.l SetBack ; A - not used here
dc.l SetBack ; B - not used here
dc.l SetBack ; C - not used here
dc.l SetBack ; D - not used here
dc.l E_Commands ; Exy (Extended Commands)
dc.l SetBack ; F - not used here
chkefx2
BSR.W UpdateFunk
MOVE.W n_cmd(A6),D0
AND.W #$0FFF,D0
BEQ.B Return3
MOVEQ #0,D0
MOVE.B n_cmd(A6),D0
AND.B #$0F,D0
MOVE.W D0,D1
LSL.B #2,D1
MOVE.L JumpList1(PC,D1.W),A4
JMP (A4) ; every efx has RTS at the end, this is safe
SetBack MOVE.W n_period(A6),6(A5)
MOVE.W n_period(A6),n_periodout(A6) ; Set scope period
CMP.B #7,D0
BEQ.W Tremolo
CMP.B #$A,D0
BEQ.W VolumeSlide
Return3 RTS
PerNop MOVE.W n_period(A6),6(A5)
MOVE.W n_period(A6),n_periodout(A6) ; Set scope period
RTS
Arpeggio
MOVE.L Counter(PC),D0
AND.W #255,D0 ; just in case
MOVE.B ArpTab(PC,D0.W),D0
CMP.B #1,D0
BEQ.W Arpeggio1
CMP.B #2,D0
BEQ.W Arpeggio2
Arpeggio0
MOVE.W n_period(A6),D2
BRA.W ArpeggioSet
; DIV -> LUT optimization. DIVU is up to 140+ cycles on a 68000.
ArpTab
dc.b 0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1
dc.b 2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0
dc.b 1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2
dc.b 0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1
dc.b 2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0
dc.b 1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2
dc.b 0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1
dc.b 2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0
EVEN
Arpeggio1
MOVEQ #0,D0
MOVE.B n_cmdlo(A6),D0
LSR.B #4,D0
BRA.B ArpeggioFind
Arpeggio2
MOVEQ #0,D0
MOVE.B n_cmdlo(A6),D0
AND.B #15,D0
ArpeggioFind
ADD.W D0,D0
MOVE.L n_peroffset(A6),A0
MOVEQ #0,D1
MOVE.W n_period(A6),D1
MOVEQ #37-1,D7
arploop CMP.W (A0)+,D1
BHS.B ArpeggioFound
DBRA D7,arploop
RTS
ArpeggioFound
MOVE.W -2(A0,D0.W),D2
ArpeggioSet
MOVE.W D2,6(A5)
MOVE.W D2,n_periodout(A6) ; Set scope period
RTS
FinePortaUp
TST.L Counter
BNE.W Return3
MOVE.B #$0F,LowMask
PortaUp MOVEQ #0,D0
MOVE.B n_cmdlo(A6),D0
AND.B LowMask(PC),D0
MOVE.B #$FF,LowMask
SUB.W D0,n_period(A6)
MOVE.W n_period(A6),D0
AND.W #$0FFF,D0
CMP.W #$0071,D0
BPL.B PortaUskip
AND.W #$F000,n_period(A6)
OR.W #$0071,n_period(A6)
PortaUskip
MOVE.W n_period(A6),D0
AND.W #$0FFF,D0
MOVE.W D0,6(A5)
MOVE.W D0,n_periodout(A6) ; Set scope period
RTS
FinePortaDown
TST.L Counter
BNE.W Return3
MOVE.B #$0F,LowMask
PortaDown
CLR.W D0
MOVE.B n_cmdlo(A6),D0
AND.B LowMask(PC),D0
MOVE.B #$FF,LowMask
ADD.W D0,n_period(A6)
MOVE.W n_period(A6),D0
AND.W #$0FFF,D0
CMP.W #$0358,D0
BMI.B PortaDskip
AND.W #$F000,n_period(A6)
OR.W #$0358,n_period(A6)
PortaDskip
MOVE.W n_period(A6),D0
AND.W #$0FFF,D0
MOVE.W D0,6(A5)
MOVE.W D0,n_periodout(A6) ; Set scope period
RTS
SetTonePorta
MOVE.W (A6),D2
AND.W #$0FFF,D2
MOVE.L n_peroffset(A6),A4
MOVEQ #0,D0
StpLoop CMP.W (A4,D0.W),D2
BHS.B StpFound
ADDQ.W #2,D0
CMP.W #37*2,D0
BLO.B StpLoop
MOVEQ #35*2,D0
StpFound
MOVE.B n_finetune(A6),D2
AND.B #8,D2
BEQ.B StpGoss
TST.W D0
BEQ.B StpGoss
SUBQ.W #2,D0
StpGoss MOVE.W (A4,D0.W),D2
MOVE.W D2,n_wantedperiod(A6)
MOVE.W n_period(A6),D0
CLR.B n_toneportdirec(A6)
CMP.W D0,D2
BEQ.B ClearTonePorta
BGE.W Return3
MOVE.B #1,n_toneportdirec(A6)
RTS
ClearTonePorta
CLR.W n_wantedperiod(A6)
RTS
TonePortamento
MOVE.B n_cmdlo(A6),D0
BEQ.B TonePortNoChange
MOVE.B D0,n_toneportspeed(A6)
CLR.B n_cmdlo(A6)
TonePortNoChange
TST.W n_wantedperiod(A6)
BEQ.W Return3
MOVEQ #0,D0
MOVE.B n_toneportspeed(A6),D0
TST.B n_toneportdirec(A6)
BNE.B TonePortaUp
TonePortaDown
ADD.W D0,n_period(A6)
MOVE.W n_wantedperiod(A6),D0
CMP.W n_period(A6),D0
BGT.B TonePortaSetPer
MOVE.W n_wantedperiod(A6),n_period(A6)
CLR.W n_wantedperiod(A6)
BRA.B TonePortaSetPer
TonePortaUp
SUB.W D0,n_period(A6)
MOVE.W n_wantedperiod(A6),D0
CMP.W n_period(A6),D0
BLT.B TonePortaSetPer
MOVE.W n_wantedperiod(A6),n_period(A6)
CLR.W n_wantedperiod(A6)
TonePortaSetPer
MOVE.W n_period(A6),D2
MOVE.B n_glissfunk(A6),D0
AND.B #$0F,D0
BEQ.B GlissSkip
MOVE.L n_peroffset(A6),A0
MOVEQ #0,D0
GlissLoop
CMP.W (A0,D0.W),D2
BHS.B GlissFound
ADDQ.W #2,D0
CMP.W #37*2,D0
BLO.B GlissLoop
MOVEQ #35*2,D0
GlissFound
MOVE.W (A0,D0.W),D2
GlissSkip
MOVE.W D2,6(A5) ; Set period
MOVE.W D2,n_periodout(A6) ; Set scope period
RTS
Vibrato MOVE.B n_cmdlo(A6),D0
BEQ.B Vibrato2
MOVE.B n_vibratocmd(A6),D2
AND.B #$0F,D0
BEQ.B vibskip
AND.B #$F0,D2
OR.B D0,D2
vibskip MOVE.B n_cmdlo(A6),D0
AND.B #$F0,D0
BEQ.B vibskip2
AND.B #$0F,D2
OR.B D0,D2
vibskip2
MOVE.B D2,n_vibratocmd(A6)
Vibrato2
MOVE.L A4,-(SP)
MOVE.B n_vibratopos(A6),D0
LEA VibratoTable(PC),A4
LSR.W #2,D0
AND.W #$001F,D0
MOVEQ #0,D2
MOVE.B n_wavecontrol(A6),D2
AND.B #3,D2
BEQ.B vib_sine
LSL.B #3,D0
CMP.B #1,D2
BEQ.B vib_rampdown
MOVE.B #255,D2
BRA.B vib_set
vib_rampdown
TST.B n_vibratopos(A6)
BPL.B vib_rampdown2
MOVE.B #255,D2
SUB.B D0,D2
BRA.B vib_set
vib_rampdown2
MOVE.B D0,D2
BRA.B vib_set
vib_sine
MOVE.B (A4,D0.W),D2
vib_set
MOVE.B n_vibratocmd(A6),D0
AND.W #15,D0
MULU.W D0,D2
LSR.W #7,D2
MOVE.W n_period(A6),D0
TST.B n_vibratopos(A6)
BMI.B VibratoNeg
ADD.W D2,D0
BRA.B Vibrato3
VibratoNeg
SUB.W D2,D0
Vibrato3
MOVE.W D0,6(A5)
MOVE.W D0,n_periodout(A6) ; Set scope period
MOVE.B n_vibratocmd(A6),D0
LSR.W #2,D0
AND.W #$003C,D0
ADD.B D0,n_vibratopos(A6)
MOVE.L (SP)+,A4
RTS
TonePlusVolSlide
BSR.W TonePortNoChange
BRA.W VolumeSlide
VibratoPlusVolSlide
BSR.B Vibrato2
BRA.W VolumeSlide
Tremolo
MOVE.B n_cmdlo(A6),D0
BEQ.B Tremolo2
MOVE.B n_tremolocmd(A6),D2
AND.B #$0F,D0
BEQ.B treskip
AND.B #$F0,D2
OR.B D0,D2
treskip MOVE.B n_cmdlo(A6),D0
AND.B #$F0,D0
BEQ.B treskip2
AND.B #$0F,D2
OR.B D0,D2
treskip2
MOVE.B D2,n_tremolocmd(A6)
Tremolo2
MOVE.B n_tremolopos(A6),D0
LEA VibratoTable(PC),A4
LSR.W #2,D0
AND.W #$001F,D0
MOVEQ #0,D2
MOVE.B n_wavecontrol(A6),D2
LSR.B #4,D2
AND.B #3,D2
BEQ.B tre_sine
LSL.B #3,D0
CMP.B #1,D2
BEQ.B tre_rampdown
MOVE.B #255,D2
BRA.B tre_set
tre_rampdown
TST.B n_vibratopos(A6)
BPL.B tre_rampdown2
MOVE.B #255,D2
SUB.B D0,D2
BRA.B tre_set
tre_rampdown2
MOVE.B D0,D2
BRA.B tre_set
tre_sine
MOVE.B (A4,D0.W),D2
tre_set
MOVE.B n_tremolocmd(A6),D0
AND.W #15,D0
MULU.W D0,D2
LSR.W #6,D2
MOVEQ #0,D0
MOVE.B n_volume(A6),D0
TST.B n_tremolopos(A6)
BMI.B TremoloNeg
ADD.W D2,D0
BRA.B Tremolo3
TremoloNeg
SUB.W D2,D0
Tremolo3
BPL.B TremoloSkip
CLR.W D0
TremoloSkip
CMP.W #$40,D0
BLS.B TremoloOk
MOVE.W #$40,D0
TremoloOk
; --PT2.3D bug fix: instant muting
TST.B n_muted(A6)
BNE.B TremoloSkip2
MOVE.W D0,8(A5)
MOVE.B D0,n_volumeout(A6) ; Set scope volume
TremoloSkip2
; --END OF FIX--------------------
MOVE.B n_tremolocmd(A6),D0
LSR.W #2,D0
AND.W #$003C,D0
ADD.B D0,n_tremolopos(A6)
ADDQ.L #4,SP
RTS
SampleOffset
MOVEQ #0,D0
MOVE.B n_cmdlo(A6),D0
BEQ.B sononew
MOVE.B D0,n_sampleoffset(A6)
sononew MOVE.B n_sampleoffset(A6),D0
LSL.W #7,D0
CMP.W n_length(A6),D0
BHS.B sofskip
SUB.W D0,n_length(A6)
ADD.W D0,D0
ADD.L D0,n_start(A6)
RTS
sofskip MOVE.W #$0001,n_length(A6)
RTS
VolumeSlide
MOVEQ #0,D0
MOVE.B n_cmdlo(A6),D0
LSR.B #4,D0
TST.B D0
BEQ.B VolSlideDown
VolSlideUp
ADD.B D0,n_volume(A6)
CMP.B #$40,n_volume(A6)
BMI.B vsuskip
MOVE.B #$40,n_volume(A6)
vsuskip RTS
VolSlideDown
MOVEQ #0,D0
MOVE.B n_cmdlo(A6),D0
AND.B #$0F,D0
VolSlideDown2
SUB.B D0,n_volume(A6)
BPL.B vsdskip
CLR.B n_volume(A6)
vsdskip RTS
PositionJump
MOVEQ #0,D0
MOVE.B n_cmdlo(A6),D0
SUBQ.B #1,D0
MOVE.L D0,SongPosition
pj2 CLR.B PBreakPosition
ST PosJumpAssert
RTS
VolumeChange
MOVEQ #0,D0
MOVE.B n_cmdlo(A6),D0
CMP.B #$40,D0
BLS.B VolumeOk
MOVEQ #$40,D0
VolumeOk
MOVE.B D0,n_volume(A6)
RTS
PatternBreak
MOVEQ #0,D0
MOVE.B n_cmdlo(A6),D0
MOVE.L D0,D2
LSR.B #4,D0
MULU.W #10,D0
AND.B #$0F,D2
ADD.B D2,D0
CMP.B #63,D0
BHI.B pj2
MOVE.B D0,PBreakPosition
ST PosJumpAssert
RTS
SetSpeed
MOVE.B 3(A6),D0
AND.W #$FF,D0
BEQ.B SpeedNull
TST.B IntMode
BEQ.B normspd
CMP.W #32,D0
BLO.B normspd
MOVE.W D0,RealTempo
MOVEM.L D0-D7/A0-A6,-(SP)
MOVE.W SamScrEnable(PC),-(SP)
ST SamScrEnable
ST UpdateTempo
JSR SetTempo
MOVE.W (SP)+,SamScrEnable
MOVEM.L (SP)+,D0-D7/A0-A6
RTS
normspd CLR.L Counter
MOVE.W D0,CurrSpeed+2
RTS
SpeedNull
CLR.L RunMode
JSR SetNormalPtrCol
; PT2.3D fix: fixes for F00 while in string/number edit mode
JSR StorePtrCol ; store idle pointer color in backup
TST.W LineCurX ; are we editing a number or string?
BEQ.B .end
JSR SetWaitPtrCol ; we're editing, set edit pointer color
.end ; ----------------------------------------------------------------
RTS
CNOP 0,4
JumpList2
dc.l PerNop ; 0 - not used
dc.l PerNop ; 1 - not used
dc.l PerNop ; 2 - not used
dc.l PerNop ; 3 - not used
dc.l PerNop ; 4 - not used
dc.l PerNop ; 5 - not used
dc.l PerNop ; 6 - not used
dc.l PerNop ; 7 - not used
dc.l PerNop ; 8 - not used
dc.l SampleOffset ; 9xx (Set Sample Offset)
dc.l PerNop ; A - not used
dc.l PositionJump ; Bxx (Position Jump)
dc.l VolumeChange ; Cxx (Set Volume)
dc.l PatternBreak ; Dxx (Pattern Break)
dc.l E_Commands ; Exy (Extended Commands)
dc.l SetSpeed ; Fxx (Set Speed)
CheckMoreEffects
MOVEQ #0,D0
MOVE.B 2(A6),D0
AND.B #$0F,D0
LSL.B #2,D0
MOVE.L JumpList2(PC,D0.W),A4
JMP (A4) ; every efx has RTS at the end, this is safe
CNOP 0,4
E_JumpList
dc.l FilterOnOff ; E0x (Set LED Filter)
dc.l FinePortaUp ; E1x (Fine Portamento Up)
dc.l FinePortaDown ; E2x (Fine Portamento Down)
dc.l SetGlissControl ; E3x (Glissando/Funk Control)
dc.l SetVibratoControl ; E4x (Vibrato Control)
dc.l SetFineTune ; E5x (Set Finetune)
dc.l JumpLoop ; E6x (Pattern Loop)
dc.l SetTremoloControl ; E7x (Tremolo Control)
dc.l PerNop ; E8x - not used
dc.l RetrigNote ; E9x (Retrig Note)
dc.l VolumeFineUp ; EAx (Fine Volume-Slide Up)
dc.l VolumeFineDown ; EBx (Fine Volume-Slide Down)
dc.l NoteCut ; ECx (Note Cut)
dc.l NoteDelay ; EDx (Note Delay)
dc.l PatternDelay ; EEx (Pattern Delay)
dc.l FunkIt ; EFx (Invert Loop)
E_Commands
MOVEQ #0,D0
MOVE.B n_cmdlo(A6),D0
AND.B #$F0,D0
LSR.B #4-2,D0
MOVE.L E_JumpList(PC,D0.W),A4
JMP (A4) ; every E-efx has RTS at the end, this is safe
FilterOnOff
MOVE.B n_cmdlo(A6),D0
AND.B #1,D0
ADD.B D0,D0
AND.B #$FD,$BFE001
OR.B D0,$BFE001
RTS
SetGlissControl
MOVE.B n_cmdlo(A6),D0
AND.B #$0F,D0
AND.B #$F0,n_glissfunk(A6)
OR.B D0,n_glissfunk(A6)
RTS
SetVibratoControl
MOVE.B n_cmdlo(A6),D0
AND.B #$0F,D0
AND.B #$F0,n_wavecontrol(A6)
OR.B D0,n_wavecontrol(A6)
RTS
SetFineTune
MOVEQ #0,D0
MOVE.B n_cmdlo(A6),D0
AND.B #$0F,D0
MOVE.B D0,n_finetune(A6)
; ----------------------------------
LSL.B #2,D0 ; update n_peroffset
LEA ftunePerTab(PC),A4
MOVE.L (A4,D0.W),n_peroffset(A6)
; ----------------------------------
RTS
JumpLoop
TST.L Counter
BNE.W Return3
MOVE.B n_cmdlo(A6),D0
AND.B #$0F,D0
BEQ.B SetLoop
TST.B n_loopcount(A6)
BEQ.B jumpcnt
SUBQ.B #1,n_loopcount(A6)
BEQ.W Return3
jmploop MOVE.B n_pattpos(A6),PBreakPosition
ST PBreakFlag
RTS
jumpcnt MOVE.B D0,n_loopcount(A6)
BRA.B jmploop
SetLoop MOVE.L PatternPosition(PC),D0
LSR.L #4,D0
AND.B #63,D0
MOVE.B D0,n_pattpos(A6)
RTS
SetTremoloControl
MOVE.B n_cmdlo(A6),D0
AND.B #$0F,D0
LSL.B #4,D0
AND.B #$0F,n_wavecontrol(A6)
OR.B D0,n_wavecontrol(A6)
RTS
RetrigNote
MOVE.L A0,-(SP)
MOVE.L D1,-(SP)
MOVEQ #0,D0
MOVE.B n_cmdlo(A6),D0
AND.B #$0F,D0
BEQ.W rtnend
MOVE.L Counter(PC),D1
BNE.B rtnskp
MOVE.W n_note(A6),D1
AND.W #$0FFF,D1
BNE.B rtnend
MOVE.L Counter(PC),D1
rtnskp DIVU.W D0,D1
SWAP D1
TST.W D1
BNE.B rtnend
DoRetrg MOVE.W n_dmabit(A6),$DFF096 ; Channel DMA off
MOVE.L n_start(A6),0(A5) ; Set sampledata pointer
MOVE.W n_length(A6),4(A5) ; Set length
MOVE.W n_period(A6),6(A5) ; Set period
MOVE.W n_period(A6),n_periodout(A6) ; Set quadrascope period
JSR WaitForPaulaLatch
MOVE.W n_dmabit(A6),D0
BSET #15,D0 ; Set DMA bits
MOVE.W D0,$DFF096
JSR WaitForPaulaLatch
MOVE.L n_loopstart(A6),0(A5)
MOVE.W n_replen(A6),4(A5)
; -- PT2.3D bug fix: update analyzer/scope/VU-meters on note retrig
JSR SpectrumAnalyzer
ST n_trigger(A6) ; Trigger quadrascope
BSR.W SetVUMeterHeight ; Set VU-meter height
; ---------------------------------------------------------
rtnend MOVE.L (SP)+,D1
MOVE.L (SP)+,A0
RTS
VolumeFineUp
TST.L Counter
BNE.W Return3
MOVEQ #0,D0
MOVE.B n_cmdlo(A6),D0
AND.B #$F,D0
BRA.W VolSlideUp
VolumeFineDown
TST.L Counter
BNE.W Return3
MOVEQ #0,D0
MOVE.B n_cmdlo(A6),D0
AND.B #$0F,D0
BRA.W VolSlideDown2
NoteCut MOVEQ #0,D0
MOVE.B n_cmdlo(A6),D0
AND.B #$0F,D0
CMP.L Counter(PC),D0
BNE.W Return3
CLR.B n_volume(A6)
RTS
NoteDelay
MOVEQ #0,D0
MOVE.B n_cmdlo(A6),D0
AND.B #$0F,D0
CMP.L Counter(PC),D0
BNE.W Return3
MOVE.W (A6),D0
AND.W #$0FFF,D0
BEQ.W Return3
MOVE.L A0,-(SP)
MOVE.L D1,-(SP)
BRA.W DoRetrg
PatternDelay
TST.L Counter
BNE.W Return3
MOVEQ #0,D0
MOVE.B n_cmdlo(A6),D0
AND.B #$0F,D0
TST.B PattDelayTime2
BNE.W Return3
ADDQ.B #1,D0
MOVE.B D0,PattDelayTime
RTS
FunkIt TST.L Counter
BNE.W Return3
MOVE.B n_cmdlo(A6),D0
AND.B #$0F,D0
LSL.B #4,D0
AND.B #$0F,n_glissfunk(A6)
OR.B D0,n_glissfunk(A6)
TST.B D0
BEQ.W Return3
UpdateFunk
MOVE.L D1,-(SP)
MOVE.L A0,-(SP)
MOVEQ #0,D0
MOVE.B n_glissfunk(A6),D0
LSR.B #4,D0
BEQ.B funkend
LEA FunkTable(PC),A0
MOVE.B (A0,D0.W),D0
ADD.B D0,n_funkoffset(A6)
BTST #7,n_funkoffset(A6)
BEQ.B funkend
CLR.B n_funkoffset(A6)
; --PT2.3D bug fix: EFx null pointer--
MOVE.L n_wavestart(A6),A0
CMP.L #0,A0
BEQ.B funkend
; --END OF FIX------------------------
MOVE.L n_loopstart(A6),D0
MOVEQ #0,D1
MOVE.W n_replen(A6),D1
ADD.L D1,D0
ADD.L D1,D0
ADDQ #1,A0
CMP.L D0,A0
BLO.B funkok
MOVE.L n_loopstart(A6),A0
funkok MOVE.L A0,n_wavestart(A6)
MOVEQ #-1,D0
SUB.B (A0),D0
MOVE.B D0,(A0)
funkend MOVE.L (SP)+,A0
MOVE.L (SP)+,D1
RTS
;************************* End of Code ******************************
; -----------------------------------------------------------------------------
; DATA
; -----------------------------------------------------------------------------
FunkTable dc.b 0,5,6,7,8,10,11,13,16,19,22,26,32,43,64,128
VibratoTable
dc.b 0, 24, 49, 74, 97,120,141,161
dc.b 180,197,212,224,235,244,250,253
dc.b 255,253,250,244,235,224,212,197
dc.b 180,161,141,120, 97, 74, 49, 24
AllRightText dc.b 'All right',0
PLSTFullText dc.b 'Plst is full!',0
AreYouSureText dc.b 'Are you sure?',0
NoDiskInDriveText
dc.b 'No disk in df0!',0
WriteProtectedText
dc.b 'Write protected',0
OprAbortedText dc.b 'Print aborted!',0
EnterDataText dc.b 'Enter data',0
EnterFilenameText dc.b 'Enter filename',0
AddingPathText dc.b 'Adding path...',0
DiskErrorText dc.b 'Disk error !!',0
LoadingText dc.b 'Loading...',0
LoadingSongText dc.b 'Loading song',0
LoadingModuleText
dc.b 'Loading module',0
LoadingSampleText
dc.b 'Loading sample',0
LoadingTrackText
dc.b 'Loading track',0
LoadingPatternText
dc.b 'Loading pattern',0
SavingText dc.b 'Saving...',0
SavingModuleText
dc.b 'Saving module',0
SavingIconText dc.b 'Saving icon',0
SavingSampleText dc.b 'Saving sample',0
LoadingPLSTText dc.b 'Loading plst',0
SavingPLSTText dc.b 'Saving plst',0
DeletingSongText dc.b 'Deleting song',0
DeletingModuleText dc.b 'Deleting module',0
DeletingSampleText dc.b 'Deleting sample',0
DeletingTrackText dc.b 'Deleting track',0
DeletingPatternText dc.b 'Deleting pattern',0
RenamingFileText dc.b 'Renaming file',0
DecrunchingText dc.b 'Decrunching...',0
CrunchingText dc.b 'Crunching... ',0
SelectEntryText dc.b 'Select entry',0
SelectSongText dc.b 'Select song',0
SelectModuleText
dc.b 'Select module',0
SelectSampleText
dc.b 'Select sample',0
SelectTrackText
dc.b 'Select track',0
SelectPatternText
dc.b 'Select pattern',0
SelectFileText
dc.b 'Select file',0
ReadingDirText dc.b 'Reading dir...',0
PosSetText dc.b 'Position set',0
PrintingSongText
dc.b 'Printing song',0
PrintingPLSTText
dc.b 'Printing plst',0
SaveSongText dc.b 'Save song ?',0
DeleteSongText dc.b 'Delete song ?',0
SaveModuleText dc.b 'Save module ?',0
SaveExeText dc.b 'Save executable ?',0
DeleteModuleText dc.b 'Delete module ?',0
SaveSampleText dc.b 'Save sample ?',0
DeleteSampleText dc.b 'Delete sample ?',0
SaveTrackText dc.b 'Save track ?',0
DeleteTrackText dc.b 'Delete track ?',0
SavePatternText dc.b 'Save pattern ?',0
DeletePatternText dc.b 'Delete pattern ?',0
PrintPLSTText dc.b 'Print plst ?',0
PrintSongText dc.b 'Print song ?',0
QuitPTText dc.b 'Really quit ?',0
UpsampleText dc.b 'Upsample ?',0
DownSampleText dc.b 'Downsample ?',0
PleaseSelectText dc.b 'Please select',0
ClearSplitText dc.b 'Clear split ?',0
ResetAllText dc.b 'Reset config ?',0
DeletePresetText dc.b 'Delete preset ?',0
LoadPLSTText dc.b 'Load presetlist?',0
SavePLSTText dc.b 'Save presetlist;',0
KillSampleText dc.b 'Kill sample ?',0
AbortLoadingText dc.b 'Abort loading ?',0
LoadConfigText dc.b 'Load config ?',0
SaveConfigText dc.b 'Save config ?',0
DiskFormatText dc.b 'Disk format'
InProgressText dc.b 'in progress'
FormattingCylText
dc.b 'Formatting cyl ',0
VerifyingText dc.b 'Verifying cyl ',0
InitDiskText dc.b 'Initializing',0
PlsEntNamText dc.b 'Please enter name'
OfVolumeText dc.b 'of volume: ST-__',0
CNOP 0,2
DiskNumText1 dc.b '0'
DiskNumText2 dc.b '0 '
PEdDefaultPath dc.b 'df0:',0
dcb.b 47,0
PEdDefaultVol dc.b 'st-'
SndDiskNum0 dc.b '0'
SndDiskNum1 dc.b '1:'
PresetName dc.b ' '
PsetNameText dc.b ' '
dc.b ' '
PsetVolText dc.b ' '
dc.b ' '
PsetLenText dc.b ' '
dc.b ' '
PsetRepeatText dc.b ' '
dc.b ' '
PsetReplenText dc.b ' '
InsertPsetText dc.b 'ST-01: 0 0000 0000 0002'
PsetPLSTtext dc.b 'No. Samplename '
dc.b 'Length Repeat RepLen',$A,$A
PsetPrtNumText dc.b ' : '
PsetPrtNameText dc.b ' '
PsetPrtLenText dc.b ' '
PsetPrtRepeatText dc.b ' '
PsetPrtRepLenText dc.b 10
dc.b 0
SongDumpText
dc.b 9
dc.b 'ProTracker Song-Dump -- Made with '
dc.b 'ProTracker v2.3F ',$D,$A,$A
dc.b 9
dc.b 'Songname: '
CRLF_Text dc.b 13,10
FF_Text dc.b 12,0
CNOP 0,2
PatternNumText dc.b 9,9,9,'Pattern: '
PattNumText1 dc.b '0'
PattNumText2 dc.b '0',$D,$A,$D,$A
PtotText dc.b 9
PattXText1 dc.b "0"
PattXText2 dc.b "0 : "
PpText dc.b ' 0000'
ascii.MSG4 dc.b ' 0000'
ascii.MSG5 dc.b ' 0000'
ascii.MSG6 dc.b ' ',$D,$A
PnText2 dc.b " "
CNOP 0,2
dc.b 0
PattPosText dc.b '00 : '
dc.b ' '
PnText dc.b ' ',0
CNOP 0,2
SongsText dc.b 'Songs',0
ModulesText dc.b 'Modules',0
TracksText dc.b 'Tracks',0
PatternsText dc.b 'Patterns',0
SamplesText dc.b 'Samples',0
dc.b 'DF0:',0
dc.b '.'
CNOP 0,2
STText1 dc.b 'ST'
STText1Num dc.b '-'
STText1Number dc.b 0,0,':'
STText2 dc.b 'ST'
STText2Num dc.b '-'
STText2Number dc.b 0,0,':'
STText3 dc.b 'ST'
STText3Num dc.b '-'
STText3Number dc.b 0,0,':'
EmptyLineText dc.b ' ',0
EVEN
FastHexTable
dc.b '000102030405060708090A0B0C0D0E0F'
dc.b '101112131415161718191A1B1C1D1E1F'
dc.b '202122232425262728292A2B2C2D2E2F'
dc.b '303132333435363738393A3B3C3D3E3F'
dc.b '404142434445464748494A4B4C4D4E4F'
dc.b '505152535455565758595A5B5C5D5E5F'
dc.b '606162636465666768696A6B6C6D6E6F'
dc.b '707172737475767778797A7B7C7D7E7F'
dc.b '808182838485868788898A8B8C8D8E8F'
dc.b '909192939495969798999A9B9C9D9E9F'
dc.b 'A0A1A2A3A4A5A6A7A8A9AAABACADAEAF'
dc.b 'B0B1B2B3B4B5B6B7B8B9BABBBCBDBEBF'
dc.b 'C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF'
dc.b 'D0D1D2D3D4D5D6D7D8D9DADBDCDDDEDF'
dc.b 'E0E1E2E3E4E5E6E7E8E9EAEBECEDEEEF'
dc.b 'F0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFF'
HexTable dc.b '0123456789ABCDEF'
TrackdiskName dc.b 'trackdisk.device',0
InputDevName dc.b 'input.device',0
RawKeyHexTable
dc.b 10,1,2,3,4,5,6,7
dc.b 8,9,32,53,51,34,18,35
RawKeyScaleTable
dc.b 49,33,50,34,51,52,36,53,37,54,38,55,56,40,57
dc.b 41,58,16,2,17,3,18,19,5,20,6,21,7,22,23,9,24,10
dc.b 25,26,12,27,70,70,0
KbdTransTable1
dc.b 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15,16
dc.b 12,13,14,15,16,17,18,19,20,21,22,23
dc.b 24,25,26,27,28,29,30,31,36,36
KbdTransTable2
dc.b 12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28
dc.b 24,25,26,27,28,29,30,31,32,33,34,35
dc.b 36,36,36,36,36,36,36,36,36,36
NoteNames1
dc.b 'C-1 C#1 D-1 D#1 E-1 F-1 F#1 G-1 G#1 A-1 A#1 B-1 '
dc.b 'C-2 C#2 D-2 D#2 E-2 F-2 F#2 G-2 G#2 A-2 A#2 B-2 '
dc.b 'C-3 C#3 D-3 D#3 E-3 F-3 F#3 G-3 G#3 A-3 A#3 B-3 '
SpcNoteText
dc.b '--- '
dc.b '??? '
NoteNames2
dc.b 'C-1 D1 D-1 E1 E-1 F-1 G1 G-1 A1 A-1 B1 B-1 '
dc.b 'C-2 D2 D-2 E2 E-2 F-2 G2 G-2 A2 A-2 B2 B-2 '
dc.b 'C-3 D3 D-3 E3 E-3 F-3 G3 G-3 A3 A-3 B3 B-3 '
dc.b '--- '
dc.b '??? '
; Optimization: prevents MULU for getting correct finetuned period
CNOP 0,4
ftunePerTab
dc.l ftune0,ftune1,ftune2,ftune3
dc.l ftune4,ftune5,ftune6,ftune7
dc.l ftune8,ftune9,ftuneA,ftuneB
dc.l ftuneC,ftuneD,ftuneE,ftuneF
PeriodTable
; Tuning 0, Normal
ftune0
dc.w 856,808,762,720,678,640,604,570,538,508,480,453
dc.w 428,404,381,360,339,320,302,285,269,254,240,226
dc.w 214,202,190,180,170,160,151,143,135,127,120,113,0
; Tuning 1
ftune1
dc.w 850,802,757,715,674,637,601,567,535,505,477,450
dc.w 425,401,379,357,337,318,300,284,268,253,239,225
dc.w 213,201,189,179,169,159,150,142,134,126,119,113,0
; Tuning 2
ftune2
dc.w 844,796,752,709,670,632,597,563,532,502,474,447
dc.w 422,398,376,355,335,316,298,282,266,251,237,224
dc.w 211,199,188,177,167,158,149,141,133,125,118,112,0
; Tuning 3
ftune3
dc.w 838,791,746,704,665,628,592,559,528,498,470,444
dc.w 419,395,373,352,332,314,296,280,264,249,235,222
dc.w 209,198,187,176,166,157,148,140,132,125,118,111,0
; Tuning 4
ftune4
dc.w 832,785,741,699,660,623,588,555,524,495,467,441
dc.w 416,392,370,350,330,312,294,278,262,247,233,220
dc.w 208,196,185,175,165,156,147,139,131,124,117,110,0
; Tuning 5
ftune5
dc.w 826,779,736,694,655,619,584,551,520,491,463,437
dc.w 413,390,368,347,328,309,292,276,260,245,232,219
dc.w 206,195,184,174,164,155,146,138,130,123,116,109,0
; Tuning 6
ftune6
dc.w 820,774,730,689,651,614,580,547,516,487,460,434
dc.w 410,387,365,345,325,307,290,274,258,244,230,217
dc.w 205,193,183,172,163,154,145,137,129,122,115,109,0
; Tuning 7
ftune7
dc.w 814,768,725,684,646,610,575,543,513,484,457,431
dc.w 407,384,363,342,323,305,288,272,256,242,228,216
dc.w 204,192,181,171,161,152,144,136,128,121,114,108,0
; Tuning -8
ftune8
dc.w 907,856,808,762,720,678,640,604,570,538,508,480
dc.w 453,428,404,381,360,339,320,302,285,269,254,240
dc.w 226,214,202,190,180,170,160,151,143,135,127,120,0
; Tuning -7
ftune9
dc.w 900,850,802,757,715,675,636,601,567,535,505,477
dc.w 450,425,401,379,357,337,318,300,284,268,253,238
dc.w 225,212,200,189,179,169,159,150,142,134,126,119,0
; Tuning -6
ftuneA
dc.w 894,844,796,752,709,670,632,597,563,532,502,474
dc.w 447,422,398,376,355,335,316,298,282,266,251,237
dc.w 223,211,199,188,177,167,158,149,141,133,125,118,0
; Tuning -5
ftuneB
dc.w 887,838,791,746,704,665,628,592,559,528,498,470
dc.w 444,419,395,373,352,332,314,296,280,264,249,235
dc.w 222,209,198,187,176,166,157,148,140,132,125,118,0
; Tuning -4
ftuneC
dc.w 881,832,785,741,699,660,623,588,555,524,494,467
dc.w 441,416,392,370,350,330,312,294,278,262,247,233
dc.w 220,208,196,185,175,165,156,147,139,131,123,117,0
; Tuning -3
ftuneD
dc.w 875,826,779,736,694,655,619,584,551,520,491,463
dc.w 437,413,390,368,347,328,309,292,276,260,245,232
dc.w 219,206,195,184,174,164,155,146,138,130,123,116,0
; Tuning -2
ftuneE
dc.w 868,820,774,730,689,651,614,580,547,516,487,460
dc.w 434,410,387,365,345,325,307,290,274,258,244,230
dc.w 217,205,193,183,172,163,154,145,137,129,122,115,0
; Tuning -1
ftuneF
dc.w 862,814,768,725,684,646,610,575,543,513,484,457
dc.w 431,407,384,363,342,323,305,288,272,256,242,228
dc.w 216,203,192,181,171,161,152,144,136,128,121,114,0
; ------------------------------------------------------
; Overflow bytes from CursorPosTable and UnshiftedKeymap
; LUTs so that overflown arpeggio at finetune -1 sounds
; right even if this table was to be moved.
; ------------------------------------------------------
dc.w 774,1800,2314,3087,4113,4627,5400,6426,6940,7713
dc.w 8739,9253,24625,12851,13365
CursorPosTable
dc.b 3,6,7,8,9,10,12
dc.b 15,16,17,18,19,21
dc.b 24,25,26,27,28,30
dc.b 33,34,35,36,37
UnshiftedKeymap
dc.b '`1234567890-=\*0'
dc.b 'qwertyuiop[]*123'
dc.b 'asdfghjkl;',39,'#',0,'456'
dc.b '<zxcvbnm,./',0,'.','789 '
ShiftedKeymap
dc.b '~!@#$%^&*()_+|*0'
dc.b 'qwertyuiop{}*123'
dc.b 'asdfghjkl:',34,'^',0,'456'
dc.b '>zxcvbnm<>?',0,'.','789 '
; -----------------------------------------------------------------------------
; UNTOUCHABLE VARIABLES (do not touch!)
; -----------------------------------------------------------------------------
CNOP 0,4
SampleInfo dc.w 0
si_volume dc.w 0
si_long dc.l 0
si_pointer dc.l 0,0,0,0,0
SampleInfo2 dc.l 0
si_long2 dc.l 0
si_pointer2 dc.l 0,0,0,0,0
CNOP 0,4
SongDataPtr dc.l 0
SampleStarts dcb.l 31,0
SamplePtrs EQU SampleStarts-4
SampleLengths dcb.l 32,0
SpritePtrsPtr dc.l 0
LineCurPosPtr dc.l 0
Ch1SpritePtr dc.l 0
Ch2SpritePtr dc.l 0
Ch3SpritePtr dc.l 0
Ch4SpritePtr dc.l 0
CursorPosPtr dc.l 0
NoSpritePtr dc.l 0
; -----------------------------------------------------------------------------
; GENERAL VARIABLES
; -----------------------------------------------------------------------------
CNOP 0,4
StackSave dc.l 0
DOSBase dc.l 0
IntuitionBase dc.l 0
GfxBase dc.l 0
PPLibBase dc.l 0
NoteNamesPtr dc.l 0
SaveEditMode dc.l 0
EditMode dc.l 0
RunMode dc.l 0
CurrCmds dc.l 0
ShowTextPtr dc.l 0
PatternNumber dc.l 0
CurrPos dc.l 0
CurrSpeed dc.l 0
KeyTransTabPtr dc.l 0
DecompMemPtr dc.l 0
DecompMemSize dc.l 0
LongFFFF dc.l 0
TextEndPtr dc.l 0
LongWordNumber dc.l 0
MaxPLSTOffset dc.l 0
FileNamePtr dc.l 0
DiskDataPtr dc.l 0
FileHandle dc.l 0
DiskDataLength dc.l 0
PattRfshNum dc.l 0
PatternPosition dc.l 0
SongPosition dc.l 0
Counter dc.l 0
PathPtr dc.l 0
FileLock dc.l 0
FormatDataPtr dc.l 0
PsetPtrTemp dc.l 0
FreeDiskSpace dc.l 0
SplitAddress dc.l 0
LaHeTx dc.l $12345678
PLSTAllocSize dc.l 0
TrackdiskPort dc.l 0,0,0,0
ProcessPtr dc.l 0,0,0,0
DateStamp dc.l 0,0,0,0
SampleSortList dcb.l 32,0
PLSTmem dc.l 0
PosEdCurrPos dc.l 0
PLSTOffset dcb.l 14,0
PPattPos dc.w 0
TextOffset dc.w 0
TextLength dc.w 0
CmdOffset dc.w 0
MountFlag dc.w 0
GetLineFlag dc.w 0
LoadInProgress dc.w 0
CurrentPlayNote dc.w 214
LineCurX dc.w 0
LineCurY dc.w 0
ScrPattPos dc.w 0
PattCurPos dc.w 0
GadgRepeat dc.w 0
WordNumber dc.w 0
HighPattNum dc.w 0
InsNum dc.w 0
LastInsNum dc.w 1
PlayInsNum dc.w 1
HiLowInstr dc.w 0
PEDpos dc.w 0
PLSTpos dc.w 0
PresetMarkTotal dc.w 0
CurrentPreset dc.w 1
UpOrDown dc.w 0
MouseX2 dc.w 0
MouseY2 dc.w 0
DidQuantize dc.w 0
LowMask dc.w $FF00
DMACONtemp dc.w 0
CurrScreen dc.w 0
DiskOpScreen2 dc.w 0
SaveCurrScreen dc.w 0
PointerCol1Save dc.w 0
PointerCol2Save dc.w 0
PointerCol3Save dc.w 0
MoreInstrFlag dc.w 0
PresetTotal dc.w 0
CylinderNumber dc.w 0
Action dc.w 0
EnterTextFlag dc.w 0
PresetLength dc.w 0
PresetFineTune dc.w 0
PresetRepeat dc.w 0
PresetReplen dc.w 0
PED_Action dc.w 0
PsetNumTemp dc.w 0
MaxPLSTEntries2 dc.w 0
NumPatterns dc.w 0
AutoInsSlot dc.w 0
lbW015B92 dc.w 0
makeExeModFlag dc.w 0
AnalyzerHeights dcb.w 23,0
AnalyzerOpplegg dcb.w 23,0
RawKeyCode dc.b 0
PattRfsh dc.b 0
PosJumpAssert dc.b 0
PBreakPosition dc.b 0
PBreakFlag dc.b 0
LEDStatus dc.b 0
PattDelayTime dc.b 0
PattDelayTime2 dc.b 0
GetDecTemp dc.b 0
UpdateTempo dc.b 0
SaveScope dc.b 0
SetSignalFlag dc.b 0
DisableAnalyzer dc.b 0
SaveDA dc.b 0
StopInputFlag dc.b 0
NoSampleInfo dc.b 0,0
PosEdNames dcb.b 16*100,' '
AskBoxShown dc.b 0,0
AboutScreenShown dc.b 0
RightMouseButtonHeld dc.b 0
SmpConvLUT dcb.b 256,0
EVEN
; -----------------------------------------------------------------------------
; SETUP DATA
; -----------------------------------------------------------------------------
DefaultSetupData
dc.b 'PT2.3 Configuration File',$A,0
dc.b 'ST-00:Songs'
dcb.b 21,0
dc.b 'ST-00:Modules'
dcb.b 19,0
dc.b 'DF0:'
dcb.b 28,0
dc.b 'Prt:'
dcb.b 28,0
DefCol dc.w $000,$BBB,$888,$555,$FD0,$D04,$000,$34F
dc.b 1 ; Song Pack Mode
dc.b 0 ; Module Pack Mode
dc.b 0 ; Split 0=off, 1=on
dc.b 0 ; Filter
dc.b 0 ; TransDel
dc.b 1 ; ShowDec
dc.b 1 ; AutoDir
dc.b 1 ; AutoExit
dc.b 0 ; ModOnly
dc.b 0 ; MIDI
dc.b 1,$18,$18,0 ; SplitData
dc.b 2,$1A,$18,0
dc.b 3,$1C,$18,0
dc.b 4,$1D,$18,0
dc.w 20,2 ; KeyRepDelay/Speed
dc.b 0 ; Accidental
dc.b 0 ; not in use
dc.b 'NewShell',0 ; ExtCmd 0
dcb.b 23,0
dc.b 'Add21k',0 ; ExtCmd 1
dcb.b 25,0
dc.b 'Info',0 ; ExtCmd 2
dcb.b 27,0
dc.b 'List',0 ; ExtCmd 3
dcb.b 27,0
dc.b 'LoadWB -Debug',0 ; ExtCmd 4
dcb.b 18,0
dc.b 'DirectoryOpus',0 ; ExtCmd 5
dcb.b 18,0
dc.b 'Run AudioMasterIV',0 ; ExtCmd 6
dcb.b 14,0
dc.b 'CEd',0 ; ExtCmd 7
dcb.b 28,0
dc.w 0 ; Not in use
dc.w 2500 ; Max PLST Entries
dc.b 2,3,4,1 ; Multi Mode Next
dc.w $102,$202,$037,$047,$304, $F06,$C10,$C20,$E93,$A0F ; EFX Macros
dc.b 0 ; RAW/IFF/PAK Save, 0=RAW, 1=IFF, 2=PAK
dc.b 1 ; IntMode, 0=VBLANK, 1=CIA
dc.b 0 ; Override
dc.b 0 ; Nosamples
dc.b 0 ; BlankZero
dc.b 1 ; ShowDirs
dc.b 0 ; CutToBuf
dc.b 0 ; ShowPublic
dc.b 1 ; IFFLoop
dc.b 0 ; SysReqFlag
dc.w 125 ; Tempo
dc.w 300 ; DMAWait (not used anymore)
dc.w 24 ; TuneNote (C-3)
dc.w $20 ; TToneVol
dc.b 0 ; LoadTrackToBufferFlag
dc.b 0 ; LoadPattToBufferFlag
dc.b 0,0,0,0,0,0 ; (Pad to 512 bytes)
dc.b "ST-00:" ; ProTracker Path
dcb.b 26,0
dc.w 6 ; DefaultSpeed
dc.w $0F00,$0F00,$0F10,$0F10,$0F20,$0F20,$0F30,$0F30 ; VU-meter
dc.w $0F40,$0F50,$0F60,$0F70,$0F80,$0F90,$0FA0,$0FB0 ; colors
dc.w $0FC0,$0FD0,$0FE0,$0FF0,$0FF0,$0EF0,$0EF0,$0DF0
dc.w $0DF0,$0CF0,$0CF0,$0BF0,$0BF0,$0AF0,$09F0,$09F0
dc.w $08F0,$08F0,$07F0,$07F0,$06F0,$06F0,$05F0,$05F0
dc.w $04F0,$04F0,$03F0,$03F0,$02F0,$01F0,$00F0,$00E0
dc.w $0F00,$0F10,$0F20,$0F30,$0F40,$0F50,$0F60,$0F70 ; Analyzer
dc.w $0F80,$0F90,$0FA0,$0FB0,$0FC0,$0FD0,$0FE0,$0FF0 ; colors
dc.w $0EF0,$0DF0,$0CF0,$0BF0,$0AF0,$09F0,$08F0,$07F0
dc.w $06F0,$05F0,$04F0,$03F0,$02F0,$01F0,$00F0,$00E0
dc.w $00D0,$00C0,$00B0,$00A0,$0090,$0080,$0070,$0060
dc.b "ST-00:Tracks" ; Tracks Path
dcb.b 20,0
dc.b "ST-00:Patterns" ; Patterns Path
dcb.b 18,0
dc.b 0 ; SalvageFlag
dc.b 0 ; OneHundredPattFlag
dc.b 0 ; SaveIconsFlag
dc.b 0 ; LoadNamesFlag
dc.b 0 ; SaveNamesFlag
dc.b 0 ; LoadPLSTFlag
dc.b 0 ; ScreenAdjustFlag
dc.b 0 ; SamplePackFlag
dc.b 0 ; RealVUMetersFlag
dcb.b 229 ; Pad to 1024 bytes
; -----------------------------------------------------------------------------
; SAMPLER ROUTINES
; -----------------------------------------------------------------------------
_custom EQU $00DFF000
intreq EQU $0000009C
intreqr EQU $0000001E
intena EQU $0000009A
joy0dat EQU $0000000A
vhposr EQU $00000006
dmacon EQU $00000096
dmaconr EQU $00000002
CNOP 0,4
SamInfoPtr dc.l 0
SamInfoLen dc.l 0
SampleNote dc.w $18
ResampleNote dc.w $18
ChordTuneNote dc.w $18
SamIntSave dc.w 0
SamDMASave dc.w 0
ClearTempSampArea
LEA TempSampArea,A0
MOVE.W #380-1,D0
MOVEQ #0,D1
ctsalop MOVE.W D1,(A0)+
DBRA D0,ctsalop
RTS
Sampler CLR.B RawKeyCode
JSR StopIt
JSR TopExit
JSR WaitForButtonUp
JSR SetWaitPtrCol
BSR.W ShowMon
JSR Wait_4000
JSR ClearRightArea
JSR ClearAnalyzerColors
BSR.B ClearTempSampArea
BSR.W WaitForDiskDrive
MOVE.W $DFF01C,SamIntSave ; intenar
MOVE.W #$7FFF,$DFF09A ; _custom+intena
JSR TurnOffVoices
MOVE.W SampleNote(PC),D0
ADD.W D0,D0
LEA PeriodTable(PC),A0
MOVE.W (A0,D0.W),D0
LSR.W #1,D0
LEA $DFF000,A0
LEA $AA(A0),A5
LEA $BA(A0),A6
MOVE.W D0,$A6(A0)
MOVE.W D0,$B6(A0)
MOVEQ.L #$20,D0
MOVE.W D0,$A8(A0)
MOVE.W D0,$B8(A0)
MOVEQ #0,D0
MOVE.W D0,(A5)
MOVE.W D0,(A6)
MOVE.B #6,$BFD200
MOVEQ.L #2,D0
MOVE.B D0,$BFD000
MOVE.B #0,$BFE301
LEA GraphOffsets(PC),A0
LEA TempSampArea,A1
LEA TextBitplane+(2536-40),A2
LEA $BFE101,A3
LEA $DFF01E,A4 ; _custom+intreqr
MOVE.W #$0180,D7
MOVEQ #6,D6
MOVEQ #10,D3
monilop2
MOVEQ #23-1,D5
monilop4
MOVEQ #8-1,D4
monilop3
BTST D7,(A4)
BEQ.B monilop3
MOVE.W D7,$7E(A4)
MOVEQ #0,D0
MOVE.B (A3),D0
MOVE.W D0,D1
SUB.B D7,D0
MOVE.B D0,(A5)
MOVE.B D0,(A6)
LSR.W #3,D1
ADD.W D1,D1
MOVE.W (A0,D1.W),D0
MOVE.W (A1),D1
MOVE.W D0,(A1)+
BCLR D4,(A2,D1.W)
BSET D4,(A2,D0.W)
DBRA D4,monilop3
ADDQ #1,A2
DBRA D5,monilop4
LEA -23(A2),A2
LEA -368(A1),A1
BTST D6,-$0100(A3)
BEQ.W sampexit
BTST D3,-8(A4)
BNE.B monilop2
;-- start sampling --
MOVE.W InsNum(PC),D1
BEQ.W sampexit
LSL.W #2,D1
LEA SamplePtrs(PC),A0
MOVE.L (A0,D1.W),D0
BEQ.B samaok
CLR.L (A0,D1.W)
MOVE.L D0,A1
MOVE.L 124(A0,D1.W),D0
BEQ.B samaok
CLR.L 124(A0,D1.W)
JSR PTFreeMem
samaok MOVE.L #$1FFFE,D6 ; try 128k
samalclop
MOVE.L D6,D0
MOVE.L #MEMF_CHIP!MEMF_CLEAR,D1
JSR PTAllocMem
TST.L D0
BNE.B samalcok
SUB.L #2048,D6 ; try 2k less
BPL.B samalclop
JSR OutOfMemErr
BRA.W sampexit
samalcok
MOVE.W InsNum(PC),D1
LSL.W #2,D1
LEA SamplePtrs(PC),A0
MOVE.L D0,(A0,D1.W)
MOVE.L D6,124(A0,D1.W)
MOVE.W $DFF002,SamDMASave
MOVE.W #$03FF,$DFF096 ; _custom+dmacon
BSR.W GetSampleInfo
MOVE.L SamInfoLen(PC),D4
CLR.W $DFF100
CLR.W $DFF180
MOVE.L SamInfoPtr(PC),A1
LEA $DFF09C,A2 ; _custom+intreq
LEA $BFE101,A3 ; parallel port
LEA $DFF01E,A4 ; _custom+intreqr
LEA $DFF0BA,A6
MOVE.W #$0180,D7
MOVEQ #6,D6
MOVEQ #0,D5
samploop
BTST D7,(A4)
BEQ.B samploop
MOVE.W D7,(A2)
MOVE.B (A3),D0
SUB.B D7,D0
MOVE.B D0,(A5)
MOVE.B D0,(A6)
MOVE.B D0,(A1)+
ADDQ.L #1,D5
CMP.L D4,D5
BEQ.B sampend
BTST D6,-$0100(A3)
BNE.B samploop
sampend MOVE.W SamDMASave(PC),D0
OR.W #$8000,D0
MOVE.W D0,$DFF096
MOVE.L A1,D0
SUB.L SamInfoPtr(PC),D0
MOVE.L D0,SamInfoLen
MOVE.L SongDataPtr(PC),A0
MOVE.W InsNum(PC),D1
MULU.W #30,D1
LEA 12(A0,D1.W),A0
MOVE.L SamInfoLen(PC),D0
LSR.L #1,D0
MOVE.W D0,(A0)+
MOVE.W #$0040,(A0)+
CLR.W (A0)+
MOVE.W #1,(A0)
; If we didn't fill up the whole sampling buffer,
; free the memory we didn't use (this is hackish)
;
; XXX: THIS IS NOT SAFE !!
;
MOVE.L SamInfoLen(PC),D1
NEG.L D1
AND.L #$FFFFFFF8,D1
NEG.L D1 ; D1 is now a multiple of 8 (for FreeMem)
MOVE.W InsNum(PC),D0
LSL.W #2,D0
LEA SamplePtrs(PC),A0
CMP.L 124(A0,D0.W),D1
BGE.B sampexit
MOVE.L 124(A0,D0.W),D2
MOVE.L D1,124(A0,D0.W)
SUB.L D1,D2
MOVE.L (A0,D0.W),A1
MOVE.L 124(A0,D0.W),D0
ADD.L D0,A1 ; A1 points to the area we didn't use in our alloc
MOVE.L D2,D0 ; D0 = size of memory we didn't use
JSR PTFreeMem
sampexit
MOVE.W SamIntSave(PC),D0
BSET #15,D0
MOVE.W D0,$DFF09A
JSR TurnOffVoices
JSR DisplayMainScreen
BSR.W ClearSamStarts
BSR.W ShowSampleInfo
BSR.W RedrawSample
JSR WaitForButtonUp
CLR.W KeyBufPos
CLR.B RawKeyCode
CLR.W ShiftKeyStatus
JMP Wait_4000
SampleNullInfo
CLR.L SamInfoPtr
CLR.L SamInfoLen
MOVEQ #-1,D0
RTS
GetSampleInfo
MOVE.W InsNum(PC),D0
BEQ.B SampleNullInfo
LSL.B #2,D0
LEA SamplePtrs(PC),A0
MOVE.L (A0,D0.W),SamInfoPtr
MOVE.L 124(A0,D0.W),SamInfoLen
MOVEQ #0,D0
RTS
ShowMon SF ScopeEnable
ST DisableAnalyzer
JSR ClearRightArea
LEA MonitorData,A0
MOVE.L #MonitorSize,D0
MOVEQ #-1,D4
JMP cgjojo
WaitForDiskDrive
JSR StorePtrCol
ST DiskDriveBusy
MOVE.L 4.W,A6
LEA $15E(A6),A0 ; DeviceList
LEA TrackdiskName(PC),A1 ; trackdisk.device
JSR _LVOFindName(A6)
MOVE.L D0,A6
LEA $24(A6),A6 ; dn_GlobalVec
trdloop2
MOVE.L A6,A1
MOVEQ #4-1,D6
tdrloop TST.L (A1)+
BEQ.B tdrskip
MOVE.L -4(A1),A2
BTST #0,$22(A2)
BNE.B tdrnotset
tdrskip DBRA D6,tdrloop
SF DiskDriveBusy
JMP RestorePtrCol
DiskDriveBusy dc.b 0
EVEN
tdrnotset
JSR SetDiskPtrCol
BRA.B trdloop2
ClearSamStarts
LEA SamplePtrs+4(PC),A0
MOVEQ #31-1,D0
MOVEQ #0,D2
cssLoop MOVE.L (A0)+,D1
BEQ.B cssSkip
MOVE.L D1,A1
CLR.W (A1)
cssSkip DBRA D0,cssLoop
RTS
GraphOffsets
dc.w 31*40,30*40,29*40,28*40,27*40,26*40,25*40,24*40
dc.w 23*40,22*40,21*40,20*40,19*40,18*40,17*40,16*40
dc.w 15*40,14*40,13*40,12*40,11*40,10*40,09*40,08*40
dc.w 07*40,06*40,05*40,04*40,03*40,02*40,01*40,00*40
SamNoteType dc.w 0
ShowSamNote
TST.W SamScrEnable
BEQ.W Return3
MOVE.L NoteNamesPtr(PC),A4
MOVE.W #237*40+36,TextOffset
MOVE.W SampleNote(PC),D0
LSL.W #2,D0
LEA (A4,D0.W),A0
MOVE.L A0,ShowTextPtr
MOVE.W #4,TextLength
BRA.W ShowText
ShowResamNote
TST.W SamScrEnable
BEQ.W Return3
MOVE.L NoteNamesPtr(PC),A4
MOVE.W #248*40+36,TextOffset
MOVE.W ResampleNote(PC),D0
LSL.W #2,D0
LEA (A4,D0.W),A0
MOVE.L A0,ShowTextPtr
MOVE.W #4,TextLength
BRA.W ShowText
; -----------------------------------------------------------------------------
; EXE REPLAYER DATA
; -----------------------------------------------------------------------------
CNOP 0,4
exeDotInfoData INCBIN "bin/dotinfo.bin"
CNOP 0,4
exeReplayData INCBIN "bin/exereplay.bin"
CNOP 0,4
exeReplayRelocHunk INCBIN "bin/reloc32hunk.bin"
; -----------------------------------------------------------------------------
; GRAPHICS DATA
; -----------------------------------------------------------------------------
SpectrumAnaSize = 839
AboutBoxSize = 1730
ScopeSize = 1713
DirScreenSize = 2882
PLSTSize = 1896-8
PosEdSize = 1945-8
Edit1Size = 1748
Edit2Size = 1902
Edit3Size = 2134
Edit4Size = 2174
SetupScreenSize = 5448
Setup2Size = 5071
PresetEdSize = 5169
SampScreenSize = 3838
MonitorSize = 817
HelpScreenSize = 900
CNOP 0,4
FontData INCBIN "raw/ptfont.raw"
CNOP 0,4
SpectrumAnaData INCBIN "pak/ptspectrumana.pak"
CNOP 0,4
ScopeData INCBIN "pak/ptscope.pak"
CNOP 0,4
AboutBoxData INCBIN "pak/ptaboutbox.pak"
CNOP 0,4
SureBoxData INCBIN "raw/ptsurebox.raw"
CNOP 0,4
ClearBoxData INCBIN "raw/ptclearbox.raw"
CNOP 0,4
FormatBoxData INCBIN "raw/ptformatbox.raw"
CNOP 0,4
TrackNameBox INCBIN "raw/pttrknamebox.raw"
CNOP 0,4
CrunchBoxData INCBIN "raw/ptcrunchbox.raw"
CNOP 0,4
DirScreenData INCBIN "pak/ptfilereq.pak"
CNOP 0,4
DirScreen2Data INCBIN "pak/ptfilereq2.pak"
CNOP 0,4
PLSTData INCBIN "pak/ptplst.pak"
CNOP 0,4
PosEdData INCBIN "pak/ptposed.pak"
CNOP 0,4
Edit1Data INCBIN "pak/ptedit1.pak"
CNOP 0,4
Edit2Data INCBIN "pak/ptedit2.pak"
CNOP 0,4
Edit3Data INCBIN "pak/ptedit3.pak"
CNOP 0,4
Edit4Data INCBIN "pak/ptedit4.pak"
CNOP 0,4
SetupScreenData INCBIN "pak/ptsetup.pak"
CNOP 0,4
Setup2Data INCBIN "pak/ptsetup2.pak"
CNOP 0,4
Setup2ToggleData INCBIN "raw/ptsetup2toggles.raw"
CNOP 0,4
PresetEdData INCBIN "pak/ptpreseted.pak"
CNOP 0,4
SampScreenData INCBIN "pak/ptsampler.pak"
CNOP 0,4
MonitorData INCBIN "pak/ptmonitor.pak"
CNOP 0,4
HelpScreenData INCBIN "pak/pthelpscreen.pak"
CNOP 0,4
VolBoxData INCBIN "raw/ptvolbox.raw"
CNOP 0,4
ToggleONdata INCBIN "raw/pttoggleon.raw"
CNOP 0,4
ToggleOFFdata INCBIN "raw/pttoggleoff.raw"
CNOP 0,4
S_BoxData INCBIN "raw/ptletters.raw"
A_BoxData EQU S_BoxData+22
T_BoxData EQU S_BoxData+44
P_BoxData EQU S_BoxData+66
H_BoxData EQU S_BoxData+88
C_BoxData EQU S_BoxData+110
N_BoxData EQU S_BoxData+132
O_BoxData EQU S_BoxData+154
; Converts pattern-period to LUT index for NotesNames1/NoteNames2 (dword)
Period2Note:
dc.b 140,148,148,148,148,148,148,136,148,148,148,148,148,148,132,148
dc.b 148,148,148,148,148,148,128,148,148,148,148,148,148,148,124,148
dc.b 148,148,148,148,148,148,120,148,148,148,148,148,148,148,148,116
dc.b 148,148,148,148,148,148,148,148,148,112,148,148,148,148,148,148
dc.b 148,148,148,108,148,148,148,148,148,148,148,148,148,104,148,148
dc.b 148,148,148,148,148,148,148,148,148,100,148,148,148,148,148,148
dc.b 148,148,148,148,148, 96,148,148,148,148,148,148,148,148,148,148
dc.b 148, 92,148,148,148,148,148,148,148,148,148,148,148,148,148, 88
dc.b 148,148,148,148,148,148,148,148,148,148,148,148,148, 84,148,148
dc.b 148,148,148,148,148,148,148,148,148,148,148,148, 80,148,148,148
dc.b 148,148,148,148,148,148,148,148,148,148,148,148, 76,148,148,148
dc.b 148,148,148,148,148,148,148,148,148,148,148,148,148, 72,148,148
dc.b 148,148,148,148,148,148,148,148,148,148,148,148,148,148,148, 68
dc.b 148,148,148,148,148,148,148,148,148,148,148,148,148,148,148,148
dc.b 148,148, 64,148,148,148,148,148,148,148,148,148,148,148,148,148
dc.b 148,148,148,148,148,148,148, 60,148,148,148,148,148,148,148,148
dc.b 148,148,148,148,148,148,148,148,148,148,148,148, 56,148,148,148
dc.b 148,148,148,148,148,148,148,148,148,148,148,148,148,148,148,148
dc.b 148,148,148, 52,148,148,148,148,148,148,148,148,148,148,148,148
dc.b 148,148,148,148,148,148,148,148,148,148,148, 48,148,148,148,148
dc.b 148,148,148,148,148,148,148,148,148,148,148,148,148,148,148,148
dc.b 148,148,148,148, 44,148,148,148,148,148,148,148,148,148,148,148
dc.b 148,148,148,148,148,148,148,148,148,148,148,148,148,148,148, 40
dc.b 148,148,148,148,148,148,148,148,148,148,148,148,148,148,148,148
dc.b 148,148,148,148,148,148,148,148,148,148,148, 36,148,148,148,148
dc.b 148,148,148,148,148,148,148,148,148,148,148,148,148,148,148,148
dc.b 148,148,148,148,148,148,148,148,148, 32,148,148,148,148,148,148
dc.b 148,148,148,148,148,148,148,148,148,148,148,148,148,148,148,148
dc.b 148,148,148,148,148,148,148,148,148, 28,148,148,148,148,148,148
dc.b 148,148,148,148,148,148,148,148,148,148,148,148,148,148,148,148
dc.b 148,148,148,148,148,148,148,148,148,148,148, 24,148,148,148,148
dc.b 148,148,148,148,148,148,148,148,148,148,148,148,148,148,148,148
dc.b 148,148,148,148,148,148,148,148,148,148,148,148,148,148,148, 20
dc.b 148,148,148,148,148,148,148,148,148,148,148,148,148,148,148,148
dc.b 148,148,148,148,148,148,148,148,148,148,148,148,148,148,148,148
dc.b 148,148,148,148,148, 16,148,148,148,148,148,148,148,148,148,148
dc.b 148,148,148,148,148,148,148,148,148,148,148,148,148,148,148,148
dc.b 148,148,148,148,148,148,148,148,148,148,148,148,148,148,148, 12
dc.b 148,148,148,148,148,148,148,148,148,148,148,148,148,148,148,148
dc.b 148,148,148,148,148,148,148,148,148,148,148,148,148,148,148,148
dc.b 148,148,148,148,148,148,148,148,148, 8,148,148,148,148,148,148
dc.b 148,148,148,148,148,148,148,148,148,148,148,148,148,148,148,148
dc.b 148,148,148,148,148,148,148,148,148,148,148,148,148,148,148,148
dc.b 148,148,148,148,148,148,148, 4,148,148,148,148,148,148,148,148
dc.b 148,148,148,148,148,148,148,148,148,148,148,148,148,148,148,148
dc.b 148,148,148,148,148,148,148,148,148,148,148,148,148,148,148,148
dc.b 148,148,148,148,148,148,148, 0
EVEN
; -----------------------------------------------------------------------------
; CHIPMEM DATA
; -----------------------------------------------------------------------------
SECTION ptdata,DATA_C
CNOP 0,4
BitplaneData INCBIN "raw/ptmainscreen.raw"
TopMenusPos EQU BitplaneData+55
Setup2Menus EQU BitplaneData+506
SpectrumAnaPos EQU BitplaneData+1815
FormatBoxPos EQU BitplaneData+2090
SureBoxPos EQU BitplaneData+2100
SamScrPos EQU BitplaneData+4880
VolBoxPos EQU BitplaneData+6209
TToneData ; Tuning Tone (Sine Wave)
dc.b 0, 25, 49, 71, 91, 106, 118, 126
dc.b 127, 126, 118, 106, 91, 71, 49, 25
dc.b 0, -25, -49, -71, -91,-106,-118,-126
dc.b -127,-126,-118,-106, -91, -71, -49, -25
CNOP 0,4
CopperList1
; ---------------
; video mode
; ---------------
dc.w $008E ; DIWSTRT ($DFF08E)
dc.w $2C81 ; "Normal" value
dc.w $0090 ; DIWSTOP ($DFF090)
dc.w $2CC1 ; "Normal" value
dc.w $0092 ; DDFSTRT ($DFF092)
dc.w $0038 ; "Normal" value
dc.w $0094 ; DDFSTOP ($DFF094)
dc.w $00D0 ; "Normal" value
dc.w $0102 ; BPLCON1 ($DFF102)
dc.w $0000
dc.w $0104 ; BPLCON2 ($DFF104)
dc.w $0024
dc.w $0106 ; BPLCON3 ($DFF106)
dc.w $0C40
dc.w $0108 ; BPL1MOD ($DFF108)
dc.w $0000
dc.w $010A ; BPL2MOD ($DFF10A)
dc.w $0000
dc.w $010C ; BPLCON4 ($DFF10C)
dc.w $0011
dc.w $01DC ; BEAMCON0 ($DFF1DC)
dc.w $0020 ; = PAL flag set
dc.w $01FC ; FMODE ($DFF1FC)
dc.w $0000 ; slow fetch (AGA compatible)
; ---------------
; sprites
; ---------------
CopperSpriteList
dc.w $0120 ; Sprite 0 high
dc.w 0
dc.w $0122 ; Sprite 0 low
dc.w 0
dc.w $0124 ; Sprite 1 high
dc.w 0
dc.w $0126 ; Sprite 1 low
dc.w 0
dc.w $0128 ; Sprite 2 high
dc.w 0
dc.w $012A ; Sprite 2 low
dc.w 0
dc.w $012C ; Sprite 3 high
dc.w 0
dc.w $012E ; Sprite 3 low
dc.w 0
dc.w $0130 ; Sprite 4 high
dc.w 0
dc.w $0132 ; Sprite 4 low
dc.w 0
dc.w $0134 ; Sprite 5 high
dc.w 0
dc.w $0136 ; Sprite 5 low
dc.w 0
dc.w $0138 ; Sprite 6 high
dc.w 0
dc.w $013A ; Sprite 6 low
dc.w 0
dc.w $013C ; Sprite 7 high
dc.w 0
dc.w $013E ; Sprite 7 low
dc.w 0
; ---------------
; palette
; ---------------
dc.w $0180 ; Color 0
CopCol0 dc.w $000
dc.w $0182 ; Color 1
dc.w $AAA
dc.w $0184 ; Color 2
dc.w $777
dc.w $0186 ; Color 3
dc.w $444
dc.w $0188 ; Color 4
dc.w $CCC
dc.w $018A ; Color 5
dc.w $A00
dc.w $018C ; Color 6
dc.w $000
dc.w $018E ; Color 7
dc.w $04D
CopCol1 dc.w $01A2 ; Color 1
dc.w $AAA
dc.w $01A4 ; Color 2
dc.w $888
dc.w $01A6 ; Color 3
dc.w $666
dc.w $01A0 ; Color 4
dc.w $000
dc.w $01BA ; Color 5
dc.w $C00
dc.w $01BC ; Color 6
dc.w $900
dc.w $01BE ; Color 7
dc.w $F00
; ---------------
; bitplane pointers
; ---------------
CopListBitplanes
dc.w $00E0 ; Bitplane 0 high
dc.w 0
dc.w $00E2 ; Bitplane 0 low
dc.w 0
dc.w $00E4 ; Bitplane 1 high
dc.w 0
dc.w $00E6 ; Bitplane 1 low
dc.w 0
dc.w $00E8 ; Bitplane 2 high
NoteBplptrHigh
dc.w 0
dc.w $00EA ; Bitplane 2 low
NoteBplptrLow
dc.w 0
; ---------------
; misc
; ---------------
dc.w $0100
dc.w $3200
CopListAnalyzer
dcb.w 320,0
CopListInsPos
dc.w $B807 ; Wait for line $88, pos $07
dc.w $FFFE
dc.w $0100 ; bplcon0
dc.w $2200
CopListBpl4
dc.w $00E8 ; Bitplane 4 high
dc.w 0
dc.w $00EA ; Bitplane 4 low
dc.w 0
dc.w $0188 ; Color 4
NoteCol dc.w $004D
dc.w $B907 ; Wait for line $89, pos $07
dc.w $FFFE
dc.w $0100 ; bplcon0
dc.w $3200
CopListMark2
dcb.w 672,0
dc.w $E907 ; Wait for line $E9, pos $07
dc.w $FFFE
dc.w $010A ; bpl2mod
dc.w $FFD8
dc.w $0108 ; bpl1mod
dc.w $FFD8
dc.w $EA07 ; Wait for line $EA, pos $07
dc.w $FFFE
dc.w $010A ; bpl2mod
dc.w 0
dc.w $0108 ; bpl1mod
dc.w 0
dc.w $EB07 ; Wait for line $E8, pos $07
dc.w $FFFE
dc.w $010A ; bpl2mod
dc.w $FFD8
dc.w $0108 ; bpl1mod
dc.w $FFD8
dc.w $EC07 ; Wait for line $EC, pos $07
dc.w $FFFE
dc.w $010A ; bpl2mod
dc.w 0
dc.w $0108 ; bpl1mod
dc.w 0
dc.w $ED07 ; Wait for line $ED, pos $07
dc.w $FFFE
dc.w $010A ; bpl2mod
dc.w $FFD8
dc.w $0108 ; bpl1mod
dc.w $FFD8
dc.w $EE07 ; Wait for line $EE, pos $07
dc.w $FFFE
dc.w $010A ; bpl2mod
dc.w 0
dc.w $0108 ; bpl1mod
dc.w 0
dc.w $EF07 ; Wait for line $EF, pos $07
dc.w $FFFE
dc.w $010A ; bpl2mod
dc.w $FFD8
dc.w $0108 ; bpl1mod
dc.w $FFD8
dc.w $F007 ; Wait for line $F0, pos $07
dc.w $FFFE
dc.w $010A ; bpl2mod
dc.w 0
dc.w $0108 ; bpl1mod
dc.w 0
dc.w $F107 ; Wait for line $F1, pos $07
dc.w $FFFE
dc.w $010A ; bpl2mod
dc.w $FFD8
dc.w $0108 ; bpl1mod
dc.w $FFD8
dc.w $F207 ; Wait for line $F2, pos $07
dc.w $FFFE
dc.w $010A ; bpl2mod
dc.w 0
dc.w $0108 ; bpl1mod
dc.w 0
dc.w $F307 ; Wait for line $F3, pos $07
dc.w $FFFE
dc.w $010A ; bpl2mod
dc.w $FFD8
dc.w $0108 ; bpl1mod
dc.w $FFD8
dc.w $F407 ; Wait for line $F4, pos $07
dc.w $FFFE
dc.w $010A ; bpl2mod
dc.w 0
dc.w $0108 ; bpl1mod
dc.w 0
dc.w $F507 ; Wait for line $F5, pos $07
dc.w $FFFE
dc.w $010A ; bpl2mod
dc.w $FFD8
dc.w $0108 ; bpl1mod
dc.w $FFD8
dc.w $F607 ; Wait for line $F6, pos $07
dc.w $FFFE
dc.w $010A ; bpl2mod
dc.w 0
dc.w $0108 ; bpl1mod
dc.w 0
dc.w $FFDF ; Wait for line $FF, pos $DF
dc.w $FFFE
dc.w $2907 ; Wait for line $29, pos $07
dc.w $FFFE
dc.w $0100 ; bplcon0
dc.w $2200
dc.w $2C07 ; Wait for line $2C, pos $07
dc.w $FFFE
dc.w $0100 ; bplcon0
dc.w $0200
dc.w $FFFF ; Wait for line $FF, pos $FF
dc.w $FFFE ; End of copperlist
CopperList2
dc.w $B607 ; Wait for line $B6, pos $07
dc.w $FFFE
dc.w $0100 ; bplcon0
dc.w $2200
CopList2Bpl4Ptr
dc.w $00E8 ; Bitplane 4 high
dc.w 0
dc.w $00EA ; Bitplane 4 low
dc.w 0
dc.w $0188 ; Color 4
dc.w $004D
dc.w $01AA ; Color 21
dc.w $00F0
dc.w $01B2 ; LoopSprite color
dc.w $00FF
dc.w $B707 ; Wait for line $B7, pos $07
dc.w $FFFE
dc.w $0100 ; bplcon0
dc.w $3200
dc.w $FFDF ; Wait for line $FF, pos $DF
dc.w $FFFE
dc.w $2907 ; Wait for line $29, pos $07
dc.w $FFFE
dc.w $0100 ; bplcon0
dc.w $2200
dc.w $2C07 ; Wait for line $2C, pos $07
dc.w $FFFE
dc.w $0100 ; bplcon0
dc.w $0200
dc.w $FFFF ; Wait for line $FF, pos $FF
dc.w $FFFE ; End of copperlist
PointerSpriteData
dc.w 0,0
dc.w $FFFF,$FFFF,$8002,$FFFE,$BFF4,$C00C,$BFE8,$C018
dc.w $BFD0,$C030,$BFE8,$C018,$BFF4,$C00C,$BFFA,$C006
dc.w $BFFD,$C003,$BFFA,$C006,$B7F4,$C80C,$ABE8,$DC18
dc.w $95D0,$F630,$A2A0,$E360,$C140,$C1C0,$8080,$8080
NoSpriteData
dc.w 0,0,0,0
CursorSpriteData
dc.w 0,0
dc.w $FFE0,$FFE0,$FFE0,$FFE0,$8020,$0000,$8020,$0000
dc.w $8020,$0000,$8020,$0000,$8020,$0000,$8020,$0000
dc.w $8020,$0000,$8020,$0000,$8020,$0000,$8020,$0000
dc.w $0000,$FFE0,$0000,$FFE0
dc.w 0,0
LineCurSpriteData
dc.w 0,0,$0000,$FE00,$0000,$FE00,$0000,$0000,0,0
VUSpriteData1
dc.w $E85B,$E901
dcb.l 48,$C0C03FC0
dc.w 0,0
VUSpriteData2
dc.w $E87F,$E901
dcb.l 48,$C0C03FC0
dc.w 0,0
VUSpriteData3
dc.w $E8A3,$E901
dcb.l 48,$C0C03FC0
dc.w 0,0
VUSpriteData4
dc.w $E8C7,$E901
dcb.l 48,$C0C03FC0
dc.w 0,0
LoopSpriteData1
dc.w 0,0
dc.w $F000,0,$F000,0,$F000,0,$F000,0,$1000,0,$1000,0,$1000,0,$1000,0
dc.w $1000,0,$1000,0,$1000,0,$1000,0,$1000,0,$1000,0,$1000,0,$1000,0
dc.w $1000,0,$1000,0,$1000,0,$1000,0,$1000,0,$1000,0,$1000,0,$1000,0
dc.w $1000,0,$1000,0,$1000,0,$1000,0,$1000,0,$1000,0,$1000,0,$7000,0
dc.w $1000,0,$1000,0,$1000,0,$1000,0,$1000,0,$1000,0,$1000,0,$1000,0
dc.w $1000,0,$1000,0,$1000,0,$1000,0,$1000,0,$1000,0,$1000,0,$1000,0
dc.w $1000,0,$1000,0,$1000,0,$1000,0,$1000,0,$1000,0,$1000,0,$1000,0
dc.w $1000,0,$1000,0,$1000,0,$1000,0,$1000,0,$1000,0,$1000,0,$1000,0
dc.w 0,0
LoopSpriteData2
dc.w 0,0
dc.w $F000,0,$F000,0,$F000,0,$F000,0,$8000,0,$8000,0,$8000,0,$8000,0
dc.w $8000,0,$8000,0,$8000,0,$8000,0,$8000,0,$8000,0,$8000,0,$8000,0
dc.w $8000,0,$8000,0,$8000,0,$8000,0,$8000,0,$8000,0,$8000,0,$8000,0
dc.w $8000,0,$8000,0,$8000,0,$8000,0,$8000,0,$8000,0,$8000,0,$E000,0
dc.w $8000,0,$8000,0,$8000,0,$8000,0,$8000,0,$8000,0,$8000,0,$8000,0
dc.w $8000,0,$8000,0,$8000,0,$8000,0,$8000,0,$8000,0,$8000,0,$8000,0
dc.w $8000,0,$8000,0,$8000,0,$8000,0,$8000,0,$8000,0,$8000,0,$8000,0
dc.w $8000,0,$8000,0,$8000,0,$8000,0,$8000,0,$8000,0,$8000,0,$8000,0
dc.w 0,0
PlayPosSpriteData
dc.w 0,0
dc.w $8000,0,$8000,0,$8000,0,$8000,0,$8000,0,$8000,0,$8000,0,$8000,0
dc.w $8000,0,$8000,0,$8000,0,$8000,0,$8000,0,$8000,0,$8000,0,$8000,0
dc.w $8000,0,$8000,0,$8000,0,$8000,0,$8000,0,$8000,0,$8000,0,$8000,0
dc.w $8000,0,$8000,0,$8000,0,$8000,0,$8000,0,$8000,0,$8000,0,$8000,0
dc.w $8000,0,$8000,0,$8000,0,$8000,0,$8000,0,$8000,0,$8000,0,$8000,0
dc.w $8000,0,$8000,0,$8000,0,$8000,0,$8000,0,$8000,0,$8000,0,$8000,0
dc.w $8000,0,$8000,0,$8000,0,$8000,0,$8000,0,$8000,0,$8000,0,$8000,0
dc.w $8000,0,$8000,0,$8000,0,$8000,0,$8000,0,$8000,0,$8000,0,$8000,0
dc.w 0,0
; -----------------------------------------------------------------------------
; CHIPMEM BSS DATA
; -----------------------------------------------------------------------------
SECTION ptbssc,BSS_C
CNOP 0,4
TextBitplane ds.b (320*685)/8 ; 685 scanlines (exactly enough!)
; -----------------------------------------------------------------------------
; BSS DATA
; -----------------------------------------------------------------------------
SECTION ptbss,BSS
CNOP 0,4
FileInfoBlock ds.b 256
FIB_EntryType EQU FileInfoBlock+4
FIB_FileName EQU FileInfoBlock+8
FIB_FileSize EQU FileInfoBlock+124
FIB_DateStamp EQU FileInfoBlock+132
InfoData ds.b 36
TopMenusBuffer ds.b 2200
TextDataBuffer ds.b 546
TrackBuffer ds.b 256
TrackReadBuffer ds.b 256
CmdsBuffer ds.b 256
BlockBuffer ds.b 256
PatternBuffer ds.b 1024
PattDiskBuffer ds.b 1024
UndoBuffer ds.b 1024
TrackdiskIOExtTD
ds.w 1
ds.l 3
TDPortPtr ds.l 1
ds.w 1
Fmt_tja ds.w 1
ds.l 2
ds.b 3
Fmt_hmmm ds.b 1
ds.w 1
FmtDataSize ds.w 2
FmtDataPtr ds.w 2
FmtDiskOffset ds.l 9
SplitTransTable ds.b 38
SplitInstrTable ds.b 38
ModulesPath2 ds.b 64
SongsPath2 ds.b 64
SamplePath2 ds.b 64
TrackPath2 ds.b 64
PattPath2 ds.b 64
EVEN
; Setup Data
SetupData ds.b 26
SongsPath ds.b 32
ModulesPath ds.b 32
SamplePath ds.b 32
PrintPath ds.b 32
ColorTable ds.w 8
PackMode ds.b 1
ModPackMode ds.b 1
SplitFlag ds.b 1
FilterFlag ds.b 1
TransDelFlag ds.b 1
ShowDecFlag ds.b 1
AutoDirFlag ds.b 1
AutoExitFlag ds.b 1
ModOnlyFlag ds.b 1
MIDIFlag ds.b 1
SplitData ds.b 4
ds.b 4
ds.b 4
ds.b 4
KeyRepDelay ds.w 1
KeyRepSpeed ds.w 1
Accidental ds.b 1
ds.b 1 ; not in use
ExtCommands ds.b 32*8 ; setup data now at 256 bytes
ds.w 1 ; not in use
MaxPLSTEntries ds.w 1
MultiModeNext ds.b 4
EffectMacros ds.w 10
RawIFFPakMode ds.b 1
IntMode ds.b 1
OverrideFlag ds.b 1
NosamplesFlag ds.b 1
BlankZeroFlag ds.b 1
ShowDirsFlag ds.b 1
ShowPublicFlag ds.b 1
CutToBufFlag ds.b 1
IFFLoopFlag ds.b 1
SysReqFlag ds.b 1
Tempo ds.w 1
DMAWait ds.w 1 ; not used
TuneNote ds.w 1
TToneVol ds.w 1
LoadTrackToBufferFlag ds.b 1
LoadPattToBufferFlag ds.b 1
SalvageAddress ds.b 6
PTPath ds.b 32 ; setup data now at 512 bytes
DefaultSpeed ds.w 1
VUmeterColors ds.w 48
AnalyzerColors ds.w 40
TrackPath ds.b 32
PattPath ds.b 32
SalvageFlag ds.b 1
OneHundredPattFlag ds.b 1
SaveIconsFlag ds.b 1
LoadNamesFlag ds.b 1
SaveNamesFlag ds.b 1
LoadPLSTFlag ds.b 1
ScreenAdjustFlag ds.b 1
SamplePackFlag ds.b 1
RealVUMetersFlag ds.b 1
ds.b 229 ; pad to 1024 bytes
; End of Setup Data
CNOP 0,4
HelpTextIndex ds.l 256
HelpTextData ds.b 656
InpEvPort ds.b 34
InpEvIOReq ds.b 48
CNOP 0,4
ScopeInfo ds.b ScopeInfoSize*4
CNOP 0,4
ScopeSamInfo ds.b 16*31
BlankSample ds.b 314
FileName ds.b 96
NewFileName ds.b 96
SampleFileName ds.b 28
PresetNameText ds.b 22
DirInputName ds.b DirNameLength
InputFileName ds.b 20
NewInputName ds.b DirNameLength
TempSampArea ds.w 380
SaveColors ds.w 40+48
BeamCONTemp ds.w 2
PaulaDMAWaitScanlines ds.w 1
GUIDelayScanlines ds.w 1
VolToolBoxShown ds.b 1
ShowRasterbar ds.b 1
END
; /* End of File */
|
8bitbubsy/pt23f
| 31,918
|
replayer/PT2.3F_replay_cia.s
|
;*******************************************************
;* ----- ProTracker V2.3F Replay Routine (CIA) ----- *
;*******************************************************
;
; This replayer has been slightly optimized over the PT2.3D replayer,
; but it's still far from fully optimized. It has also been rewritten to
; behave like PT2.3F's internal replayer, for maximum accuracy.
;
; Changelog:
; - 04.10.2021: Fixed crucial bug in mt_init. Thanks to insane/Rabenauge^tSCc!
; - 05.10.2021: Fixed LUT bug in arpeggio routine. Thanks again to insane!
;
; - 04.11.2021: 1) Rewritten again to match PT2.3F's internal replayer
; 2) Removed MULUs/DIVUs, as part of optimizing
; 3) dword alignment, as part of optimizing
; 4) Long CMP+BEQ chains replaced with jump tables
; 5) Fixed tremolo effect & sample-num + volume slide
; 6) Set back old LED status on exit
; 7) Set default BPM on mt_init
; 8) Clear more replayer variables on mt_init
;
; - 26.06.2023: Fixed my own bug on .MODs with a ton of patterns
; - 28.06.2023: 1) Fixed my own bug in mt_init (bytes written out-of-bounds)
; 2) Removed Karplus-Strong effect (just like other PT players)
; 3) Changed some logic to remove need for stacking regs in places
; 4) Small code cleanup
; - 17.11.2024: Small arpeggio effect optimization
; - 12.03.2025: mt_LowMask was not initialized correctly (small portamento bug)
; - 13.03.2025: Register preserving in mt_end
; - 21.05.2025: Set Sample Offset (9xx) now works on >64kB samples
; - 23.06.2025: Removed 512-byte optimization LUT for E9x (Retrig Note)
; CIA Version:
; Call SetCIAInt to install the interrupt server. Then call mt_init
; to initialize the song. Playback starts when the mt_enable flag
; is set to a non-zero value. To end the song and turn off all voices,
; call mt_end. At last, call ResetCIAInt to remove the interrupt.
;
; You can use this routine to play a module. Just remove the semicolons.
; Also change the module path in mt_data at the very bottom of this file.
; Exit by pressing both mouse buttons.
;
main BSR.W SetCIAInt
BSR.W mt_init
ST mt_Enable
MOVE.L 4.W,A6
LEA DOSName(PC),A1
MOVEQ #0,D0
JSR LVOOpenLibrary(A6)
TST.L D0
BEQ.B theend
MOVE.L D0,A6
wloop MOVEQ #10,D1
JSR LVODelay(A6)
BTST #6,$BFE001
BNE.B wloop
BTST #2,$DFF016
BNE.B wloop
MOVE.L A6,A1
MOVE.L 4.W,A6
JSR LVOCloseLibrary(A6)
theend BSR.W mt_end
BSR.W ResetCIAInt
RTS
;---- CIA Interrupt ----
AddICRVector = -6
RemICRVector = -12
LVOOpenResource = -498
LVOOpenLibrary = -552
LVOCloseLibrary = -414
LVODelay = -198
ciatalo = $400
ciatahi = $500
ciatblo = $600
ciatbhi = $700
ciacra = $E00
ciacrb = $F00
SetCIAInt
MOVEQ #2,D6
LEA $BFD000,A5
MOVE.B #'b',CIAAName+3
SetCIALoop
MOVEQ #0,D0
LEA CIAAName(PC),A1
MOVE.L 4.W,A6
JSR LVOOpenResource(A6)
MOVE.L D0,CIAAbase
BEQ.W mt_Return3
LEA GfxName(PC),A1
MOVEQ #0,D0
JSR LVOOpenLibrary(A6)
TST.L D0
BEQ ResetCIAInt
MOVE.L D0,A1
MOVE.W 206(A1),D0 ; DisplayFlags
BTST #2,D0 ; PAL?
BEQ.B WasNTSC
MOVE.L #1773447,D7 ; PAL
BRA.B sciask
WasNTSC MOVE.L #1789773,D7 ; NTSC
sciask MOVE.L D7,TimerValue
DIVU #125,D7 ; Default to normal 50 Hz timer
JSR LVOCloseLibrary(A6)
MOVE.L CIAAbase(PC),A6
CMP.W #2,D6
BEQ.B TryTimerA
TryTimerB
LEA MusicIntServer(PC),A1
MOVEQ #1,D0 ; Bit 1: Timer B
JSR AddICRVector(A6)
MOVE.L #1,TimerFlag
TST.L D0
BNE.B CIAError
MOVE.L A5,CIAAaddr
MOVE.B D7,ciatblo(A5)
LSR.W #8,D7
MOVE.B D7,ciatbhi(A5)
BSET #0,ciacrb(A5)
RTS
TryTimerA
LEA MusicIntServer(PC),A1
MOVEQ #0,D0 ; Bit 0: Timer A
JSR AddICRVector(A6)
CLR.L TimerFlag
TST.L D0
BNE.B CIAError
MOVE.L A5,CIAAaddr
MOVE.B D7,ciatalo(A5)
LSR.W #8,D7
MOVE.B D7,ciatahi(A5)
BSET #0,ciacra(A5)
RTS
CIAError
MOVE.B #'a',CIAAName+3
LEA $BFE001,A5
SUBQ.W #1,D6
BNE SetCIALoop
CLR.L CIAAbase
RTS
ResetCIAInt
MOVE.L CIAAbase(PC),D0
BEQ.W mt_Return3
CLR.L CIAAbase
MOVE.L D0,A6
MOVE.L CIAAaddr(PC),A5
TST.L TimerFlag
BEQ.B ResTimerA
BCLR #0,ciacrb(A5)
MOVEQ #1,D0
BRA.B RemInt
ResTimerA
BCLR #0,ciacra(A5)
MOVEQ #0,D0
RemInt LEA MusicIntServer(PC),A1
MOVEQ #0,d0
JSR RemICRVector(A6)
RTS
;---- Tempo ----
SetTempo
MOVE.L CIAAbase(PC),D2
BEQ.W mt_Return3
CMP.W #32,D0
BHS.B setemsk
MOVEQ #32,D0
setemsk MOVE.W D0,RealTempo
MOVE.L TimerValue(PC),D2
DIVU D0,D2
MOVE.L CIAAaddr(PC),A4
MOVE.L TimerFlag(PC),D0
BEQ.B SetTemA
MOVE.B D2,ciatblo(A4)
LSR.W #8,D2
MOVE.B D2,ciatbhi(A4)
RTS
SetTemA MOVE.B D2,ciatalo(A4)
LSR.W #8,D2
MOVE.B D2,ciatahi(A4)
RTS
CNOP 0,4
CIAAaddr dc.l 0
CIAAbase dc.l 0
TimerFlag dc.l 0
TimerValue dc.l 0
RealTempo dc.w 125 ; copy of current BPM set in SetTempo
LEDStatus dc.b 0
CNOP 0,4
MusicIntServer
dc.l 0,0
dc.b 2,5 ; type, priority
dc.l MusIntName
dc.l 0,mt_IntMusic
DOSName dc.b "dos.library",0
CIAAName dc.b "ciaa.resource",0
GfxName dc.b "graphics.library",0
MusIntName dc.b "ProTracker interrupt",0
EVEN
;---- Playroutine ----
n_note EQU 0 ; W (MUST be first!)
n_cmd EQU 2 ; W (MUST be second!)
n_cmdlo EQU 3 ; B (offset in n_cmd)
n_start EQU 4 ; L (aligned)
n_loopstart EQU 8 ; L
n_wavestart EQU 12 ; L
n_peroffset EQU 16 ; L (offset to finetuned period-LUT section)
n_length EQU 20 ; W (aligned)
n_replen EQU 22 ; W
n_period EQU 24 ; W
n_dmabit EQU 26 ; W
n_wantedperiod EQU 28 ; W
n_finetune EQU 30 ; B
n_volume EQU 31 ; B
n_toneportdirec EQU 32 ; B
n_toneportspeed EQU 33 ; B
n_vibratocmd EQU 34 ; B
n_vibratopos EQU 35 ; B
n_tremolocmd EQU 36 ; B
n_tremolopos EQU 37 ; B
n_wavecontrol EQU 38 ; B
n_glissfunk EQU 39 ; B
n_sampleoffset EQU 40 ; B
n_pattpos EQU 41 ; B
n_loopcount EQU 42 ; B
n_funkoffset EQU 43 ; B
mt_init
MOVEM.L D0-A6,-(SP)
LEA mt_data,A0
MOVE.L A0,mt_SongDataPtr
MOVE.B 950(A0),mt_SongLength
LEA 12(A0),A1
MOVE.L A1,mt_SampleStructPtr
; count number of patterns (find highest referred pattern)
LEA 952(A0),A1 ; order list address
MOVEQ #128-1,D0 ; 128 order list entries
MOVEQ #0,D1
mtloop MOVE.L D1,D2
SUBQ.W #1,D0
mtloop2 MOVE.B (A1)+,D1
CMP.B D2,D1
BGT.B mtloop
DBRA D0,mtloop2
ADDQ.B #1,D2
; generate mt_SampleStarts list and fix samples
LSL.L #8,D2
LSL.L #2,D2 ; D2 *= 1024
ADD.L #1084,D2
ADD.L A0,D2
MOVE.L D2,A2 ; A2 is now the address of first sample's data
LEA mt_SampleStarts(PC),A1
MOVEQ #31-1,D3
mtloop3 MOVEQ #0,D0
MOVE.W 42(A0),D0 ; get sample length
BEQ.B mtskip2 ; sample is empty, don't handle
MOVEQ #0,D1
MOVE.W 46(A0),D1 ; get repeat
MOVEQ #0,D2
MOVE.W 48(A0),D2 ; get replen
BNE.B mtskip
MOVEQ #1,D2
MOVE.W D2,48(A0) ; replen is zero, set to 1 (fixes lock-up)
mtskip ADD.L D2,D1
CMP.L #1,D1 ; loop enabled? (repeat+replen > 1)
BHI.B mtskip2 ; yes
CLR.W (A2) ; no, clear first word of sample (prevents beep)
mtskip2 MOVE.L A2,(A1)+ ; move sample address into mt_SampleStarts slot
ADD.L D0,D0 ; turn into real sample length
ADD.L D0,A2 ; add to address
LEA 30(A0),A0 ; skip to next sample list entry
DBRA D3,mtloop3
; initialize stuff
MOVE.B $BFE001,D0 ; copy of LED filter state
AND.B #2,D0
MOVE.B D0,LEDStatus
BSET #1,$BFE001 ; turn off LED filter
; --------------------
MOVE.B #6,mt_Speed
CLR.B mt_Counter
CLR.B mt_SongPos
CLR.W mt_PatternPos
CLR.B mt_PattDelayTime
CLR.B mt_PattDelayTime2
BSR.W mt_RestoreEffects
MOVEQ #125,D0
BSR.W SetTempo
SF mt_Enable
BSR.B mt_TurnOffVoices
MOVEM.L (SP)+,D0-A6
RTS
mt_end
SF mt_Enable
BCLR #1,$BFE001 ; restore previous LED filter state
MOVE.L D0,-(SP)
MOVE.B LEDStatus(PC),D0
OR.B D0,$BFE001
MOVE.L (SP)+,D0
mt_TurnOffVoices
MOVE.W #$F,$DFF096 ; turn off voice DMAs
CLR.W $DFF0A8 ; clear voice volumes
CLR.W $DFF0B8
CLR.W $DFF0C8
CLR.W $DFF0D8
RTS
mt_RestoreEffects
LEA mt_audchan1temp(PC),A0
BSR.B reefsub
LEA mt_audchan2temp(PC),A0
BSR.B reefsub
LEA mt_audchan3temp(PC),A0
BSR.B reefsub
LEA mt_audchan4temp(PC),A0
reefsub CLR.B n_wavecontrol(A0)
CLR.B n_glissfunk(A0)
CLR.B n_finetune(A0)
CLR.B n_loopcount(A0)
RTS
mt_IntMusic
MOVEM.L D0-A6,-(SP)
TST.B mt_Enable
BEQ.W mt_exit
ADDQ.B #1,mt_Counter
MOVE.B mt_Counter(PC),D0
CMP.B mt_Speed(PC),D0
BLO.B mt_NoNewNote
CLR.B mt_Counter
TST.B mt_PattDelayTime2
BEQ.B mt_GetNewNote
BSR.B mt_NoNewAllChannels
BRA.W mt_dskip
mt_NoNewNote
BSR.B mt_NoNewAllChannels
BRA.W mt_NoNewPositionYet
mt_NoNewAllChannels
LEA mt_audchan1temp(PC),A6
LEA $DFF0A0,A5
BSR.W mt_CheckEffects
LEA mt_audchan2temp(PC),A6
LEA $DFF0B0,A5
BSR.W mt_CheckEffects
LEA mt_audchan3temp(PC),A6
LEA $DFF0C0,A5
BSR.W mt_CheckEffects
LEA mt_audchan4temp(PC),A6
LEA $DFF0D0,A5
BRA.W mt_CheckEffects
mt_GetNewNote
; Setup pattern pointer
MOVE.L mt_SongDataPtr(PC),A0
LEA 952(A0),A1 ;pattpo
LEA 1084(A0),A0 ;patterndata
MOVEQ #0,D0
MOVE.B mt_SongPos(PC),D0
MOVEQ #0,D1
MOVE.B (A1,D0.W),D1
LSL.L #8,D1
LSL.L #2,D1
MOVEQ #0,D0
MOVE.W mt_PatternPos(PC),D0
ADD.L D0,D1
ADD.L D1,A0
MOVE.L A0,mt_PatternPtr
CLR.W mt_DMACONtemp
LEA $DFF0A0,A5
LEA mt_audchan1temp(PC),A6
BSR.B mt_PlayVoice
MOVEQ #0,D0
MOVE.B n_volume(A6),D0
MOVE.W D0,8(A5)
LEA $DFF0B0,A5
LEA mt_audchan2temp(PC),A6
BSR.B mt_PlayVoice
MOVEQ #0,D0
MOVE.B n_volume(A6),D0
MOVE.W D0,8(A5)
LEA $DFF0C0,A5
LEA mt_audchan3temp(PC),A6
BSR.B mt_PlayVoice
MOVEQ #0,D0
MOVE.B n_volume(A6),D0
MOVE.W D0,8(A5)
LEA $DFF0D0,A5
LEA mt_audchan4temp(PC),A6
BSR.B mt_PlayVoice
MOVEQ #0,D0
MOVE.B n_volume(A6),D0
MOVE.W D0,8(A5)
BRA.W mt_SetDMA
mt_PlayVoice
TST.L (A6)
BNE.B mt_plvskip
BSR.W mt_PerNop
mt_plvskip
MOVE.L mt_PatternPtr(PC),A0
MOVE.L (A0)+,(A6) ; Read note from pattern
MOVE.L A0,mt_PatternPtr
MOVEQ #0,D2
MOVE.B n_cmd(A6),D2 ; Get lower 4 bits of instrument
AND.B #$F0,D2
LSR.B #4,D2
MOVE.B (A6),D0 ; Get higher 4 bits of instrument
AND.B #$F0,D0
OR.B D0,D2
BEQ.W mt_SetRegisters ; Instrument was zero
LEA mt_SampleStarts(PC),A1
MOVE.L mt_SampleStructPtr(PC),A3
MOVE D2,D4
SUBQ.L #1,D2
LSL.L #2,D2
MULU.W #30,D4
MOVE.L (A1,D2.L),n_start(A6)
MOVE.W (A3,D4.L),n_length(A6)
MOVEQ #0,D0
MOVE.B 2(A3,D4.L),D0
AND.B #$0F,D0
MOVE.B D0,n_finetune(A6)
; ----------------------------------
LSL.B #2,D0 ; update n_peroffset
LEA mt_ftunePerTab(PC),A4
MOVE.L (A4,D0.W),n_peroffset(A6)
; ----------------------------------
MOVEQ #0,D3
MOVE.B 3(A3,D4.L),n_volume(A6)
MOVE.W 4(A3,D4.L),D3 ; Get repeat
BEQ.B mt_NoLoop
MOVE.L n_start(A6),D2 ; Get start
ADD.L D3,D3
ADD.L D3,D2 ; Add repeat
MOVE.L D2,n_loopstart(A6)
MOVE.L D2,n_wavestart(A6)
MOVE.W 4(A3,D4.L),D0 ; Get repeat
ADD.W 6(A3,D4.L),D0 ; Add replen
MOVE.W D0,n_length(A6)
MOVE.W 6(A3,D4.L),n_replen(A6) ; Save replen
BRA.B mt_SetRegisters
mt_NoLoop
MOVE.L n_start(A6),D2
ADD.L D3,D2
MOVE.L D2,n_loopstart(A6)
MOVE.L D2,n_wavestart(A6)
MOVE.W 6(A3,D4.L),n_replen(A6) ; Save replen
mt_SetRegisters
MOVE.W (A6),D0
AND.W #$0FFF,D0
BEQ.W mt_CheckMoreEffects ; If no note
MOVE.W 2(A6),D0
AND.W #$FF0,D0
CMP.W #$E50,D0 ; finetune
BEQ.B mt_DoSetFineTune
MOVE.B 2(A6),D0
AND.B #$0F,D0
CMP.B #3,D0 ; TonePortamento
BEQ.B mt_ChkTonePorta
CMP.B #5,D0 ; TonePortamento + VolSlide
BEQ.B mt_ChkTonePorta
CMP.B #9,D0 ; Sample Offset
BNE.B mt_SetPeriod
BSR.W mt_CheckMoreEffects
BRA.B mt_SetPeriod
mt_DoSetFineTune
BSR.W mt_SetFineTune
BRA.B mt_SetPeriod
mt_ChkTonePorta
BSR.W mt_SetTonePorta
BRA.W mt_CheckMoreEffects
mt_SetPeriod
MOVE.W (A6),D1
AND.W #$0FFF,D1
LEA mt_PeriodTable(PC),A1
MOVEQ #0,D0
MOVEQ #37-1,D7
mt_ftuloop
CMP.W (A1,D0.W),D1
BHS.B mt_ftufound
ADDQ.W #2,D0
DBRA D7,mt_ftuloop
mt_ftufound
MOVE.L n_peroffset(A6),A1
MOVE.W (A1,D0.W),n_period(A6)
MOVE.W 2(A6),D0
AND.W #$0FF0,D0
CMP.W #$0ED0,D0 ; Notedelay
BEQ.W mt_CheckMoreEffects
MOVE.W n_dmabit(A6),$DFF096
BTST #2,n_wavecontrol(A6)
BNE.B mt_vibnoc
CLR.B n_vibratopos(A6)
mt_vibnoc
BTST #6,n_wavecontrol(A6)
BNE.B mt_trenoc
CLR.B n_tremolopos(A6)
mt_trenoc
MOVE.W n_length(A6),4(A5) ; Set length
MOVE.L n_start(A6),(A5) ; Set start
BNE.B mt_sdmaskp
CLR.L n_loopstart(A6)
MOVEQ #1,D0
MOVE.W D0,4(A5)
MOVE.W D0,n_replen(A6)
mt_sdmaskp
MOVE.W n_period(A6),D0
MOVE.W D0,6(A5) ; Set period
MOVE.W n_dmabit(A6),D0
OR.W D0,mt_DMACONtemp
BRA.W mt_CheckMoreEffects
mt_SetDMA
; scanline-wait (wait before starting Paula DMA)
LEA $DFF006,A0
MOVEQ #7-1,D1
lineloop1
MOVE.B (A0),D0
waiteol1
CMP.B (A0),D0
BEQ.B waiteol1
DBRA D1,lineloop1
MOVE.W mt_DMACONtemp(PC),D0
OR.W #$8000,D0 ; Set bits
MOVE.W D0,$DFF096
; scanline-wait (wait for Paula DMA to latch)
MOVEQ #7-1,D1
lineloop2
MOVE.B (A0),D0
waiteol2
CMP.B (A0),D0
BEQ.B waiteol2
DBRA D1,lineloop2
LEA $DFF000,A5
LEA mt_audchan4temp(PC),A6
MOVE.L n_loopstart(A6),$D0(A5)
MOVE.W n_replen(A6),$D4(A5)
LEA mt_audchan3temp(PC),A6
MOVE.L n_loopstart(A6),$C0(A5)
MOVE.W n_replen(A6),$C4(A5)
LEA mt_audchan2temp(PC),A6
MOVE.L n_loopstart(A6),$B0(A5)
MOVE.W n_replen(A6),$B4(A5)
LEA mt_audchan1temp(PC),A6
MOVE.L n_loopstart(A6),$A0(A5)
MOVE.W n_replen(A6),$A4(A5)
mt_dskip
ADD.W #16,mt_PatternPos
MOVE.B mt_PattDelayTime(PC),D0
BEQ.B mt_dskpc
MOVE.B D0,mt_PattDelayTime2
CLR.B mt_PattDelayTime
mt_dskpc
TST.B mt_PattDelayTime2
BEQ.B mt_dskpa
SUBQ.B #1,mt_PattDelayTime2
BEQ.B mt_dskpa
SUB.W #16,mt_PatternPos
mt_dskpa
TST.B mt_PBreakFlag
BEQ.B mt_nnpysk
SF mt_PBreakFlag
MOVEQ #0,D0
MOVE.B mt_PBreakPos(PC),D0
LSL.W #4,D0
MOVE.W D0,mt_PatternPos
CLR.B mt_PBreakPos
mt_nnpysk
CMP.W #1024,mt_PatternPos
BLO.B mt_NoNewPositionYet
mt_NextPosition
MOVEQ #0,D0
MOVE.B mt_PBreakPos(PC),D0
LSL.W #4,D0
MOVE.W D0,mt_PatternPos
CLR.B mt_PBreakPos
CLR.B mt_PosJumpFlag
ADDQ.B #1,mt_SongPos
AND.B #127,mt_SongPos
MOVE.B mt_SongPos(PC),D1
CMP.B mt_SongLength(PC),D1
BLO.B mt_NoNewPositionYet
CLR.B mt_SongPos
mt_NoNewPositionYet
TST.B mt_PosJumpFlag
BNE.B mt_NextPosition
mt_exit MOVEM.L (SP)+,D0-A6
RTS
mt_CheckEffects
BSR.B mt_chkefx2
MOVEQ #0,D0
MOVE.B n_volume(A6),D0
MOVE.W D0,8(A5)
RTS
CNOP 0,4
mt_JumpList1
dc.l mt_Arpeggio ; 0xy (Arpeggio)
dc.l mt_PortaUp ; 1xx (Portamento Up)
dc.l mt_PortaDown ; 2xx (Portamento Down)
dc.l mt_TonePortamento ; 3xx (Tone Portamento)
dc.l mt_Vibrato ; 4xy (Vibrato)
dc.l mt_TonePlusVolSlide ; 5xy (Tone Portamento + Volume Slide)
dc.l mt_VibratoPlusVolSlide ; 6xy (Vibrato + Volume Slide)
dc.l SetBack ; 7 - not used here
dc.l SetBack ; 8 - unused!
dc.l SetBack ; 9 - not used here
dc.l SetBack ; A - not used here
dc.l SetBack ; B - not used here
dc.l SetBack ; C - not used here
dc.l SetBack ; D - not used here
dc.l mt_E_Commands ; Exy (Extended Commands)
dc.l SetBack ; F - not used here
mt_chkefx2
BSR.W mt_UpdateFunk
MOVE.W n_cmd(A6),D0
AND.W #$0FFF,D0
BEQ.B mt_Return3
MOVEQ #0,D0
MOVE.B n_cmd(A6),D0
AND.B #$0F,D0
MOVE.W D0,D1
LSL.B #2,D1
MOVE.L mt_JumpList1(PC,D1.W),A4
JMP (A4) ; every efx has RTS at the end, this is safe
SetBack MOVE.W n_period(A6),6(A5)
CMP.B #7,D0
BEQ.W mt_Tremolo
CMP.B #$A,D0
BEQ.W mt_VolumeSlide
mt_Return3
RTS
mt_PerNop
MOVE.W n_period(A6),6(A5)
RTS
; DIV -> LUT optimization. DIVU is 140+ cycles on a 68000.
mt_ArpTab
dc.b 0,1,2,0,1,2,0,1
dc.b 2,0,1,2,0,1,2,0
dc.b 1,2,0,1,2,0,1,2
dc.b 0,1,2,0,1,2,0,1
mt_Arpeggio
MOVEQ #0,D0
MOVE.B mt_Counter(PC),D0
AND.B #$1F,D0 ; just in case
MOVE.B mt_ArpTab(PC,D0.W),D0
CMP.B #1,D0
BEQ.B mt_Arpeggio1
CMP.B #2,D0
BEQ.B mt_Arpeggio2
mt_Arpeggio0
MOVE.W n_period(A6),6(A5)
RTS
mt_Arpeggio1
MOVEQ #0,D0
MOVE.B n_cmdlo(A6),D0
LSR.B #4,D0
BRA.B mt_ArpeggioFind
mt_Arpeggio2
MOVEQ #0,D0
MOVE.B n_cmdlo(A6),D0
AND.B #15,D0
mt_ArpeggioFind
ADD.W D0,D0
MOVE.L n_peroffset(A6),A0
MOVEQ #0,D1
MOVE.W n_period(A6),D1
MOVEQ #37-1,D3
mt_arploop
CMP.W (A0)+,D1
BHS.B mt_ArpeggioFound
DBRA D3,mt_arploop
RTS
mt_ArpeggioFound
MOVE.W -2(A0,D0.W),6(A5)
RTS
mt_FinePortaUp
TST.B mt_Counter
BNE.W mt_Return3
MOVE.B #$0F,mt_LowMask
mt_PortaUp
MOVEQ #0,D0
MOVE.B n_cmdlo(A6),D0
AND.B mt_LowMask(PC),D0
MOVE.B #$FF,mt_LowMask
SUB.W D0,n_period(A6)
MOVE.W n_period(A6),D0
AND.W #$0FFF,D0
CMP.W #113,D0
BPL.B mt_PortaUskip
AND.W #$F000,n_period(A6)
OR.W #113,n_period(A6)
mt_PortaUskip
MOVE.W n_period(A6),D0
AND.W #$0FFF,D0
MOVE.W D0,6(A5)
RTS
mt_FinePortaDown
TST.B mt_Counter
BNE.W mt_Return3
MOVE.B #$0F,mt_LowMask
mt_PortaDown
CLR.W D0
MOVE.B n_cmdlo(A6),D0
AND.B mt_LowMask(PC),D0
MOVE.B #$FF,mt_LowMask
ADD.W D0,n_period(A6)
MOVE.W n_period(A6),D0
AND.W #$0FFF,D0
CMP.W #856,D0
BMI.B mt_PortaDskip
AND.W #$F000,n_period(A6)
OR.W #856,n_period(A6)
mt_PortaDskip
MOVE.W n_period(A6),D0
AND.W #$0FFF,D0
MOVE.W D0,6(A5)
RTS
mt_SetTonePorta
MOVE.W (A6),D2
AND.W #$0FFF,D2
MOVE.L n_peroffset(A6),A4
MOVEQ #0,D0
mt_StpLoop
CMP.W (A4,D0.W),D2
BHS.B mt_StpFound
ADDQ.W #2,D0
CMP.W #37*2,D0
BLO.B mt_StpLoop
MOVEQ #35*2,D0
mt_StpFound
MOVE.B n_finetune(A6),D2
AND.B #8,D2
BEQ.B mt_StpGoss
TST.W D0
BEQ.B mt_StpGoss
SUBQ.W #2,D0
mt_StpGoss
MOVE.W (A4,D0.W),D2
MOVE.W D2,n_wantedperiod(A6)
MOVE.W n_period(A6),D0
CLR.B n_toneportdirec(A6)
CMP.W D0,D2
BEQ.B mt_ClearTonePorta
BGE.W mt_Return3
MOVE.B #1,n_toneportdirec(A6)
RTS
mt_ClearTonePorta
CLR.W n_wantedperiod(A6)
RTS
mt_TonePortamento
MOVE.B n_cmdlo(A6),D0
BEQ.B mt_TonePortNoChange
MOVE.B D0,n_toneportspeed(A6)
CLR.B n_cmdlo(A6)
mt_TonePortNoChange
TST.W n_wantedperiod(A6)
BEQ.W mt_Return3
MOVEQ #0,D0
MOVE.B n_toneportspeed(A6),D0
TST.B n_toneportdirec(A6)
BNE.B mt_TonePortaUp
mt_TonePortaDown
ADD.W D0,n_period(A6)
MOVE.W n_wantedperiod(A6),D0
CMP.W n_period(A6),D0
BGT.B mt_TonePortaSetPer
MOVE.W n_wantedperiod(A6),n_period(A6)
CLR.W n_wantedperiod(A6)
BRA.B mt_TonePortaSetPer
mt_TonePortaUp
SUB.W D0,n_period(A6)
MOVE.W n_wantedperiod(A6),D0
CMP.W n_period(A6),D0
BLT.B mt_TonePortaSetPer
MOVE.W n_wantedperiod(A6),n_period(A6)
CLR.W n_wantedperiod(A6)
mt_TonePortaSetPer
MOVE.W n_period(A6),D2
MOVE.B n_glissfunk(A6),D0
AND.B #$0F,D0
BEQ.B mt_GlissSkip
MOVE.L n_peroffset(A6),A0
MOVEQ #0,D0
mt_GlissLoop
CMP.W (A0,D0.W),D2
BHS.B mt_GlissFound
ADDQ.W #2,D0
CMP.W #37*2,D0
BLO.B mt_GlissLoop
MOVEQ #35*2,D0
mt_GlissFound
MOVE.W (A0,D0.W),D2
mt_GlissSkip
MOVE.W D2,6(A5) ; Set period
RTS
mt_Vibrato
MOVE.B n_cmdlo(A6),D0
BEQ.B mt_Vibrato2
MOVE.B n_vibratocmd(A6),D2
AND.B #$0F,D0
BEQ.B mt_vibskip
AND.B #$F0,D2
OR.B D0,D2
mt_vibskip
MOVE.B n_cmdlo(A6),D0
AND.B #$F0,D0
BEQ.B mt_vibskip2
AND.B #$0F,D2
OR.B D0,D2
mt_vibskip2
MOVE.B D2,n_vibratocmd(A6)
mt_Vibrato2
MOVE.B n_vibratopos(A6),D0
LEA mt_VibratoTable(PC),A4
LSR.W #2,D0
AND.W #$001F,D0
MOVEQ #0,D2
MOVE.B n_wavecontrol(A6),D2
AND.B #3,D2
BEQ.B mt_vib_sine
LSL.B #3,D0
CMP.B #1,D2
BEQ.B mt_vib_rampdown
MOVE.B #255,D2
BRA.B mt_vib_set
mt_vib_rampdown
TST.B n_vibratopos(A6)
BPL.B mt_vib_rampdown2
MOVE.B #255,D2
SUB.B D0,D2
BRA.B mt_vib_set
mt_vib_rampdown2
MOVE.B D0,D2
BRA.B mt_vib_set
mt_vib_sine
MOVE.B (A4,D0.W),D2
mt_vib_set
MOVE.B n_vibratocmd(A6),D0
AND.W #15,D0
MULU.W D0,D2
LSR.W #7,D2
MOVE.W n_period(A6),D0
TST.B n_vibratopos(A6)
BMI.B mt_VibratoNeg
ADD.W D2,D0
BRA.B mt_Vibrato3
mt_VibratoNeg
SUB.W D2,D0
mt_Vibrato3
MOVE.W D0,6(A5)
MOVE.B n_vibratocmd(A6),D0
LSR.W #2,D0
AND.W #$003C,D0
ADD.B D0,n_vibratopos(A6)
RTS
mt_TonePlusVolSlide
BSR.W mt_TonePortNoChange
BRA.W mt_VolumeSlide
mt_VibratoPlusVolSlide
BSR.B mt_Vibrato2
BRA.W mt_VolumeSlide
mt_Tremolo
MOVE.B n_cmdlo(A6),D0
BEQ.B mt_Tremolo2
MOVE.B n_tremolocmd(A6),D2
AND.B #$0F,D0
BEQ.B mt_treskip
AND.B #$F0,D2
OR.B D0,D2
mt_treskip
MOVE.B n_cmdlo(A6),D0
AND.B #$F0,D0
BEQ.B mt_treskip2
AND.B #$0F,D2
OR.B D0,D2
mt_treskip2
MOVE.B D2,n_tremolocmd(A6)
mt_Tremolo2
MOVE.B n_tremolopos(A6),D0
LEA mt_VibratoTable(PC),A4
LSR.W #2,D0
AND.W #$001F,D0
MOVEQ #0,D2
MOVE.B n_wavecontrol(A6),D2
LSR.B #4,D2
AND.B #3,D2
BEQ.B mt_tre_sine
LSL.B #3,D0
CMP.B #1,D2
BEQ.B mt_tre_rampdown
MOVE.B #255,D2
BRA.B mt_tre_set
mt_tre_rampdown
TST.B n_vibratopos(A6)
BPL.B mt_tre_rampdown2
MOVE.B #255,D2
SUB.B D0,D2
BRA.B mt_tre_set
mt_tre_rampdown2
MOVE.B D0,D2
BRA.B mt_tre_set
mt_tre_sine
MOVE.B (A4,D0.W),D2
mt_tre_set
MOVE.B n_tremolocmd(A6),D0
AND.W #15,D0
MULU.W D0,D2
LSR.W #6,D2
MOVEQ #0,D0
MOVE.B n_volume(A6),D0
TST.B n_tremolopos(A6)
BMI.B mt_TremoloNeg
ADD.W D2,D0
BRA.B mt_Tremolo3
mt_TremoloNeg
SUB.W D2,D0
mt_Tremolo3
BPL.B mt_TremoloSkip
CLR.W D0
mt_TremoloSkip
CMP.W #64,D0
BLS.B mt_TremoloOk
MOVE.W #64,D0
mt_TremoloOk
MOVE.W D0,8(A5)
MOVE.B n_tremolocmd(A6),D0
LSR.W #2,D0
AND.W #$003C,D0
ADD.B D0,n_tremolopos(A6)
ADDQ.L #4,SP ; hack to not set volume in mt_CheckEffects
RTS
mt_SampleOffset
MOVEQ #0,D0
MOVE.B n_cmdlo(A6),D0
BEQ.B mt_sononew
MOVE.B D0,n_sampleoffset(A6)
mt_sononew
MOVE.B n_sampleoffset(A6),D0
LSL.W #7,D0
CMP.W n_length(A6),D0
BHS.B mt_sofskip
SUB.W D0,n_length(A6)
ADD.W D0,D0
ADD.L D0,n_start(A6)
RTS
mt_sofskip
MOVE.W #1,n_length(A6)
RTS
mt_VolumeSlide
MOVEQ #0,D0
MOVE.B n_cmdlo(A6),D0
LSR.B #4,D0
BEQ.B mt_VolSlideDown
mt_VolSlideUp
ADD.B D0,n_volume(A6)
CMP.B #64,n_volume(A6)
BMI.B mt_vsuskip
MOVE.B #64,n_volume(A6)
mt_vsuskip
RTS
mt_VolSlideDown
MOVEQ #0,D0
MOVE.B n_cmdlo(A6),D0
AND.B #$0F,D0
mt_VolSlideDown2
SUB.B D0,n_volume(A6)
BPL.B mt_vsdskip
CLR.B n_volume(A6)
mt_vsdskip
RTS
mt_PositionJump
MOVE.B n_cmdlo(A6),D0
SUBQ.B #1,D0
MOVE.B D0,mt_SongPos
mt_pj2 CLR.B mt_PBreakPos
ST mt_PosJumpFlag
RTS
mt_VolumeChange
MOVEQ #0,D0
MOVE.B n_cmdlo(A6),D0
CMP.B #64,D0
BLS.B mt_VolumeOk
MOVEQ #64,D0
mt_VolumeOk
MOVE.B D0,n_volume(A6)
RTS
mt_PatternBreak
MOVEQ #0,D0
MOVE.B n_cmdlo(A6),D0
MOVE.L D0,D2
LSR.B #4,D0
MULU.W #10,D0
AND.B #$0F,D2
ADD.B D2,D0
CMP.B #63,D0
BHI.B mt_pj2
MOVE.B D0,mt_PBreakPos
ST mt_PosJumpFlag
RTS
mt_SetSpeed
MOVEQ #0,D0
MOVE.B 3(A6),D0
BEQ.W mt_end
CMP.B #32,D0
BHS.W SetTempo
CLR.B mt_Counter
MOVE.B D0,mt_Speed
RTS
CNOP 0,4
mt_JumpList2
dc.l mt_PerNop ; 0 - not used
dc.l mt_PerNop ; 1 - not used
dc.l mt_PerNop ; 2 - not used
dc.l mt_PerNop ; 3 - not used
dc.l mt_PerNop ; 4 - not used
dc.l mt_PerNop ; 5 - not used
dc.l mt_PerNop ; 6 - not used
dc.l mt_PerNop ; 7 - not used
dc.l mt_PerNop ; 8 - not used
dc.l mt_SampleOffset ; 9xx (Set Sample Offset)
dc.l mt_PerNop ; A - not used
dc.l mt_PositionJump ; Bxx (Position Jump)
dc.l mt_VolumeChange ; Cxx (Set Volume)
dc.l mt_PatternBreak ; Dxx (Pattern Break)
dc.l mt_E_Commands ; Exy (Extended Commands)
dc.l mt_SetSpeed ; Fxx (Set Speed)
mt_CheckMoreEffects
MOVEQ #0,D0
MOVE.B 2(A6),D0
AND.B #$0F,D0
LSL.B #2,D0
MOVE.L mt_JumpList2(PC,D0.W),A4
JMP (A4) ; every efx has RTS at the end, this is safe
CNOP 0,4
mt_E_JumpList
dc.l mt_FilterOnOff ; E0x (Set LED Filter)
dc.l mt_FinePortaUp ; E1x (Fine Portamento Up)
dc.l mt_FinePortaDown ; E2x (Fine Portamento Down)
dc.l mt_SetGlissControl ; E3x (Glissando/Funk Control)
dc.l mt_SetVibratoControl ; E4x (Vibrato Control)
dc.l mt_SetFineTune ; E5x (Set Finetune)
dc.l mt_JumpLoop ; E6x (Pattern Loop)
dc.l mt_SetTremoloControl ; E7x (Tremolo Control)
dc.l mt_KarplusStrong ; E8x (Karplus-Strong)
dc.l mt_RetrigNote ; E9x (Retrig Note)
dc.l mt_VolumeFineUp ; EAx (Fine Volume-Slide Up)
dc.l mt_VolumeFineDown ; EBx (Fine Volume-Slide Down)
dc.l mt_NoteCut ; ECx (Note Cut)
dc.l mt_NoteDelay ; EDx (Note Delay)
dc.l mt_PatternDelay ; EEx (Pattern Delay)
dc.l mt_FunkIt ; EFx (Invert Loop)
mt_E_Commands
MOVEQ #0,D0
MOVE.B n_cmdlo(A6),D0
AND.B #$F0,D0
LSR.B #4-2,D0
MOVE.L mt_E_JumpList(PC,D0.W),A4
JMP (A4) ; every E-efx has RTS at the end, this is safe
mt_FilterOnOff
TST.B mt_Counter
BNE.W mt_Return3
MOVE.B n_cmdlo(A6),D0
AND.B #1,D0
ADD.B D0,D0
AND.B #$FD,$BFE001
OR.B D0,$BFE001
RTS
mt_SetGlissControl
MOVE.B n_cmdlo(A6),D0
AND.B #$0F,D0
AND.B #$F0,n_glissfunk(A6)
OR.B D0,n_glissfunk(A6)
RTS
mt_SetVibratoControl
MOVE.B n_cmdlo(A6),D0
AND.B #$0F,D0
AND.B #$F0,n_wavecontrol(A6)
OR.B D0,n_wavecontrol(A6)
RTS
mt_SetFineTune
MOVEQ #0,D0
MOVE.B n_cmdlo(A6),D0
AND.B #$0F,D0
MOVE.B D0,n_finetune(A6)
; ----------------------------------
LSL.B #2,D0 ; update n_peroffset
LEA mt_ftunePerTab(PC),A4
MOVE.L (A4,D0.W),n_peroffset(A6)
; ----------------------------------
RTS
mt_JumpLoop
TST.B mt_Counter
BNE.W mt_Return3
MOVE.B n_cmdlo(A6),D0
AND.B #$0F,D0
BEQ.B mt_SetLoop
TST.B n_loopcount(A6)
BEQ.B mt_jumpcnt
SUBQ.B #1,n_loopcount(A6)
BEQ.W mt_Return3
mt_jmploop
MOVE.B n_pattpos(A6),mt_PBreakPos
ST mt_PBreakFlag
RTS
mt_jumpcnt
MOVE.B D0,n_loopcount(A6)
BRA.B mt_jmploop
mt_SetLoop
MOVE.W mt_PatternPos(PC),D0
LSR.W #4,D0
AND.B #63,D0
MOVE.B D0,n_pattpos(A6)
RTS
mt_SetTremoloControl
MOVE.B n_cmdlo(A6),D0
AND.B #$0F,D0
LSL.B #4,D0
AND.B #$0F,n_wavecontrol(A6)
OR.B D0,n_wavecontrol(A6)
RTS
mt_KarplusStrong
RTS
mt_RetrigNote
MOVEQ #0,D0
MOVE.B n_cmdlo(A6),D0
AND.B #$0F,D0
BEQ.B mt_rtnend
MOVEQ #0,D1
MOVE.B mt_Counter(PC),D1
BNE.B mt_rtnskp
MOVE.W n_note(A6),D2
AND.W #$0FFF,D2
BNE.B mt_rtnend
mt_rtnskp
DIVU.W D0,D1
SWAP D1
TST.W D1
BNE.B mt_rtnend
mt_DoRetrig
MOVE.W n_dmabit(A6),$DFF096 ; Channel DMA off
MOVE.L n_start(A6),(A5) ; Set sampledata pointer
MOVE.W n_length(A6),4(A5) ; Set length
MOVE.W n_period(A6),6(A5) ; Set period
; scanline-wait (wait before starting Paula DMA)
LEA $DFF006,A0
MOVEQ #7-1,D1
lineloop3
MOVE.B (A0),D0
waiteol3
CMP.B (A0),D0
BEQ.B waiteol3
DBRA D1,lineloop3
MOVE.W n_dmabit(A6),D0
BSET #15,D0 ; Set bits
MOVE.W D0,$DFF096
; scanline-wait (wait for Paula DMA to latch)
MOVEQ #7-1,D1
lineloop4
MOVE.B (A0),D0
waiteol4
CMP.B (A0),D0
BEQ.B waiteol4
DBRA D1,lineloop4
MOVE.L n_loopstart(A6),(A5)
MOVE.W n_replen(A6),4(A5)
mt_rtnend
RTS
mt_VolumeFineUp
TST.B mt_Counter
BNE.W mt_Return3
MOVEQ #0,D0
MOVE.B n_cmdlo(A6),D0
AND.B #$F,D0
BRA.W mt_VolSlideUp
mt_VolumeFineDown
TST.B mt_Counter
BNE.W mt_Return3
MOVEQ #0,D0
MOVE.B n_cmdlo(A6),D0
AND.B #$0F,D0
BRA.W mt_VolSlideDown2
mt_NoteCut
MOVEQ #0,D0
MOVE.B n_cmdlo(A6),D0
AND.B #$0F,D0
CMP.B mt_Counter(PC),D0
BNE.W mt_Return3
CLR.B n_volume(A6)
RTS
mt_NoteDelay
MOVEQ #0,D0
MOVE.B n_cmdlo(A6),D0
AND.B #$0F,D0
CMP.B mt_Counter,D0
BNE.W mt_Return3
MOVE.W (A6),D0
AND.W #$0FFF,D0
BEQ.W mt_Return3
BRA.W mt_DoRetrig
mt_PatternDelay
TST.B mt_Counter
BNE.W mt_Return3
MOVEQ #0,D0
MOVE.B n_cmdlo(A6),D0
AND.B #$0F,D0
TST.B mt_PattDelayTime2
BNE.W mt_Return3
ADDQ.B #1,D0
MOVE.B D0,mt_PattDelayTime
RTS
mt_FunkIt
TST.B mt_Counter
BNE.W mt_Return3
MOVE.B n_cmdlo(A6),D0
AND.B #$0F,D0
LSL.B #4,D0
AND.B #$0F,n_glissfunk(A6)
OR.B D0,n_glissfunk(A6)
TST.B D0
BEQ.W mt_Return3
mt_UpdateFunk
MOVEQ #0,D0
MOVE.B n_glissfunk(A6),D0
LSR.B #4,D0
BEQ.B mt_funkend
LEA mt_FunkTable(PC),A0
MOVE.B (A0,D0.W),D0
ADD.B D0,n_funkoffset(A6)
BTST #7,n_funkoffset(A6)
BEQ.B mt_funkend
CLR.B n_funkoffset(A6)
MOVE.L n_wavestart(A6),A0
CMP.L #0,A0
BEQ.B mt_funkend
MOVE.L n_loopstart(A6),D0
MOVEQ #0,D1
MOVE.W n_replen(A6),D1
ADD.L D1,D0
ADD.L D1,D0
ADDQ.L #1,A0
CMP.L D0,A0
BLO.B mt_funkok
MOVE.L n_loopstart(A6),A0
mt_funkok
MOVE.L A0,n_wavestart(A6)
MOVEQ #-1,D0
SUB.B (A0),D0
MOVE.B D0,(A0)
mt_funkend
RTS
mt_FunkTable
dc.b 0,5,6,7,8,10,11,13,16,19,22,26,32,43,64,128
mt_VibratoTable
dc.b 0, 24, 49, 74, 97,120,141,161
dc.b 180,197,212,224,235,244,250,253
dc.b 255,253,250,244,235,224,212,197
dc.b 180,161,141,120, 97, 74, 49, 24
; this LUT prevents MULU for getting correct period section
CNOP 0,4
mt_ftunePerTab
dc.l mt_ftune0,mt_ftune1,mt_ftune2,mt_ftune3
dc.l mt_ftune4,mt_ftune5,mt_ftune6,mt_ftune7
dc.l mt_ftune8,mt_ftune9,mt_ftuneA,mt_ftuneB
dc.l mt_ftuneC,mt_ftuneD,mt_ftuneE,mt_ftuneF
mt_PeriodTable
; Tuning 0, Normal
mt_ftune0
dc.w 856,808,762,720,678,640,604,570,538,508,480,453
dc.w 428,404,381,360,339,320,302,285,269,254,240,226
dc.w 214,202,190,180,170,160,151,143,135,127,120,113,0
; Tuning 1
mt_ftune1
dc.w 850,802,757,715,674,637,601,567,535,505,477,450
dc.w 425,401,379,357,337,318,300,284,268,253,239,225
dc.w 213,201,189,179,169,159,150,142,134,126,119,113,0
; Tuning 2
mt_ftune2
dc.w 844,796,752,709,670,632,597,563,532,502,474,447
dc.w 422,398,376,355,335,316,298,282,266,251,237,224
dc.w 211,199,188,177,167,158,149,141,133,125,118,112,0
; Tuning 3
mt_ftune3
dc.w 838,791,746,704,665,628,592,559,528,498,470,444
dc.w 419,395,373,352,332,314,296,280,264,249,235,222
dc.w 209,198,187,176,166,157,148,140,132,125,118,111,0
; Tuning 4
mt_ftune4
dc.w 832,785,741,699,660,623,588,555,524,495,467,441
dc.w 416,392,370,350,330,312,294,278,262,247,233,220
dc.w 208,196,185,175,165,156,147,139,131,124,117,110,0
; Tuning 5
mt_ftune5
dc.w 826,779,736,694,655,619,584,551,520,491,463,437
dc.w 413,390,368,347,328,309,292,276,260,245,232,219
dc.w 206,195,184,174,164,155,146,138,130,123,116,109,0
; Tuning 6
mt_ftune6
dc.w 820,774,730,689,651,614,580,547,516,487,460,434
dc.w 410,387,365,345,325,307,290,274,258,244,230,217
dc.w 205,193,183,172,163,154,145,137,129,122,115,109,0
; Tuning 7
mt_ftune7
dc.w 814,768,725,684,646,610,575,543,513,484,457,431
dc.w 407,384,363,342,323,305,288,272,256,242,228,216
dc.w 204,192,181,171,161,152,144,136,128,121,114,108,0
; Tuning -8
mt_ftune8
dc.w 907,856,808,762,720,678,640,604,570,538,508,480
dc.w 453,428,404,381,360,339,320,302,285,269,254,240
dc.w 226,214,202,190,180,170,160,151,143,135,127,120,0
; Tuning -7
mt_ftune9
dc.w 900,850,802,757,715,675,636,601,567,535,505,477
dc.w 450,425,401,379,357,337,318,300,284,268,253,238
dc.w 225,212,200,189,179,169,159,150,142,134,126,119,0
; Tuning -6
mt_ftuneA
dc.w 894,844,796,752,709,670,632,597,563,532,502,474
dc.w 447,422,398,376,355,335,316,298,282,266,251,237
dc.w 223,211,199,188,177,167,158,149,141,133,125,118,0
; Tuning -5
mt_ftuneB
dc.w 887,838,791,746,704,665,628,592,559,528,498,470
dc.w 444,419,395,373,352,332,314,296,280,264,249,235
dc.w 222,209,198,187,176,166,157,148,140,132,125,118,0
; Tuning -4
mt_ftuneC
dc.w 881,832,785,741,699,660,623,588,555,524,494,467
dc.w 441,416,392,370,350,330,312,294,278,262,247,233
dc.w 220,208,196,185,175,165,156,147,139,131,123,117,0
; Tuning -3
mt_ftuneD
dc.w 875,826,779,736,694,655,619,584,551,520,491,463
dc.w 437,413,390,368,347,328,309,292,276,260,245,232
dc.w 219,206,195,184,174,164,155,146,138,130,123,116,0
; Tuning -2
mt_ftuneE
dc.w 868,820,774,730,689,651,614,580,547,516,487,460
dc.w 434,410,387,365,345,325,307,290,274,258,244,230
dc.w 217,205,193,183,172,163,154,145,137,129,122,115,0
; Tuning -1
mt_ftuneF
dc.w 862,814,768,725,684,646,610,575,543,513,484,457
dc.w 431,407,384,363,342,323,305,288,272,256,242,228
dc.w 216,203,192,181,171,161,152,144,136,128,121,114,0
; ------------------------------------------------------
; Overflow bytes from CursorPosTable and UnshiftedKeymap
; LUTs so that overflown arpeggio at finetune -1 sounds
; right even if this table was to be moved.
; ------------------------------------------------------
dc.w 774,1800,2314,3087,4113,4627,5400,6426,6940,7713
dc.w 8739,9253,24625,12851,13365
CNOP 0,4
mt_audchan1temp dcb.b 26
dc.w $0001 ; voice #1 DMA bit
dcb.b 16
CNOP 0,4
mt_audchan2temp dcb.b 26
dc.w $0002 ; voice #2 DMA bit
dcb.b 16
CNOP 0,4
mt_audchan3temp dcb.b 26
dc.w $0004 ; voice #3 DMA bit
dcb.b 16
CNOP 0,4
mt_audchan4temp dcb.b 26
dc.w $0008 ; voice #4 DMA bit
dcb.b 16
CNOP 0,4
mt_SampleStarts dcb.l 31,0
mt_SongDataPtr dc.l 0
mt_SampleStructPtr dc.l 0
mt_PatternPtr dc.l 0
mt_PatternPos dc.w 0
mt_DMACONtemp dc.w 0
mt_SongLength dc.b 0
mt_Speed dc.b 6
mt_Counter dc.b 0
mt_SongPos dc.b 0
mt_PBreakPos dc.b 0
mt_PosJumpFlag dc.b 0
mt_PBreakFlag dc.b 0
mt_LowMask dc.b $FF
mt_PattDelayTime dc.b 0
mt_PattDelayTime2 dc.b 0
mt_Enable dc.b 0
SECTION music,DATA_C
CNOP 0,4
mt_data INCBIN "music.mod"
;/* End of File */
|
8bitbubsy/pt23f
| 28,617
|
replayer/PT2.3F_replay_vblank.s
|
;*******************************************************
;* ---- ProTracker V2.3F Replay Routine (VBlank) ---- *
;*******************************************************
;
; This is the vblank version of the PT2.3F replayer. If you don't know
; the difference between CIA and vblank, you probably want to use the
; CIA version instead.
;
; This replayer has been slightly optimized over the PT2.3D replayer,
; but it's still far from fully optimized. It has also been rewritten to
; behave like PT2.3F's internal replayer, for maximum accuracy.
;
; Changelog:
; - 13.03.2025: Initial version
; - 21.05.2025: Set Sample Offset (9xx) now works on >64kB samples
; - 23.06.2025: Removed 512-byte optimization LUT for E9x (Retrig Note)
; Now comes some simple test code. It expects to call mt_music()
; ~50 times a second. It might be a better idea to set up a vblank
; interrupt and call mt_music in there, but this is about as simple
; as it gets.
;
; NOTE:
; The test code may play at the wrong tempo, especially in some
; emulator configs!
;
main
BSR.W mt_init ; setup module
mloop ; ---------------------------
vloop MOVE.L $DFF004,D0 ; wait for vblank
AND.L #$1FF00,D0
CMP.L #303<<8,D0
BNE.B vloop
; ---------------------------
BTST #6,$BFE001 ; test for mouse button
BEQ.B exit
; ---------------------------
BSR.W mt_music
; ---------------------------
BRA.B mloop
exit BSR.W mt_end
RTS
LEDStatus dc.b 0
EVEN
;---- Playroutine ----
n_note EQU 0 ; W (MUST be first!)
n_cmd EQU 2 ; W (MUST be second!)
n_cmdlo EQU 3 ; B (offset in n_cmd)
n_start EQU 4 ; L (aligned)
n_loopstart EQU 8 ; L
n_wavestart EQU 12 ; L
n_peroffset EQU 16 ; L (offset to finetuned period-LUT section)
n_length EQU 20 ; W (aligned)
n_replen EQU 22 ; W
n_period EQU 24 ; W
n_dmabit EQU 26 ; W
n_wantedperiod EQU 28 ; W
n_finetune EQU 30 ; B
n_volume EQU 31 ; B
n_toneportdirec EQU 32 ; B
n_toneportspeed EQU 33 ; B
n_vibratocmd EQU 34 ; B
n_vibratopos EQU 35 ; B
n_tremolocmd EQU 36 ; B
n_tremolopos EQU 37 ; B
n_wavecontrol EQU 38 ; B
n_glissfunk EQU 39 ; B
n_sampleoffset EQU 40 ; B
n_pattpos EQU 41 ; B
n_loopcount EQU 42 ; B
n_funkoffset EQU 43 ; B
mt_init
MOVEM.L D0-A6,-(SP)
LEA mt_data,A0
MOVE.L A0,mt_SongDataPtr
MOVE.B 950(A0),mt_SongLength
LEA 12(A0),A1
MOVE.L A1,mt_SampleStructPtr
; count number of patterns (find highest referred pattern)
LEA 952(A0),A1 ; order list address
MOVEQ #128-1,D0 ; 128 order list entries
MOVEQ #0,D1
mtloop MOVE.L D1,D2
SUBQ.W #1,D0
mtloop2 MOVE.B (A1)+,D1
CMP.B D2,D1
BGT.B mtloop
DBRA D0,mtloop2
ADDQ.B #1,D2
; generate mt_SampleStarts list and fix samples
LSL.L #8,D2
LSL.L #2,D2 ; D2 *= 1024
ADD.L #1084,D2
ADD.L A0,D2
MOVE.L D2,A2 ; A2 is now the address of first sample's data
LEA mt_SampleStarts(PC),A1
MOVEQ #31-1,D3
mtloop3 MOVEQ #0,D0
MOVE.W 42(A0),D0 ; get sample length
BEQ.B mtskip2 ; sample is empty, don't handle
MOVEQ #0,D1
MOVE.W 46(A0),D1 ; get repeat
MOVEQ #0,D2
MOVE.W 48(A0),D2 ; get replen
BNE.B mtskip
MOVEQ #1,D2
MOVE.W D2,48(A0) ; replen is zero, set to 1 (fixes lock-up)
mtskip ADD.L D2,D1
CMP.L #1,D1 ; loop enabled? (repeat+replen > 1)
BHI.B mtskip2 ; yes
CLR.W (A2) ; no, clear first word of sample (prevents beep)
mtskip2 MOVE.L A2,(A1)+ ; move sample address into mt_SampleStarts slot
ADD.L D0,D0 ; turn into real sample length
ADD.L D0,A2 ; add to address
LEA 30(A0),A0 ; skip to next sample list entry
DBRA D3,mtloop3
; initialize stuff
MOVE.B $BFE001,D0 ; copy of LED filter state
AND.B #2,D0
MOVE.B D0,LEDStatus
BSET #1,$BFE001 ; turn off LED filter
; --------------------
MOVE.B #6,mt_Speed
CLR.B mt_Counter
CLR.B mt_SongPos
CLR.W mt_PatternPos
CLR.B mt_PattDelayTime
CLR.B mt_PattDelayTime2
BSR.W mt_RestoreEffects
BSR.B mt_TurnOffVoices
MOVEM.L (SP)+,D0-A6
RTS
mt_end
BCLR #1,$BFE001 ; restore previous LED filter state
MOVE.L D0,-(SP)
MOVE.B LEDStatus(PC),D0
OR.B D0,$BFE001
MOVE.L (SP)+,D0
mt_TurnOffVoices
MOVE.W #$F,$DFF096 ; turn off voice DMAs
CLR.W $DFF0A8 ; clear voice volumes
CLR.W $DFF0B8
CLR.W $DFF0C8
CLR.W $DFF0D8
RTS
mt_RestoreEffects
LEA mt_audchan1temp(PC),A0
BSR.B reefsub
LEA mt_audchan2temp(PC),A0
BSR.B reefsub
LEA mt_audchan3temp(PC),A0
BSR.B reefsub
LEA mt_audchan4temp(PC),A0
reefsub CLR.B n_wavecontrol(A0)
CLR.B n_glissfunk(A0)
CLR.B n_finetune(A0)
CLR.B n_loopcount(A0)
RTS
mt_music
MOVEM.L D0-A6,-(SP)
ADDQ.B #1,mt_Counter
MOVE.B mt_Counter(PC),D0
CMP.B mt_Speed(PC),D0
BLO.B mt_NoNewNote
CLR.B mt_Counter
TST.B mt_PattDelayTime2
BEQ.B mt_GetNewNote
BSR.B mt_NoNewAllChannels
BRA.W mt_dskip
mt_NoNewNote
BSR.B mt_NoNewAllChannels
BRA.W mt_NoNewPositionYet
mt_NoNewAllChannels
LEA mt_audchan1temp(PC),A6
LEA $DFF0A0,A5
BSR.W mt_CheckEffects
LEA mt_audchan2temp(PC),A6
LEA $DFF0B0,A5
BSR.W mt_CheckEffects
LEA mt_audchan3temp(PC),A6
LEA $DFF0C0,A5
BSR.W mt_CheckEffects
LEA mt_audchan4temp(PC),A6
LEA $DFF0D0,A5
BRA.W mt_CheckEffects
mt_GetNewNote
; Setup pattern pointer
MOVE.L mt_SongDataPtr(PC),A0
LEA 952(A0),A1 ;pattpo
LEA 1084(A0),A0 ;patterndata
MOVEQ #0,D0
MOVE.B mt_SongPos(PC),D0
MOVEQ #0,D1
MOVE.B (A1,D0.W),D1
LSL.L #8,D1
LSL.L #2,D1
MOVEQ #0,D0
MOVE.W mt_PatternPos(PC),D0
ADD.L D0,D1
ADD.L D1,A0
MOVE.L A0,mt_PatternPtr
CLR.W mt_DMACONtemp
LEA $DFF0A0,A5
LEA mt_audchan1temp(PC),A6
BSR.B mt_PlayVoice
MOVEQ #0,D0
MOVE.B n_volume(A6),D0
MOVE.W D0,8(A5)
LEA $DFF0B0,A5
LEA mt_audchan2temp(PC),A6
BSR.B mt_PlayVoice
MOVEQ #0,D0
MOVE.B n_volume(A6),D0
MOVE.W D0,8(A5)
LEA $DFF0C0,A5
LEA mt_audchan3temp(PC),A6
BSR.B mt_PlayVoice
MOVEQ #0,D0
MOVE.B n_volume(A6),D0
MOVE.W D0,8(A5)
LEA $DFF0D0,A5
LEA mt_audchan4temp(PC),A6
BSR.B mt_PlayVoice
MOVEQ #0,D0
MOVE.B n_volume(A6),D0
MOVE.W D0,8(A5)
BRA.W mt_SetDMA
mt_PlayVoice
TST.L (A6)
BNE.B mt_plvskip
BSR.W mt_PerNop
mt_plvskip
MOVE.L mt_PatternPtr(PC),A0
MOVE.L (A0)+,(A6) ; Read note from pattern
MOVE.L A0,mt_PatternPtr
MOVEQ #0,D2
MOVE.B n_cmd(A6),D2 ; Get lower 4 bits of instrument
AND.B #$F0,D2
LSR.B #4,D2
MOVE.B (A6),D0 ; Get higher 4 bits of instrument
AND.B #$F0,D0
OR.B D0,D2
BEQ.W mt_SetRegisters ; Instrument was zero
LEA mt_SampleStarts(PC),A1
MOVE.L mt_SampleStructPtr(PC),A3
MOVE D2,D4
SUBQ.L #1,D2
LSL.L #2,D2
MULU.W #30,D4
MOVE.L (A1,D2.L),n_start(A6)
MOVE.W (A3,D4.L),n_length(A6)
MOVEQ #0,D0
MOVE.B 2(A3,D4.L),D0
AND.B #$0F,D0
MOVE.B D0,n_finetune(A6)
; ----------------------------------
LSL.B #2,D0 ; update n_peroffset
LEA mt_ftunePerTab(PC),A4
MOVE.L (A4,D0.W),n_peroffset(A6)
; ----------------------------------
MOVEQ #0,D3
MOVE.B 3(A3,D4.L),n_volume(A6)
MOVE.W 4(A3,D4.L),D3 ; Get repeat
BEQ.B mt_NoLoop
MOVE.L n_start(A6),D2 ; Get start
ADD.L D3,D3
ADD.L D3,D2 ; Add repeat
MOVE.L D2,n_loopstart(A6)
MOVE.L D2,n_wavestart(A6)
MOVE.W 4(A3,D4.L),D0 ; Get repeat
ADD.W 6(A3,D4.L),D0 ; Add replen
MOVE.W D0,n_length(A6)
MOVE.W 6(A3,D4.L),n_replen(A6) ; Save replen
BRA.B mt_SetRegisters
mt_NoLoop
MOVE.L n_start(A6),D2
ADD.L D3,D2
MOVE.L D2,n_loopstart(A6)
MOVE.L D2,n_wavestart(A6)
MOVE.W 6(A3,D4.L),n_replen(A6) ; Save replen
mt_SetRegisters
MOVE.W (A6),D0
AND.W #$0FFF,D0
BEQ.W mt_CheckMoreEffects ; If no note
MOVE.W 2(A6),D0
AND.W #$FF0,D0
CMP.W #$E50,D0 ; finetune
BEQ.B mt_DoSetFineTune
MOVE.B 2(A6),D0
AND.B #$0F,D0
CMP.B #3,D0 ; TonePortamento
BEQ.B mt_ChkTonePorta
CMP.B #5,D0 ; TonePortamento + VolSlide
BEQ.B mt_ChkTonePorta
CMP.B #9,D0 ; Sample Offset
BNE.B mt_SetPeriod
BSR.W mt_CheckMoreEffects
BRA.B mt_SetPeriod
mt_DoSetFineTune
BSR.W mt_SetFineTune
BRA.B mt_SetPeriod
mt_ChkTonePorta
BSR.W mt_SetTonePorta
BRA.W mt_CheckMoreEffects
mt_SetPeriod
MOVE.W (A6),D1
AND.W #$0FFF,D1
LEA mt_PeriodTable(PC),A1
MOVEQ #0,D0
MOVEQ #37-1,D7
mt_ftuloop
CMP.W (A1,D0.W),D1
BHS.B mt_ftufound
ADDQ.W #2,D0
DBRA D7,mt_ftuloop
mt_ftufound
MOVE.L n_peroffset(A6),A1
MOVE.W (A1,D0.W),n_period(A6)
MOVE.W 2(A6),D0
AND.W #$0FF0,D0
CMP.W #$0ED0,D0 ; Notedelay
BEQ.W mt_CheckMoreEffects
MOVE.W n_dmabit(A6),$DFF096
BTST #2,n_wavecontrol(A6)
BNE.B mt_vibnoc
CLR.B n_vibratopos(A6)
mt_vibnoc
BTST #6,n_wavecontrol(A6)
BNE.B mt_trenoc
CLR.B n_tremolopos(A6)
mt_trenoc
MOVE.W n_length(A6),4(A5) ; Set length
MOVE.L n_start(A6),(A5) ; Set start
BNE.B mt_sdmaskp
CLR.L n_loopstart(A6)
MOVEQ #1,D0
MOVE.W D0,4(A5)
MOVE.W D0,n_replen(A6)
mt_sdmaskp
MOVE.W n_period(A6),D0
MOVE.W D0,6(A5) ; Set period
MOVE.W n_dmabit(A6),D0
OR.W D0,mt_DMACONtemp
BRA.W mt_CheckMoreEffects
mt_SetDMA
; scanline-wait (wait before starting Paula DMA)
LEA $DFF006,A0
MOVEQ #7-1,D1
lineloop1
MOVE.B (A0),D0
waiteol1
CMP.B (A0),D0
BEQ.B waiteol1
DBRA D1,lineloop1
MOVE.W mt_DMACONtemp(PC),D0
OR.W #$8000,D0 ; Set bits
MOVE.W D0,$DFF096
; scanline-wait (wait for Paula DMA to latch)
MOVEQ #7-1,D1
lineloop2
MOVE.B (A0),D0
waiteol2
CMP.B (A0),D0
BEQ.B waiteol2
DBRA D1,lineloop2
LEA $DFF000,A5
LEA mt_audchan4temp(PC),A6
MOVE.L n_loopstart(A6),$D0(A5)
MOVE.W n_replen(A6),$D4(A5)
LEA mt_audchan3temp(PC),A6
MOVE.L n_loopstart(A6),$C0(A5)
MOVE.W n_replen(A6),$C4(A5)
LEA mt_audchan2temp(PC),A6
MOVE.L n_loopstart(A6),$B0(A5)
MOVE.W n_replen(A6),$B4(A5)
LEA mt_audchan1temp(PC),A6
MOVE.L n_loopstart(A6),$A0(A5)
MOVE.W n_replen(A6),$A4(A5)
mt_dskip
ADD.W #16,mt_PatternPos
MOVE.B mt_PattDelayTime(PC),D0
BEQ.B mt_dskpc
MOVE.B D0,mt_PattDelayTime2
CLR.B mt_PattDelayTime
mt_dskpc
TST.B mt_PattDelayTime2
BEQ.B mt_dskpa
SUBQ.B #1,mt_PattDelayTime2
BEQ.B mt_dskpa
SUB.W #16,mt_PatternPos
mt_dskpa
TST.B mt_PBreakFlag
BEQ.B mt_nnpysk
SF mt_PBreakFlag
MOVEQ #0,D0
MOVE.B mt_PBreakPos(PC),D0
LSL.W #4,D0
MOVE.W D0,mt_PatternPos
CLR.B mt_PBreakPos
mt_nnpysk
CMP.W #1024,mt_PatternPos
BLO.B mt_NoNewPositionYet
mt_NextPosition
MOVEQ #0,D0
MOVE.B mt_PBreakPos(PC),D0
LSL.W #4,D0
MOVE.W D0,mt_PatternPos
CLR.B mt_PBreakPos
CLR.B mt_PosJumpFlag
ADDQ.B #1,mt_SongPos
AND.B #127,mt_SongPos
MOVE.B mt_SongPos(PC),D1
CMP.B mt_SongLength(PC),D1
BLO.B mt_NoNewPositionYet
CLR.B mt_SongPos
mt_NoNewPositionYet
TST.B mt_PosJumpFlag
BNE.B mt_NextPosition
mt_exit MOVEM.L (SP)+,D0-A6
RTS
mt_CheckEffects
BSR.B mt_chkefx2
MOVEQ #0,D0
MOVE.B n_volume(A6),D0
MOVE.W D0,8(A5)
RTS
CNOP 0,4
mt_JumpList1
dc.l mt_Arpeggio ; 0xy (Arpeggio)
dc.l mt_PortaUp ; 1xx (Portamento Up)
dc.l mt_PortaDown ; 2xx (Portamento Down)
dc.l mt_TonePortamento ; 3xx (Tone Portamento)
dc.l mt_Vibrato ; 4xy (Vibrato)
dc.l mt_TonePlusVolSlide ; 5xy (Tone Portamento + Volume Slide)
dc.l mt_VibratoPlusVolSlide ; 6xy (Vibrato + Volume Slide)
dc.l SetBack ; 7 - not used here
dc.l SetBack ; 8 - unused!
dc.l SetBack ; 9 - not used here
dc.l SetBack ; A - not used here
dc.l SetBack ; B - not used here
dc.l SetBack ; C - not used here
dc.l SetBack ; D - not used here
dc.l mt_E_Commands ; Exy (Extended Commands)
dc.l SetBack ; F - not used here
mt_chkefx2
BSR.W mt_UpdateFunk
MOVE.W n_cmd(A6),D0
AND.W #$0FFF,D0
BEQ.B mt_Return3
MOVEQ #0,D0
MOVE.B n_cmd(A6),D0
AND.B #$0F,D0
MOVE.W D0,D1
LSL.B #2,D1
MOVE.L mt_JumpList1(PC,D1.W),A4
JMP (A4) ; every efx has RTS at the end, this is safe
SetBack MOVE.W n_period(A6),6(A5)
CMP.B #7,D0
BEQ.W mt_Tremolo
CMP.B #$A,D0
BEQ.W mt_VolumeSlide
mt_Return3
RTS
mt_PerNop
MOVE.W n_period(A6),6(A5)
RTS
mt_Arpeggio
MOVEQ #0,D0
MOVE.B mt_Counter(PC),D0
MOVE.B mt_ArpTab(PC,D0.W),D0
CMP.B #1,D0
BEQ.B mt_Arpeggio1
CMP.B #2,D0
BEQ.B mt_Arpeggio2
mt_Arpeggio0
MOVE.W n_period(A6),6(A5)
RTS
mt_Arpeggio1
MOVEQ #0,D0
MOVE.B n_cmdlo(A6),D0
LSR.B #4,D0
BRA.B mt_ArpeggioFind
mt_Arpeggio2
MOVEQ #0,D0
MOVE.B n_cmdlo(A6),D0
AND.B #15,D0
mt_ArpeggioFind
ADD.W D0,D0
MOVE.L n_peroffset(A6),A0
MOVEQ #0,D1
MOVE.W n_period(A6),D1
MOVEQ #37-1,D3
mt_arploop
CMP.W (A0)+,D1
BHS.B mt_ArpeggioFound
DBRA D3,mt_arploop
RTS
mt_ArpeggioFound
MOVE.W -2(A0,D0.W),6(A5)
RTS
; DIV -> LUT optimization. DIVU is 140+ cycles on a 68000.
mt_ArpTab
dc.b 0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1
dc.b 2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0
dc.b 1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2
dc.b 0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1
dc.b 2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0
dc.b 1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2
dc.b 0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1
dc.b 2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0
mt_FinePortaUp
TST.B mt_Counter
BNE.W mt_Return3
MOVE.B #$0F,mt_LowMask
mt_PortaUp
MOVEQ #0,D0
MOVE.B n_cmdlo(A6),D0
AND.B mt_LowMask(PC),D0
MOVE.B #$FF,mt_LowMask
SUB.W D0,n_period(A6)
MOVE.W n_period(A6),D0
AND.W #$0FFF,D0
CMP.W #113,D0
BPL.B mt_PortaUskip
AND.W #$F000,n_period(A6)
OR.W #113,n_period(A6)
mt_PortaUskip
MOVE.W n_period(A6),D0
AND.W #$0FFF,D0
MOVE.W D0,6(A5)
RTS
mt_FinePortaDown
TST.B mt_Counter
BNE.W mt_Return3
MOVE.B #$0F,mt_LowMask
mt_PortaDown
CLR.W D0
MOVE.B n_cmdlo(A6),D0
AND.B mt_LowMask(PC),D0
MOVE.B #$FF,mt_LowMask
ADD.W D0,n_period(A6)
MOVE.W n_period(A6),D0
AND.W #$0FFF,D0
CMP.W #856,D0
BMI.B mt_PortaDskip
AND.W #$F000,n_period(A6)
OR.W #856,n_period(A6)
mt_PortaDskip
MOVE.W n_period(A6),D0
AND.W #$0FFF,D0
MOVE.W D0,6(A5)
RTS
mt_SetTonePorta
MOVE.W (A6),D2
AND.W #$0FFF,D2
MOVE.L n_peroffset(A6),A4
MOVEQ #0,D0
mt_StpLoop
CMP.W (A4,D0.W),D2
BHS.B mt_StpFound
ADDQ.W #2,D0
CMP.W #37*2,D0
BLO.B mt_StpLoop
MOVEQ #35*2,D0
mt_StpFound
MOVE.B n_finetune(A6),D2
AND.B #8,D2
BEQ.B mt_StpGoss
TST.W D0
BEQ.B mt_StpGoss
SUBQ.W #2,D0
mt_StpGoss
MOVE.W (A4,D0.W),D2
MOVE.W D2,n_wantedperiod(A6)
MOVE.W n_period(A6),D0
CLR.B n_toneportdirec(A6)
CMP.W D0,D2
BEQ.B mt_ClearTonePorta
BGE.W mt_Return3
MOVE.B #1,n_toneportdirec(A6)
RTS
mt_ClearTonePorta
CLR.W n_wantedperiod(A6)
RTS
mt_TonePortamento
MOVE.B n_cmdlo(A6),D0
BEQ.B mt_TonePortNoChange
MOVE.B D0,n_toneportspeed(A6)
CLR.B n_cmdlo(A6)
mt_TonePortNoChange
TST.W n_wantedperiod(A6)
BEQ.W mt_Return3
MOVEQ #0,D0
MOVE.B n_toneportspeed(A6),D0
TST.B n_toneportdirec(A6)
BNE.B mt_TonePortaUp
mt_TonePortaDown
ADD.W D0,n_period(A6)
MOVE.W n_wantedperiod(A6),D0
CMP.W n_period(A6),D0
BGT.B mt_TonePortaSetPer
MOVE.W n_wantedperiod(A6),n_period(A6)
CLR.W n_wantedperiod(A6)
BRA.B mt_TonePortaSetPer
mt_TonePortaUp
SUB.W D0,n_period(A6)
MOVE.W n_wantedperiod(A6),D0
CMP.W n_period(A6),D0
BLT.B mt_TonePortaSetPer
MOVE.W n_wantedperiod(A6),n_period(A6)
CLR.W n_wantedperiod(A6)
mt_TonePortaSetPer
MOVE.W n_period(A6),D2
MOVE.B n_glissfunk(A6),D0
AND.B #$0F,D0
BEQ.B mt_GlissSkip
MOVE.L n_peroffset(A6),A0
MOVEQ #0,D0
mt_GlissLoop
CMP.W (A0,D0.W),D2
BHS.B mt_GlissFound
ADDQ.W #2,D0
CMP.W #37*2,D0
BLO.B mt_GlissLoop
MOVEQ #35*2,D0
mt_GlissFound
MOVE.W (A0,D0.W),D2
mt_GlissSkip
MOVE.W D2,6(A5) ; Set period
RTS
mt_Vibrato
MOVE.B n_cmdlo(A6),D0
BEQ.B mt_Vibrato2
MOVE.B n_vibratocmd(A6),D2
AND.B #$0F,D0
BEQ.B mt_vibskip
AND.B #$F0,D2
OR.B D0,D2
mt_vibskip
MOVE.B n_cmdlo(A6),D0
AND.B #$F0,D0
BEQ.B mt_vibskip2
AND.B #$0F,D2
OR.B D0,D2
mt_vibskip2
MOVE.B D2,n_vibratocmd(A6)
mt_Vibrato2
MOVE.B n_vibratopos(A6),D0
LEA mt_VibratoTable(PC),A4
LSR.W #2,D0
AND.W #$001F,D0
MOVEQ #0,D2
MOVE.B n_wavecontrol(A6),D2
AND.B #3,D2
BEQ.B mt_vib_sine
LSL.B #3,D0
CMP.B #1,D2
BEQ.B mt_vib_rampdown
MOVE.B #255,D2
BRA.B mt_vib_set
mt_vib_rampdown
TST.B n_vibratopos(A6)
BPL.B mt_vib_rampdown2
MOVE.B #255,D2
SUB.B D0,D2
BRA.B mt_vib_set
mt_vib_rampdown2
MOVE.B D0,D2
BRA.B mt_vib_set
mt_vib_sine
MOVE.B (A4,D0.W),D2
mt_vib_set
MOVE.B n_vibratocmd(A6),D0
AND.W #15,D0
MULU.W D0,D2
LSR.W #7,D2
MOVE.W n_period(A6),D0
TST.B n_vibratopos(A6)
BMI.B mt_VibratoNeg
ADD.W D2,D0
BRA.B mt_Vibrato3
mt_VibratoNeg
SUB.W D2,D0
mt_Vibrato3
MOVE.W D0,6(A5)
MOVE.B n_vibratocmd(A6),D0
LSR.W #2,D0
AND.W #$003C,D0
ADD.B D0,n_vibratopos(A6)
RTS
mt_TonePlusVolSlide
BSR.W mt_TonePortNoChange
BRA.W mt_VolumeSlide
mt_VibratoPlusVolSlide
BSR.B mt_Vibrato2
BRA.W mt_VolumeSlide
mt_Tremolo
MOVE.B n_cmdlo(A6),D0
BEQ.B mt_Tremolo2
MOVE.B n_tremolocmd(A6),D2
AND.B #$0F,D0
BEQ.B mt_treskip
AND.B #$F0,D2
OR.B D0,D2
mt_treskip
MOVE.B n_cmdlo(A6),D0
AND.B #$F0,D0
BEQ.B mt_treskip2
AND.B #$0F,D2
OR.B D0,D2
mt_treskip2
MOVE.B D2,n_tremolocmd(A6)
mt_Tremolo2
MOVE.B n_tremolopos(A6),D0
LEA mt_VibratoTable(PC),A4
LSR.W #2,D0
AND.W #$001F,D0
MOVEQ #0,D2
MOVE.B n_wavecontrol(A6),D2
LSR.B #4,D2
AND.B #3,D2
BEQ.B mt_tre_sine
LSL.B #3,D0
CMP.B #1,D2
BEQ.B mt_tre_rampdown
MOVE.B #255,D2
BRA.B mt_tre_set
mt_tre_rampdown
TST.B n_vibratopos(A6)
BPL.B mt_tre_rampdown2
MOVE.B #255,D2
SUB.B D0,D2
BRA.B mt_tre_set
mt_tre_rampdown2
MOVE.B D0,D2
BRA.B mt_tre_set
mt_tre_sine
MOVE.B (A4,D0.W),D2
mt_tre_set
MOVE.B n_tremolocmd(A6),D0
AND.W #15,D0
MULU.W D0,D2
LSR.W #6,D2
MOVEQ #0,D0
MOVE.B n_volume(A6),D0
TST.B n_tremolopos(A6)
BMI.B mt_TremoloNeg
ADD.W D2,D0
BRA.B mt_Tremolo3
mt_TremoloNeg
SUB.W D2,D0
mt_Tremolo3
BPL.B mt_TremoloSkip
CLR.W D0
mt_TremoloSkip
CMP.W #64,D0
BLS.B mt_TremoloOk
MOVE.W #64,D0
mt_TremoloOk
MOVE.W D0,8(A5)
MOVE.B n_tremolocmd(A6),D0
LSR.W #2,D0
AND.W #$003C,D0
ADD.B D0,n_tremolopos(A6)
ADDQ.L #4,SP ; hack to not set volume in mt_CheckEffects
RTS
mt_SampleOffset
MOVEQ #0,D0
MOVE.B n_cmdlo(A6),D0
BEQ.B mt_sononew
MOVE.B D0,n_sampleoffset(A6)
mt_sononew
MOVE.B n_sampleoffset(A6),D0
LSL.W #7,D0
CMP.W n_length(A6),D0
BHS.B mt_sofskip
SUB.W D0,n_length(A6)
ADD.W D0,D0
ADD.L D0,n_start(A6)
RTS
mt_sofskip
MOVE.W #1,n_length(A6)
RTS
mt_VolumeSlide
MOVEQ #0,D0
MOVE.B n_cmdlo(A6),D0
LSR.B #4,D0
BEQ.B mt_VolSlideDown
mt_VolSlideUp
ADD.B D0,n_volume(A6)
CMP.B #64,n_volume(A6)
BMI.B mt_vsuskip
MOVE.B #64,n_volume(A6)
mt_vsuskip
RTS
mt_VolSlideDown
MOVEQ #0,D0
MOVE.B n_cmdlo(A6),D0
AND.B #$0F,D0
mt_VolSlideDown2
SUB.B D0,n_volume(A6)
BPL.B mt_vsdskip
CLR.B n_volume(A6)
mt_vsdskip
RTS
mt_PositionJump
MOVE.B n_cmdlo(A6),D0
SUBQ.B #1,D0
MOVE.B D0,mt_SongPos
mt_pj2 CLR.B mt_PBreakPos
ST mt_PosJumpFlag
RTS
mt_VolumeChange
MOVEQ #0,D0
MOVE.B n_cmdlo(A6),D0
CMP.B #64,D0
BLS.B mt_VolumeOk
MOVEQ #64,D0
mt_VolumeOk
MOVE.B D0,n_volume(A6)
RTS
mt_PatternBreak
MOVEQ #0,D0
MOVE.B n_cmdlo(A6),D0
MOVE.L D0,D2
LSR.B #4,D0
MULU.W #10,D0
AND.B #$0F,D2
ADD.B D2,D0
CMP.B #63,D0
BHI.B mt_pj2
MOVE.B D0,mt_PBreakPos
ST mt_PosJumpFlag
RTS
mt_SetSpeed
MOVE.B 3(A6),D0
BEQ.W mt_end
CLR.B mt_Counter
MOVE.B D0,mt_Speed
RTS
CNOP 0,4
mt_JumpList2
dc.l mt_PerNop ; 0 - not used
dc.l mt_PerNop ; 1 - not used
dc.l mt_PerNop ; 2 - not used
dc.l mt_PerNop ; 3 - not used
dc.l mt_PerNop ; 4 - not used
dc.l mt_PerNop ; 5 - not used
dc.l mt_PerNop ; 6 - not used
dc.l mt_PerNop ; 7 - not used
dc.l mt_PerNop ; 8 - not used
dc.l mt_SampleOffset ; 9xx (Set Sample Offset)
dc.l mt_PerNop ; A - not used
dc.l mt_PositionJump ; Bxx (Position Jump)
dc.l mt_VolumeChange ; Cxx (Set Volume)
dc.l mt_PatternBreak ; Dxx (Pattern Break)
dc.l mt_E_Commands ; Exy (Extended Commands)
dc.l mt_SetSpeed ; Fxx (Set Speed)
mt_CheckMoreEffects
MOVEQ #0,D0
MOVE.B 2(A6),D0
AND.B #$0F,D0
LSL.B #2,D0
MOVE.L mt_JumpList2(PC,D0.W),A4
JMP (A4) ; every efx has RTS at the end, this is safe
CNOP 0,4
mt_E_JumpList
dc.l mt_FilterOnOff ; E0x (Set LED Filter)
dc.l mt_FinePortaUp ; E1x (Fine Portamento Up)
dc.l mt_FinePortaDown ; E2x (Fine Portamento Down)
dc.l mt_SetGlissControl ; E3x (Glissando/Funk Control)
dc.l mt_SetVibratoControl ; E4x (Vibrato Control)
dc.l mt_SetFineTune ; E5x (Set Finetune)
dc.l mt_JumpLoop ; E6x (Pattern Loop)
dc.l mt_SetTremoloControl ; E7x (Tremolo Control)
dc.l mt_KarplusStrong ; E8x (Karplus-Strong)
dc.l mt_RetrigNote ; E9x (Retrig Note)
dc.l mt_VolumeFineUp ; EAx (Fine Volume-Slide Up)
dc.l mt_VolumeFineDown ; EBx (Fine Volume-Slide Down)
dc.l mt_NoteCut ; ECx (Note Cut)
dc.l mt_NoteDelay ; EDx (Note Delay)
dc.l mt_PatternDelay ; EEx (Pattern Delay)
dc.l mt_FunkIt ; EFx (Invert Loop)
mt_E_Commands
MOVEQ #0,D0
MOVE.B n_cmdlo(A6),D0
AND.B #$F0,D0
LSR.B #4-2,D0
MOVE.L mt_E_JumpList(PC,D0.W),A4
JMP (A4) ; every E-efx has RTS at the end, this is safe
mt_FilterOnOff
TST.B mt_Counter
BNE.W mt_Return3
MOVE.B n_cmdlo(A6),D0
AND.B #1,D0
ADD.B D0,D0
AND.B #$FD,$BFE001
OR.B D0,$BFE001
RTS
mt_SetGlissControl
MOVE.B n_cmdlo(A6),D0
AND.B #$0F,D0
AND.B #$F0,n_glissfunk(A6)
OR.B D0,n_glissfunk(A6)
RTS
mt_SetVibratoControl
MOVE.B n_cmdlo(A6),D0
AND.B #$0F,D0
AND.B #$F0,n_wavecontrol(A6)
OR.B D0,n_wavecontrol(A6)
RTS
mt_SetFineTune
MOVEQ #0,D0
MOVE.B n_cmdlo(A6),D0
AND.B #$0F,D0
MOVE.B D0,n_finetune(A6)
; ----------------------------------
LSL.B #2,D0 ; update n_peroffset
LEA mt_ftunePerTab(PC),A4
MOVE.L (A4,D0.W),n_peroffset(A6)
; ----------------------------------
RTS
mt_JumpLoop
TST.B mt_Counter
BNE.W mt_Return3
MOVE.B n_cmdlo(A6),D0
AND.B #$0F,D0
BEQ.B mt_SetLoop
TST.B n_loopcount(A6)
BEQ.B mt_jumpcnt
SUBQ.B #1,n_loopcount(A6)
BEQ.W mt_Return3
mt_jmploop
MOVE.B n_pattpos(A6),mt_PBreakPos
ST mt_PBreakFlag
RTS
mt_jumpcnt
MOVE.B D0,n_loopcount(A6)
BRA.B mt_jmploop
mt_SetLoop
MOVE.W mt_PatternPos(PC),D0
LSR.W #4,D0
AND.B #63,D0
MOVE.B D0,n_pattpos(A6)
RTS
mt_SetTremoloControl
MOVE.B n_cmdlo(A6),D0
AND.B #$0F,D0
LSL.B #4,D0
AND.B #$0F,n_wavecontrol(A6)
OR.B D0,n_wavecontrol(A6)
RTS
mt_KarplusStrong
RTS
mt_RetrigNote
MOVEQ #0,D0
MOVE.B n_cmdlo(A6),D0
AND.B #$0F,D0
BEQ.B mt_rtnend
MOVEQ #0,D1
MOVE.B mt_Counter(PC),D1
BNE.B mt_rtnskp
MOVE.W n_note(A6),D2
AND.W #$0FFF,D2
BNE.B mt_rtnend
mt_rtnskp
DIVU.W D0,D1
SWAP D1
TST.W D1
BNE.B mt_rtnend
mt_DoRetrig
MOVE.W n_dmabit(A6),$DFF096 ; Channel DMA off
MOVE.L n_start(A6),(A5) ; Set sampledata pointer
MOVE.W n_length(A6),4(A5) ; Set length
MOVE.W n_period(A6),6(A5) ; Set period
; scanline-wait (wait before starting Paula DMA)
LEA $DFF006,A0
MOVEQ #7-1,D1
lineloop3
MOVE.B (A0),D0
waiteol3
CMP.B (A0),D0
BEQ.B waiteol3
DBRA D1,lineloop3
MOVE.W n_dmabit(A6),D0
BSET #15,D0 ; Set bits
MOVE.W D0,$DFF096
; scanline-wait (wait for Paula DMA to latch)
MOVEQ #7-1,D1
lineloop4
MOVE.B (A0),D0
waiteol4
CMP.B (A0),D0
BEQ.B waiteol4
DBRA D1,lineloop4
MOVE.L n_loopstart(A6),(A5)
MOVE.W n_replen(A6),4(A5)
mt_rtnend
RTS
mt_VolumeFineUp
TST.B mt_Counter
BNE.W mt_Return3
MOVEQ #0,D0
MOVE.B n_cmdlo(A6),D0
AND.B #$F,D0
BRA.W mt_VolSlideUp
mt_VolumeFineDown
TST.B mt_Counter
BNE.W mt_Return3
MOVEQ #0,D0
MOVE.B n_cmdlo(A6),D0
AND.B #$0F,D0
BRA.W mt_VolSlideDown2
mt_NoteCut
MOVEQ #0,D0
MOVE.B n_cmdlo(A6),D0
AND.B #$0F,D0
CMP.B mt_Counter(PC),D0
BNE.W mt_Return3
CLR.B n_volume(A6)
RTS
mt_NoteDelay
MOVEQ #0,D0
MOVE.B n_cmdlo(A6),D0
AND.B #$0F,D0
CMP.B mt_Counter,D0
BNE.W mt_Return3
MOVE.W (A6),D0
AND.W #$0FFF,D0
BEQ.W mt_Return3
BRA.W mt_DoRetrig
mt_PatternDelay
TST.B mt_Counter
BNE.W mt_Return3
MOVEQ #0,D0
MOVE.B n_cmdlo(A6),D0
AND.B #$0F,D0
TST.B mt_PattDelayTime2
BNE.W mt_Return3
ADDQ.B #1,D0
MOVE.B D0,mt_PattDelayTime
RTS
mt_FunkIt
TST.B mt_Counter
BNE.W mt_Return3
MOVE.B n_cmdlo(A6),D0
AND.B #$0F,D0
LSL.B #4,D0
AND.B #$0F,n_glissfunk(A6)
OR.B D0,n_glissfunk(A6)
TST.B D0
BEQ.W mt_Return3
mt_UpdateFunk
MOVEQ #0,D0
MOVE.B n_glissfunk(A6),D0
LSR.B #4,D0
BEQ.B mt_funkend
LEA mt_FunkTable(PC),A0
MOVE.B (A0,D0.W),D0
ADD.B D0,n_funkoffset(A6)
BTST #7,n_funkoffset(A6)
BEQ.B mt_funkend
CLR.B n_funkoffset(A6)
MOVE.L n_wavestart(A6),A0
CMP.L #0,A0
BEQ.B mt_funkend
MOVE.L n_loopstart(A6),D0
MOVEQ #0,D1
MOVE.W n_replen(A6),D1
ADD.L D1,D0
ADD.L D1,D0
ADDQ.L #1,A0
CMP.L D0,A0
BLO.B mt_funkok
MOVE.L n_loopstart(A6),A0
mt_funkok
MOVE.L A0,n_wavestart(A6)
MOVEQ #-1,D0
SUB.B (A0),D0
MOVE.B D0,(A0)
mt_funkend
RTS
mt_FunkTable
dc.b 0,5,6,7,8,10,11,13,16,19,22,26,32,43,64,128
mt_VibratoTable
dc.b 0, 24, 49, 74, 97,120,141,161
dc.b 180,197,212,224,235,244,250,253
dc.b 255,253,250,244,235,224,212,197
dc.b 180,161,141,120, 97, 74, 49, 24
; this LUT prevents MULU for getting correct period section
CNOP 0,4
mt_ftunePerTab
dc.l mt_ftune0,mt_ftune1,mt_ftune2,mt_ftune3
dc.l mt_ftune4,mt_ftune5,mt_ftune6,mt_ftune7
dc.l mt_ftune8,mt_ftune9,mt_ftuneA,mt_ftuneB
dc.l mt_ftuneC,mt_ftuneD,mt_ftuneE,mt_ftuneF
mt_PeriodTable
; Tuning 0, Normal
mt_ftune0
dc.w 856,808,762,720,678,640,604,570,538,508,480,453
dc.w 428,404,381,360,339,320,302,285,269,254,240,226
dc.w 214,202,190,180,170,160,151,143,135,127,120,113,0
; Tuning 1
mt_ftune1
dc.w 850,802,757,715,674,637,601,567,535,505,477,450
dc.w 425,401,379,357,337,318,300,284,268,253,239,225
dc.w 213,201,189,179,169,159,150,142,134,126,119,113,0
; Tuning 2
mt_ftune2
dc.w 844,796,752,709,670,632,597,563,532,502,474,447
dc.w 422,398,376,355,335,316,298,282,266,251,237,224
dc.w 211,199,188,177,167,158,149,141,133,125,118,112,0
; Tuning 3
mt_ftune3
dc.w 838,791,746,704,665,628,592,559,528,498,470,444
dc.w 419,395,373,352,332,314,296,280,264,249,235,222
dc.w 209,198,187,176,166,157,148,140,132,125,118,111,0
; Tuning 4
mt_ftune4
dc.w 832,785,741,699,660,623,588,555,524,495,467,441
dc.w 416,392,370,350,330,312,294,278,262,247,233,220
dc.w 208,196,185,175,165,156,147,139,131,124,117,110,0
; Tuning 5
mt_ftune5
dc.w 826,779,736,694,655,619,584,551,520,491,463,437
dc.w 413,390,368,347,328,309,292,276,260,245,232,219
dc.w 206,195,184,174,164,155,146,138,130,123,116,109,0
; Tuning 6
mt_ftune6
dc.w 820,774,730,689,651,614,580,547,516,487,460,434
dc.w 410,387,365,345,325,307,290,274,258,244,230,217
dc.w 205,193,183,172,163,154,145,137,129,122,115,109,0
; Tuning 7
mt_ftune7
dc.w 814,768,725,684,646,610,575,543,513,484,457,431
dc.w 407,384,363,342,323,305,288,272,256,242,228,216
dc.w 204,192,181,171,161,152,144,136,128,121,114,108,0
; Tuning -8
mt_ftune8
dc.w 907,856,808,762,720,678,640,604,570,538,508,480
dc.w 453,428,404,381,360,339,320,302,285,269,254,240
dc.w 226,214,202,190,180,170,160,151,143,135,127,120,0
; Tuning -7
mt_ftune9
dc.w 900,850,802,757,715,675,636,601,567,535,505,477
dc.w 450,425,401,379,357,337,318,300,284,268,253,238
dc.w 225,212,200,189,179,169,159,150,142,134,126,119,0
; Tuning -6
mt_ftuneA
dc.w 894,844,796,752,709,670,632,597,563,532,502,474
dc.w 447,422,398,376,355,335,316,298,282,266,251,237
dc.w 223,211,199,188,177,167,158,149,141,133,125,118,0
; Tuning -5
mt_ftuneB
dc.w 887,838,791,746,704,665,628,592,559,528,498,470
dc.w 444,419,395,373,352,332,314,296,280,264,249,235
dc.w 222,209,198,187,176,166,157,148,140,132,125,118,0
; Tuning -4
mt_ftuneC
dc.w 881,832,785,741,699,660,623,588,555,524,494,467
dc.w 441,416,392,370,350,330,312,294,278,262,247,233
dc.w 220,208,196,185,175,165,156,147,139,131,123,117,0
; Tuning -3
mt_ftuneD
dc.w 875,826,779,736,694,655,619,584,551,520,491,463
dc.w 437,413,390,368,347,328,309,292,276,260,245,232
dc.w 219,206,195,184,174,164,155,146,138,130,123,116,0
; Tuning -2
mt_ftuneE
dc.w 868,820,774,730,689,651,614,580,547,516,487,460
dc.w 434,410,387,365,345,325,307,290,274,258,244,230
dc.w 217,205,193,183,172,163,154,145,137,129,122,115,0
; Tuning -1
mt_ftuneF
dc.w 862,814,768,725,684,646,610,575,543,513,484,457
dc.w 431,407,384,363,342,323,305,288,272,256,242,228
dc.w 216,203,192,181,171,161,152,144,136,128,121,114,0
; ------------------------------------------------------
; Overflow bytes from CursorPosTable and UnshiftedKeymap
; LUTs so that overflown arpeggio at finetune -1 sounds
; right even if this table was to be moved.
; ------------------------------------------------------
dc.w 774,1800,2314,3087,4113,4627,5400,6426,6940,7713
dc.w 8739,9253,24625,12851,13365
CNOP 0,4
mt_audchan1temp dcb.b 26
dc.w $0001 ; voice #1 DMA bit
dcb.b 16
CNOP 0,4
mt_audchan2temp dcb.b 26
dc.w $0002 ; voice #2 DMA bit
dcb.b 16
CNOP 0,4
mt_audchan3temp dcb.b 26
dc.w $0004 ; voice #3 DMA bit
dcb.b 16
CNOP 0,4
mt_audchan4temp dcb.b 26
dc.w $0008 ; voice #4 DMA bit
dcb.b 16
CNOP 0,4
mt_SampleStarts dcb.l 31,0
mt_SongDataPtr dc.l 0
mt_SampleStructPtr dc.l 0
mt_PatternPtr dc.l 0
mt_PatternPos dc.w 0
mt_DMACONtemp dc.w 0
mt_SongLength dc.b 0
mt_Speed dc.b 6
mt_Counter dc.b 0
mt_SongPos dc.b 0
mt_PBreakPos dc.b 0
mt_PosJumpFlag dc.b 0
mt_PBreakFlag dc.b 0
mt_LowMask dc.b $FF
mt_PattDelayTime dc.b 0
mt_PattDelayTime2 dc.b 0
SECTION music,DATA_C
CNOP 0,4
mt_data INCBIN "music.mod"
;/* End of File */
|
8devices/carambola2
| 1,089
|
package/boot/uboot-ar71xx/files/board/zyxel/nbg460n/lowlevel_init.S
|
/*
* (C) Copyright 2010
* Michael Kurz <michi.kurz@googlemail.com>.
*
* See file CREDITS for list of people who contributed to this
* project.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*/
#include <config.h>
#include <version.h>
#include <asm/regdef.h>
#include <asm/mipsregs.h>
#include <asm/addrspace.h>
.globl lowlevel_init
/*
All done by Bootbase, nothing to do
*/
lowlevel_init:
jr ra
nop
|
8devices/openwrt-8devices
| 1,089
|
package/boot/uboot-ar71xx/files/board/zyxel/nbg460n/lowlevel_init.S
|
/*
* (C) Copyright 2010
* Michael Kurz <michi.kurz@googlemail.com>.
*
* See file CREDITS for list of people who contributed to this
* project.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*/
#include <config.h>
#include <version.h>
#include <asm/regdef.h>
#include <asm/mipsregs.h>
#include <asm/addrspace.h>
.globl lowlevel_init
/*
All done by Bootbase, nothing to do
*/
lowlevel_init:
jr ra
nop
|
903257958/stm32_oop_driver
| 24,722
|
stm32f411ce_drivers/stm32f411ce_uart/firmware/cmsis/device/startup_stm32f411xe.s
|
;*******************************************************************************
;* File Name : startup_stm32f411xe.s
;* Author : MCD Application Team
;* Description : STM32F411xExx devices vector table for MDK-ARM toolchain.
;* This module performs:
;* - Set the initial SP
;* - Set the initial PC == Reset_Handler
;* - Set the vector table entries with the exceptions ISR address
;* - Branches to __main in the C library (which eventually
;* calls main()).
;* After Reset the CortexM4 processor is in Thread mode,
;* priority is Privileged, and the Stack is set to Main.
;*******************************************************************************
;* @attention
;*
;* Copyright (c) 2017 STMicroelectronics.
;* All rights reserved.
;*
;* This software is licensed under terms that can be found in the LICENSE file
;* in the root directory of this software component.
;* If no LICENSE file comes with this software, it is provided AS-IS.
;*
;*******************************************************************************
;* <<< Use Configuration Wizard in Context Menu >>>
;
; Amount of memory (in bytes) allocated for Stack
; Tailor this value to your application needs
; <h> Stack Configuration
; <o> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
; </h>
Stack_Size EQU 0x400
AREA STACK, NOINIT, READWRITE, ALIGN=3
Stack_Mem SPACE Stack_Size
__initial_sp
; <h> Heap Configuration
; <o> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
; </h>
Heap_Size EQU 0x200
AREA HEAP, NOINIT, READWRITE, ALIGN=3
__heap_base
Heap_Mem SPACE Heap_Size
__heap_limit
PRESERVE8
THUMB
; Vector Table Mapped to Address 0 at Reset
AREA RESET, DATA, READONLY
EXPORT __Vectors
EXPORT __Vectors_End
EXPORT __Vectors_Size
__Vectors DCD __initial_sp ; Top of Stack
DCD Reset_Handler ; Reset Handler
DCD NMI_Handler ; NMI Handler
DCD HardFault_Handler ; Hard Fault Handler
DCD MemManage_Handler ; MPU Fault Handler
DCD BusFault_Handler ; Bus Fault Handler
DCD UsageFault_Handler ; Usage Fault Handler
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD SVC_Handler ; SVCall Handler
DCD DebugMon_Handler ; Debug Monitor Handler
DCD 0 ; Reserved
DCD PendSV_Handler ; PendSV Handler
DCD SysTick_Handler ; SysTick Handler
; External Interrupts
DCD WWDG_IRQHandler ; Window WatchDog
DCD PVD_IRQHandler ; PVD through EXTI Line detection
DCD TAMP_STAMP_IRQHandler ; Tamper and TimeStamps through the EXTI line
DCD RTC_WKUP_IRQHandler ; RTC Wakeup through the EXTI line
DCD FLASH_IRQHandler ; FLASH
DCD RCC_IRQHandler ; RCC
DCD EXTI0_IRQHandler ; EXTI Line0
DCD EXTI1_IRQHandler ; EXTI Line1
DCD EXTI2_IRQHandler ; EXTI Line2
DCD EXTI3_IRQHandler ; EXTI Line3
DCD EXTI4_IRQHandler ; EXTI Line4
DCD DMA1_Stream0_IRQHandler ; DMA1 Stream 0
DCD DMA1_Stream1_IRQHandler ; DMA1 Stream 1
DCD DMA1_Stream2_IRQHandler ; DMA1 Stream 2
DCD DMA1_Stream3_IRQHandler ; DMA1 Stream 3
DCD DMA1_Stream4_IRQHandler ; DMA1 Stream 4
DCD DMA1_Stream5_IRQHandler ; DMA1 Stream 5
DCD DMA1_Stream6_IRQHandler ; DMA1 Stream 6
DCD ADC_IRQHandler ; ADC1, ADC2 and ADC3s
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD EXTI9_5_IRQHandler ; External Line[9:5]s
DCD TIM1_BRK_TIM9_IRQHandler ; TIM1 Break and TIM9
DCD TIM1_UP_TIM10_IRQHandler ; TIM1 Update and TIM10
DCD TIM1_TRG_COM_TIM11_IRQHandler ; TIM1 Trigger and Commutation and TIM11
DCD TIM1_CC_IRQHandler ; TIM1 Capture Compare
DCD TIM2_IRQHandler ; TIM2
DCD TIM3_IRQHandler ; TIM3
DCD TIM4_IRQHandler ; TIM4
DCD I2C1_EV_IRQHandler ; I2C1 Event
DCD I2C1_ER_IRQHandler ; I2C1 Error
DCD I2C2_EV_IRQHandler ; I2C2 Event
DCD I2C2_ER_IRQHandler ; I2C2 Error
DCD SPI1_IRQHandler ; SPI1
DCD SPI2_IRQHandler ; SPI2
DCD USART1_IRQHandler ; USART1
DCD USART2_IRQHandler ; USART2
DCD 0 ; Reserved
DCD EXTI15_10_IRQHandler ; External Line[15:10]s
DCD RTC_Alarm_IRQHandler ; RTC Alarm (A and B) through EXTI Line
DCD OTG_FS_WKUP_IRQHandler ; USB OTG FS Wakeup through EXTI line
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD DMA1_Stream7_IRQHandler ; DMA1 Stream7
DCD 0 ; Reserved
DCD SDIO_IRQHandler ; SDIO
DCD TIM5_IRQHandler ; TIM5
DCD SPI3_IRQHandler ; SPI3
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD DMA2_Stream0_IRQHandler ; DMA2 Stream 0
DCD DMA2_Stream1_IRQHandler ; DMA2 Stream 1
DCD DMA2_Stream2_IRQHandler ; DMA2 Stream 2
DCD DMA2_Stream3_IRQHandler ; DMA2 Stream 3
DCD DMA2_Stream4_IRQHandler ; DMA2 Stream 4
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD OTG_FS_IRQHandler ; USB OTG FS
DCD DMA2_Stream5_IRQHandler ; DMA2 Stream 5
DCD DMA2_Stream6_IRQHandler ; DMA2 Stream 6
DCD DMA2_Stream7_IRQHandler ; DMA2 Stream 7
DCD USART6_IRQHandler ; USART6
DCD I2C3_EV_IRQHandler ; I2C3 event
DCD I2C3_ER_IRQHandler ; I2C3 error
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD FPU_IRQHandler ; FPU
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD SPI4_IRQHandler ; SPI4
DCD SPI5_IRQHandler ; SPI5
__Vectors_End
__Vectors_Size EQU __Vectors_End - __Vectors
AREA |.text|, CODE, READONLY
; Reset handler
Reset_Handler PROC
EXPORT Reset_Handler [WEAK]
IMPORT SystemInit
IMPORT __main
LDR R0, =SystemInit
BLX R0
LDR R0, =__main
BX R0
ENDP
; Dummy Exception Handlers (infinite loops which can be modified)
NMI_Handler PROC
EXPORT NMI_Handler [WEAK]
B .
ENDP
HardFault_Handler\
PROC
EXPORT HardFault_Handler [WEAK]
B .
ENDP
MemManage_Handler\
PROC
EXPORT MemManage_Handler [WEAK]
B .
ENDP
BusFault_Handler\
PROC
EXPORT BusFault_Handler [WEAK]
B .
ENDP
UsageFault_Handler\
PROC
EXPORT UsageFault_Handler [WEAK]
B .
ENDP
SVC_Handler PROC
EXPORT SVC_Handler [WEAK]
B .
ENDP
DebugMon_Handler\
PROC
EXPORT DebugMon_Handler [WEAK]
B .
ENDP
PendSV_Handler PROC
EXPORT PendSV_Handler [WEAK]
B .
ENDP
SysTick_Handler PROC
EXPORT SysTick_Handler [WEAK]
B .
ENDP
Default_Handler PROC
EXPORT WWDG_IRQHandler [WEAK]
EXPORT PVD_IRQHandler [WEAK]
EXPORT TAMP_STAMP_IRQHandler [WEAK]
EXPORT RTC_WKUP_IRQHandler [WEAK]
EXPORT FLASH_IRQHandler [WEAK]
EXPORT RCC_IRQHandler [WEAK]
EXPORT EXTI0_IRQHandler [WEAK]
EXPORT EXTI1_IRQHandler [WEAK]
EXPORT EXTI2_IRQHandler [WEAK]
EXPORT EXTI3_IRQHandler [WEAK]
EXPORT EXTI4_IRQHandler [WEAK]
EXPORT DMA1_Stream0_IRQHandler [WEAK]
EXPORT DMA1_Stream1_IRQHandler [WEAK]
EXPORT DMA1_Stream2_IRQHandler [WEAK]
EXPORT DMA1_Stream3_IRQHandler [WEAK]
EXPORT DMA1_Stream4_IRQHandler [WEAK]
EXPORT DMA1_Stream5_IRQHandler [WEAK]
EXPORT DMA1_Stream6_IRQHandler [WEAK]
EXPORT ADC_IRQHandler [WEAK]
EXPORT EXTI9_5_IRQHandler [WEAK]
EXPORT TIM1_BRK_TIM9_IRQHandler [WEAK]
EXPORT TIM1_UP_TIM10_IRQHandler [WEAK]
EXPORT TIM1_TRG_COM_TIM11_IRQHandler [WEAK]
EXPORT TIM1_CC_IRQHandler [WEAK]
EXPORT TIM2_IRQHandler [WEAK]
EXPORT TIM3_IRQHandler [WEAK]
EXPORT TIM4_IRQHandler [WEAK]
EXPORT I2C1_EV_IRQHandler [WEAK]
EXPORT I2C1_ER_IRQHandler [WEAK]
EXPORT I2C2_EV_IRQHandler [WEAK]
EXPORT I2C2_ER_IRQHandler [WEAK]
EXPORT SPI1_IRQHandler [WEAK]
EXPORT SPI2_IRQHandler [WEAK]
EXPORT USART1_IRQHandler [WEAK]
EXPORT USART2_IRQHandler [WEAK]
EXPORT EXTI15_10_IRQHandler [WEAK]
EXPORT RTC_Alarm_IRQHandler [WEAK]
EXPORT OTG_FS_WKUP_IRQHandler [WEAK]
EXPORT DMA1_Stream7_IRQHandler [WEAK]
EXPORT SDIO_IRQHandler [WEAK]
EXPORT TIM5_IRQHandler [WEAK]
EXPORT SPI3_IRQHandler [WEAK]
EXPORT DMA2_Stream0_IRQHandler [WEAK]
EXPORT DMA2_Stream1_IRQHandler [WEAK]
EXPORT DMA2_Stream2_IRQHandler [WEAK]
EXPORT DMA2_Stream3_IRQHandler [WEAK]
EXPORT DMA2_Stream4_IRQHandler [WEAK]
EXPORT OTG_FS_IRQHandler [WEAK]
EXPORT DMA2_Stream5_IRQHandler [WEAK]
EXPORT DMA2_Stream6_IRQHandler [WEAK]
EXPORT DMA2_Stream7_IRQHandler [WEAK]
EXPORT USART6_IRQHandler [WEAK]
EXPORT I2C3_EV_IRQHandler [WEAK]
EXPORT I2C3_ER_IRQHandler [WEAK]
EXPORT FPU_IRQHandler [WEAK]
EXPORT SPI4_IRQHandler [WEAK]
EXPORT SPI5_IRQHandler [WEAK]
WWDG_IRQHandler
PVD_IRQHandler
TAMP_STAMP_IRQHandler
RTC_WKUP_IRQHandler
FLASH_IRQHandler
RCC_IRQHandler
EXTI0_IRQHandler
EXTI1_IRQHandler
EXTI2_IRQHandler
EXTI3_IRQHandler
EXTI4_IRQHandler
DMA1_Stream0_IRQHandler
DMA1_Stream1_IRQHandler
DMA1_Stream2_IRQHandler
DMA1_Stream3_IRQHandler
DMA1_Stream4_IRQHandler
DMA1_Stream5_IRQHandler
DMA1_Stream6_IRQHandler
ADC_IRQHandler
EXTI9_5_IRQHandler
TIM1_BRK_TIM9_IRQHandler
TIM1_UP_TIM10_IRQHandler
TIM1_TRG_COM_TIM11_IRQHandler
TIM1_CC_IRQHandler
TIM2_IRQHandler
TIM3_IRQHandler
TIM4_IRQHandler
I2C1_EV_IRQHandler
I2C1_ER_IRQHandler
I2C2_EV_IRQHandler
I2C2_ER_IRQHandler
SPI1_IRQHandler
SPI2_IRQHandler
USART1_IRQHandler
USART2_IRQHandler
EXTI15_10_IRQHandler
RTC_Alarm_IRQHandler
OTG_FS_WKUP_IRQHandler
DMA1_Stream7_IRQHandler
SDIO_IRQHandler
TIM5_IRQHandler
SPI3_IRQHandler
DMA2_Stream0_IRQHandler
DMA2_Stream1_IRQHandler
DMA2_Stream2_IRQHandler
DMA2_Stream3_IRQHandler
DMA2_Stream4_IRQHandler
OTG_FS_IRQHandler
DMA2_Stream5_IRQHandler
DMA2_Stream6_IRQHandler
DMA2_Stream7_IRQHandler
USART6_IRQHandler
I2C3_EV_IRQHandler
I2C3_ER_IRQHandler
FPU_IRQHandler
SPI4_IRQHandler
SPI5_IRQHandler
B .
ENDP
ALIGN
;*******************************************************************************
; User Stack and Heap initialization
;*******************************************************************************
IF :DEF:__MICROLIB
EXPORT __initial_sp
EXPORT __heap_base
EXPORT __heap_limit
ELSE
IMPORT __use_two_region_memory
EXPORT __user_initial_stackheap
__user_initial_stackheap
LDR R0, = Heap_Mem
LDR R1, =(Stack_Mem + Stack_Size)
LDR R2, = (Heap_Mem + Heap_Size)
LDR R3, = Stack_Mem
BX LR
ALIGN
ENDIF
END
|
903257958/stm32_oop_driver
| 29,173
|
stm32f405rg_drivers/stm32f405rg_uart/firmware/cmsis/device/startup_stm32f40_41xxx.s
|
;******************** (C) COPYRIGHT 2016 STMicroelectronics ********************
;* File Name : startup_stm32f40_41xxx.s
;* Author : MCD Application Team
;* @version : V1.8.0
;* @date : 09-November-2016
;* Description : STM32F40xxx/41xxx devices vector table for MDK-ARM toolchain.
;* This module performs:
;* - Set the initial SP
;* - Set the initial PC == Reset_Handler
;* - Set the vector table entries with the exceptions ISR address
;* - Configure the system clock and the external SRAM mounted on
;* STM324xG-EVAL board to be used as data memory (optional,
;* to be enabled by user)
;* - Branches to __main in the C library (which eventually
;* calls main()).
;* After Reset the CortexM4 processor is in Thread mode,
;* priority is Privileged, and the Stack is set to Main.
;* <<< Use Configuration Wizard in Context Menu >>>
;*******************************************************************************
;
; Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
; You may not use this file except in compliance with the License.
; You may obtain a copy of the License at:
;
; http://www.st.com/software_license_agreement_liberty_v2
;
; Unless required by applicable law or agreed to in writing, software
; distributed under the License is distributed on an "AS IS" BASIS,
; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
; See the License for the specific language governing permissions and
; limitations under the License.
;
;*******************************************************************************
; Amount of memory (in bytes) allocated for Stack
; Tailor this value to your application needs
; <h> Stack Configuration
; <o> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
; </h>
Stack_Size EQU 0x00000400
AREA STACK, NOINIT, READWRITE, ALIGN=3
Stack_Mem SPACE Stack_Size
__initial_sp
; <h> Heap Configuration
; <o> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
; </h>
Heap_Size EQU 0x00000200
AREA HEAP, NOINIT, READWRITE, ALIGN=3
__heap_base
Heap_Mem SPACE Heap_Size
__heap_limit
PRESERVE8
THUMB
; Vector Table Mapped to Address 0 at Reset
AREA RESET, DATA, READONLY
EXPORT __Vectors
EXPORT __Vectors_End
EXPORT __Vectors_Size
__Vectors DCD __initial_sp ; Top of Stack
DCD Reset_Handler ; Reset Handler
DCD NMI_Handler ; NMI Handler
DCD HardFault_Handler ; Hard Fault Handler
DCD MemManage_Handler ; MPU Fault Handler
DCD BusFault_Handler ; Bus Fault Handler
DCD UsageFault_Handler ; Usage Fault Handler
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD SVC_Handler ; SVCall Handler
DCD DebugMon_Handler ; Debug Monitor Handler
DCD 0 ; Reserved
DCD PendSV_Handler ; PendSV Handler
DCD SysTick_Handler ; SysTick Handler
; External Interrupts
DCD WWDG_IRQHandler ; Window WatchDog
DCD PVD_IRQHandler ; PVD through EXTI Line detection
DCD TAMP_STAMP_IRQHandler ; Tamper and TimeStamps through the EXTI line
DCD RTC_WKUP_IRQHandler ; RTC Wakeup through the EXTI line
DCD FLASH_IRQHandler ; FLASH
DCD RCC_IRQHandler ; RCC
DCD EXTI0_IRQHandler ; EXTI Line0
DCD EXTI1_IRQHandler ; EXTI Line1
DCD EXTI2_IRQHandler ; EXTI Line2
DCD EXTI3_IRQHandler ; EXTI Line3
DCD EXTI4_IRQHandler ; EXTI Line4
DCD DMA1_Stream0_IRQHandler ; DMA1 Stream 0
DCD DMA1_Stream1_IRQHandler ; DMA1 Stream 1
DCD DMA1_Stream2_IRQHandler ; DMA1 Stream 2
DCD DMA1_Stream3_IRQHandler ; DMA1 Stream 3
DCD DMA1_Stream4_IRQHandler ; DMA1 Stream 4
DCD DMA1_Stream5_IRQHandler ; DMA1 Stream 5
DCD DMA1_Stream6_IRQHandler ; DMA1 Stream 6
DCD ADC_IRQHandler ; ADC1, ADC2 and ADC3s
DCD CAN1_TX_IRQHandler ; CAN1 TX
DCD CAN1_RX0_IRQHandler ; CAN1 RX0
DCD CAN1_RX1_IRQHandler ; CAN1 RX1
DCD CAN1_SCE_IRQHandler ; CAN1 SCE
DCD EXTI9_5_IRQHandler ; External Line[9:5]s
DCD TIM1_BRK_TIM9_IRQHandler ; TIM1 Break and TIM9
DCD TIM1_UP_TIM10_IRQHandler ; TIM1 Update and TIM10
DCD TIM1_TRG_COM_TIM11_IRQHandler ; TIM1 Trigger and Commutation and TIM11
DCD TIM1_CC_IRQHandler ; TIM1 Capture Compare
DCD TIM2_IRQHandler ; TIM2
DCD TIM3_IRQHandler ; TIM3
DCD TIM4_IRQHandler ; TIM4
DCD I2C1_EV_IRQHandler ; I2C1 Event
DCD I2C1_ER_IRQHandler ; I2C1 Error
DCD I2C2_EV_IRQHandler ; I2C2 Event
DCD I2C2_ER_IRQHandler ; I2C2 Error
DCD SPI1_IRQHandler ; SPI1
DCD SPI2_IRQHandler ; SPI2
DCD USART1_IRQHandler ; USART1
DCD USART2_IRQHandler ; USART2
DCD USART3_IRQHandler ; USART3
DCD EXTI15_10_IRQHandler ; External Line[15:10]s
DCD RTC_Alarm_IRQHandler ; RTC Alarm (A and B) through EXTI Line
DCD OTG_FS_WKUP_IRQHandler ; USB OTG FS Wakeup through EXTI line
DCD TIM8_BRK_TIM12_IRQHandler ; TIM8 Break and TIM12
DCD TIM8_UP_TIM13_IRQHandler ; TIM8 Update and TIM13
DCD TIM8_TRG_COM_TIM14_IRQHandler ; TIM8 Trigger and Commutation and TIM14
DCD TIM8_CC_IRQHandler ; TIM8 Capture Compare
DCD DMA1_Stream7_IRQHandler ; DMA1 Stream7
DCD FSMC_IRQHandler ; FSMC
DCD SDIO_IRQHandler ; SDIO
DCD TIM5_IRQHandler ; TIM5
DCD SPI3_IRQHandler ; SPI3
DCD UART4_IRQHandler ; UART4
DCD UART5_IRQHandler ; UART5
DCD TIM6_DAC_IRQHandler ; TIM6 and DAC1&2 underrun errors
DCD TIM7_IRQHandler ; TIM7
DCD DMA2_Stream0_IRQHandler ; DMA2 Stream 0
DCD DMA2_Stream1_IRQHandler ; DMA2 Stream 1
DCD DMA2_Stream2_IRQHandler ; DMA2 Stream 2
DCD DMA2_Stream3_IRQHandler ; DMA2 Stream 3
DCD DMA2_Stream4_IRQHandler ; DMA2 Stream 4
DCD ETH_IRQHandler ; Ethernet
DCD ETH_WKUP_IRQHandler ; Ethernet Wakeup through EXTI line
DCD CAN2_TX_IRQHandler ; CAN2 TX
DCD CAN2_RX0_IRQHandler ; CAN2 RX0
DCD CAN2_RX1_IRQHandler ; CAN2 RX1
DCD CAN2_SCE_IRQHandler ; CAN2 SCE
DCD OTG_FS_IRQHandler ; USB OTG FS
DCD DMA2_Stream5_IRQHandler ; DMA2 Stream 5
DCD DMA2_Stream6_IRQHandler ; DMA2 Stream 6
DCD DMA2_Stream7_IRQHandler ; DMA2 Stream 7
DCD USART6_IRQHandler ; USART6
DCD I2C3_EV_IRQHandler ; I2C3 event
DCD I2C3_ER_IRQHandler ; I2C3 error
DCD OTG_HS_EP1_OUT_IRQHandler ; USB OTG HS End Point 1 Out
DCD OTG_HS_EP1_IN_IRQHandler ; USB OTG HS End Point 1 In
DCD OTG_HS_WKUP_IRQHandler ; USB OTG HS Wakeup through EXTI
DCD OTG_HS_IRQHandler ; USB OTG HS
DCD DCMI_IRQHandler ; DCMI
DCD CRYP_IRQHandler ; CRYP crypto
DCD HASH_RNG_IRQHandler ; Hash and Rng
DCD FPU_IRQHandler ; FPU
__Vectors_End
__Vectors_Size EQU __Vectors_End - __Vectors
AREA |.text|, CODE, READONLY
; Reset handler
Reset_Handler PROC
EXPORT Reset_Handler [WEAK]
IMPORT SystemInit
IMPORT __main
LDR R0, =SystemInit
BLX R0
LDR R0, =__main
BX R0
ENDP
; Dummy Exception Handlers (infinite loops which can be modified)
NMI_Handler PROC
EXPORT NMI_Handler [WEAK]
B .
ENDP
HardFault_Handler\
PROC
EXPORT HardFault_Handler [WEAK]
B .
ENDP
MemManage_Handler\
PROC
EXPORT MemManage_Handler [WEAK]
B .
ENDP
BusFault_Handler\
PROC
EXPORT BusFault_Handler [WEAK]
B .
ENDP
UsageFault_Handler\
PROC
EXPORT UsageFault_Handler [WEAK]
B .
ENDP
SVC_Handler PROC
EXPORT SVC_Handler [WEAK]
B .
ENDP
DebugMon_Handler\
PROC
EXPORT DebugMon_Handler [WEAK]
B .
ENDP
PendSV_Handler PROC
EXPORT PendSV_Handler [WEAK]
B .
ENDP
SysTick_Handler PROC
EXPORT SysTick_Handler [WEAK]
B .
ENDP
Default_Handler PROC
EXPORT WWDG_IRQHandler [WEAK]
EXPORT PVD_IRQHandler [WEAK]
EXPORT TAMP_STAMP_IRQHandler [WEAK]
EXPORT RTC_WKUP_IRQHandler [WEAK]
EXPORT FLASH_IRQHandler [WEAK]
EXPORT RCC_IRQHandler [WEAK]
EXPORT EXTI0_IRQHandler [WEAK]
EXPORT EXTI1_IRQHandler [WEAK]
EXPORT EXTI2_IRQHandler [WEAK]
EXPORT EXTI3_IRQHandler [WEAK]
EXPORT EXTI4_IRQHandler [WEAK]
EXPORT DMA1_Stream0_IRQHandler [WEAK]
EXPORT DMA1_Stream1_IRQHandler [WEAK]
EXPORT DMA1_Stream2_IRQHandler [WEAK]
EXPORT DMA1_Stream3_IRQHandler [WEAK]
EXPORT DMA1_Stream4_IRQHandler [WEAK]
EXPORT DMA1_Stream5_IRQHandler [WEAK]
EXPORT DMA1_Stream6_IRQHandler [WEAK]
EXPORT ADC_IRQHandler [WEAK]
EXPORT CAN1_TX_IRQHandler [WEAK]
EXPORT CAN1_RX0_IRQHandler [WEAK]
EXPORT CAN1_RX1_IRQHandler [WEAK]
EXPORT CAN1_SCE_IRQHandler [WEAK]
EXPORT EXTI9_5_IRQHandler [WEAK]
EXPORT TIM1_BRK_TIM9_IRQHandler [WEAK]
EXPORT TIM1_UP_TIM10_IRQHandler [WEAK]
EXPORT TIM1_TRG_COM_TIM11_IRQHandler [WEAK]
EXPORT TIM1_CC_IRQHandler [WEAK]
EXPORT TIM2_IRQHandler [WEAK]
EXPORT TIM3_IRQHandler [WEAK]
EXPORT TIM4_IRQHandler [WEAK]
EXPORT I2C1_EV_IRQHandler [WEAK]
EXPORT I2C1_ER_IRQHandler [WEAK]
EXPORT I2C2_EV_IRQHandler [WEAK]
EXPORT I2C2_ER_IRQHandler [WEAK]
EXPORT SPI1_IRQHandler [WEAK]
EXPORT SPI2_IRQHandler [WEAK]
EXPORT USART1_IRQHandler [WEAK]
EXPORT USART2_IRQHandler [WEAK]
EXPORT USART3_IRQHandler [WEAK]
EXPORT EXTI15_10_IRQHandler [WEAK]
EXPORT RTC_Alarm_IRQHandler [WEAK]
EXPORT OTG_FS_WKUP_IRQHandler [WEAK]
EXPORT TIM8_BRK_TIM12_IRQHandler [WEAK]
EXPORT TIM8_UP_TIM13_IRQHandler [WEAK]
EXPORT TIM8_TRG_COM_TIM14_IRQHandler [WEAK]
EXPORT TIM8_CC_IRQHandler [WEAK]
EXPORT DMA1_Stream7_IRQHandler [WEAK]
EXPORT FSMC_IRQHandler [WEAK]
EXPORT SDIO_IRQHandler [WEAK]
EXPORT TIM5_IRQHandler [WEAK]
EXPORT SPI3_IRQHandler [WEAK]
EXPORT UART4_IRQHandler [WEAK]
EXPORT UART5_IRQHandler [WEAK]
EXPORT TIM6_DAC_IRQHandler [WEAK]
EXPORT TIM7_IRQHandler [WEAK]
EXPORT DMA2_Stream0_IRQHandler [WEAK]
EXPORT DMA2_Stream1_IRQHandler [WEAK]
EXPORT DMA2_Stream2_IRQHandler [WEAK]
EXPORT DMA2_Stream3_IRQHandler [WEAK]
EXPORT DMA2_Stream4_IRQHandler [WEAK]
EXPORT ETH_IRQHandler [WEAK]
EXPORT ETH_WKUP_IRQHandler [WEAK]
EXPORT CAN2_TX_IRQHandler [WEAK]
EXPORT CAN2_RX0_IRQHandler [WEAK]
EXPORT CAN2_RX1_IRQHandler [WEAK]
EXPORT CAN2_SCE_IRQHandler [WEAK]
EXPORT OTG_FS_IRQHandler [WEAK]
EXPORT DMA2_Stream5_IRQHandler [WEAK]
EXPORT DMA2_Stream6_IRQHandler [WEAK]
EXPORT DMA2_Stream7_IRQHandler [WEAK]
EXPORT USART6_IRQHandler [WEAK]
EXPORT I2C3_EV_IRQHandler [WEAK]
EXPORT I2C3_ER_IRQHandler [WEAK]
EXPORT OTG_HS_EP1_OUT_IRQHandler [WEAK]
EXPORT OTG_HS_EP1_IN_IRQHandler [WEAK]
EXPORT OTG_HS_WKUP_IRQHandler [WEAK]
EXPORT OTG_HS_IRQHandler [WEAK]
EXPORT DCMI_IRQHandler [WEAK]
EXPORT CRYP_IRQHandler [WEAK]
EXPORT HASH_RNG_IRQHandler [WEAK]
EXPORT FPU_IRQHandler [WEAK]
WWDG_IRQHandler
PVD_IRQHandler
TAMP_STAMP_IRQHandler
RTC_WKUP_IRQHandler
FLASH_IRQHandler
RCC_IRQHandler
EXTI0_IRQHandler
EXTI1_IRQHandler
EXTI2_IRQHandler
EXTI3_IRQHandler
EXTI4_IRQHandler
DMA1_Stream0_IRQHandler
DMA1_Stream1_IRQHandler
DMA1_Stream2_IRQHandler
DMA1_Stream3_IRQHandler
DMA1_Stream4_IRQHandler
DMA1_Stream5_IRQHandler
DMA1_Stream6_IRQHandler
ADC_IRQHandler
CAN1_TX_IRQHandler
CAN1_RX0_IRQHandler
CAN1_RX1_IRQHandler
CAN1_SCE_IRQHandler
EXTI9_5_IRQHandler
TIM1_BRK_TIM9_IRQHandler
TIM1_UP_TIM10_IRQHandler
TIM1_TRG_COM_TIM11_IRQHandler
TIM1_CC_IRQHandler
TIM2_IRQHandler
TIM3_IRQHandler
TIM4_IRQHandler
I2C1_EV_IRQHandler
I2C1_ER_IRQHandler
I2C2_EV_IRQHandler
I2C2_ER_IRQHandler
SPI1_IRQHandler
SPI2_IRQHandler
USART1_IRQHandler
USART2_IRQHandler
USART3_IRQHandler
EXTI15_10_IRQHandler
RTC_Alarm_IRQHandler
OTG_FS_WKUP_IRQHandler
TIM8_BRK_TIM12_IRQHandler
TIM8_UP_TIM13_IRQHandler
TIM8_TRG_COM_TIM14_IRQHandler
TIM8_CC_IRQHandler
DMA1_Stream7_IRQHandler
FSMC_IRQHandler
SDIO_IRQHandler
TIM5_IRQHandler
SPI3_IRQHandler
UART4_IRQHandler
UART5_IRQHandler
TIM6_DAC_IRQHandler
TIM7_IRQHandler
DMA2_Stream0_IRQHandler
DMA2_Stream1_IRQHandler
DMA2_Stream2_IRQHandler
DMA2_Stream3_IRQHandler
DMA2_Stream4_IRQHandler
ETH_IRQHandler
ETH_WKUP_IRQHandler
CAN2_TX_IRQHandler
CAN2_RX0_IRQHandler
CAN2_RX1_IRQHandler
CAN2_SCE_IRQHandler
OTG_FS_IRQHandler
DMA2_Stream5_IRQHandler
DMA2_Stream6_IRQHandler
DMA2_Stream7_IRQHandler
USART6_IRQHandler
I2C3_EV_IRQHandler
I2C3_ER_IRQHandler
OTG_HS_EP1_OUT_IRQHandler
OTG_HS_EP1_IN_IRQHandler
OTG_HS_WKUP_IRQHandler
OTG_HS_IRQHandler
DCMI_IRQHandler
CRYP_IRQHandler
HASH_RNG_IRQHandler
FPU_IRQHandler
B .
ENDP
ALIGN
;*******************************************************************************
; User Stack and Heap initialization
;*******************************************************************************
IF :DEF:__MICROLIB
EXPORT __initial_sp
EXPORT __heap_base
EXPORT __heap_limit
ELSE
IMPORT __use_two_region_memory
EXPORT __user_initial_stackheap
__user_initial_stackheap
LDR R0, = Heap_Mem
LDR R1, =(Stack_Mem + Stack_Size)
LDR R2, = (Heap_Mem + Heap_Size)
LDR R3, = Stack_Mem
BX LR
ALIGN
ENDIF
END
;************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE*****
|
903257958/stm32_oop_driver
| 29,173
|
stm32f405rg_drivers/stm32f405rg_i2c_soft_mpu6050/firmware/cmsis/device/startup_stm32f40_41xxx.s
|
;******************** (C) COPYRIGHT 2016 STMicroelectronics ********************
;* File Name : startup_stm32f40_41xxx.s
;* Author : MCD Application Team
;* @version : V1.8.0
;* @date : 09-November-2016
;* Description : STM32F40xxx/41xxx devices vector table for MDK-ARM toolchain.
;* This module performs:
;* - Set the initial SP
;* - Set the initial PC == Reset_Handler
;* - Set the vector table entries with the exceptions ISR address
;* - Configure the system clock and the external SRAM mounted on
;* STM324xG-EVAL board to be used as data memory (optional,
;* to be enabled by user)
;* - Branches to __main in the C library (which eventually
;* calls main()).
;* After Reset the CortexM4 processor is in Thread mode,
;* priority is Privileged, and the Stack is set to Main.
;* <<< Use Configuration Wizard in Context Menu >>>
;*******************************************************************************
;
; Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
; You may not use this file except in compliance with the License.
; You may obtain a copy of the License at:
;
; http://www.st.com/software_license_agreement_liberty_v2
;
; Unless required by applicable law or agreed to in writing, software
; distributed under the License is distributed on an "AS IS" BASIS,
; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
; See the License for the specific language governing permissions and
; limitations under the License.
;
;*******************************************************************************
; Amount of memory (in bytes) allocated for Stack
; Tailor this value to your application needs
; <h> Stack Configuration
; <o> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
; </h>
Stack_Size EQU 0x00000400
AREA STACK, NOINIT, READWRITE, ALIGN=3
Stack_Mem SPACE Stack_Size
__initial_sp
; <h> Heap Configuration
; <o> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
; </h>
Heap_Size EQU 0x00000200
AREA HEAP, NOINIT, READWRITE, ALIGN=3
__heap_base
Heap_Mem SPACE Heap_Size
__heap_limit
PRESERVE8
THUMB
; Vector Table Mapped to Address 0 at Reset
AREA RESET, DATA, READONLY
EXPORT __Vectors
EXPORT __Vectors_End
EXPORT __Vectors_Size
__Vectors DCD __initial_sp ; Top of Stack
DCD Reset_Handler ; Reset Handler
DCD NMI_Handler ; NMI Handler
DCD HardFault_Handler ; Hard Fault Handler
DCD MemManage_Handler ; MPU Fault Handler
DCD BusFault_Handler ; Bus Fault Handler
DCD UsageFault_Handler ; Usage Fault Handler
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD SVC_Handler ; SVCall Handler
DCD DebugMon_Handler ; Debug Monitor Handler
DCD 0 ; Reserved
DCD PendSV_Handler ; PendSV Handler
DCD SysTick_Handler ; SysTick Handler
; External Interrupts
DCD WWDG_IRQHandler ; Window WatchDog
DCD PVD_IRQHandler ; PVD through EXTI Line detection
DCD TAMP_STAMP_IRQHandler ; Tamper and TimeStamps through the EXTI line
DCD RTC_WKUP_IRQHandler ; RTC Wakeup through the EXTI line
DCD FLASH_IRQHandler ; FLASH
DCD RCC_IRQHandler ; RCC
DCD EXTI0_IRQHandler ; EXTI Line0
DCD EXTI1_IRQHandler ; EXTI Line1
DCD EXTI2_IRQHandler ; EXTI Line2
DCD EXTI3_IRQHandler ; EXTI Line3
DCD EXTI4_IRQHandler ; EXTI Line4
DCD DMA1_Stream0_IRQHandler ; DMA1 Stream 0
DCD DMA1_Stream1_IRQHandler ; DMA1 Stream 1
DCD DMA1_Stream2_IRQHandler ; DMA1 Stream 2
DCD DMA1_Stream3_IRQHandler ; DMA1 Stream 3
DCD DMA1_Stream4_IRQHandler ; DMA1 Stream 4
DCD DMA1_Stream5_IRQHandler ; DMA1 Stream 5
DCD DMA1_Stream6_IRQHandler ; DMA1 Stream 6
DCD ADC_IRQHandler ; ADC1, ADC2 and ADC3s
DCD CAN1_TX_IRQHandler ; CAN1 TX
DCD CAN1_RX0_IRQHandler ; CAN1 RX0
DCD CAN1_RX1_IRQHandler ; CAN1 RX1
DCD CAN1_SCE_IRQHandler ; CAN1 SCE
DCD EXTI9_5_IRQHandler ; External Line[9:5]s
DCD TIM1_BRK_TIM9_IRQHandler ; TIM1 Break and TIM9
DCD TIM1_UP_TIM10_IRQHandler ; TIM1 Update and TIM10
DCD TIM1_TRG_COM_TIM11_IRQHandler ; TIM1 Trigger and Commutation and TIM11
DCD TIM1_CC_IRQHandler ; TIM1 Capture Compare
DCD TIM2_IRQHandler ; TIM2
DCD TIM3_IRQHandler ; TIM3
DCD TIM4_IRQHandler ; TIM4
DCD I2C1_EV_IRQHandler ; I2C1 Event
DCD I2C1_ER_IRQHandler ; I2C1 Error
DCD I2C2_EV_IRQHandler ; I2C2 Event
DCD I2C2_ER_IRQHandler ; I2C2 Error
DCD SPI1_IRQHandler ; SPI1
DCD SPI2_IRQHandler ; SPI2
DCD USART1_IRQHandler ; USART1
DCD USART2_IRQHandler ; USART2
DCD USART3_IRQHandler ; USART3
DCD EXTI15_10_IRQHandler ; External Line[15:10]s
DCD RTC_Alarm_IRQHandler ; RTC Alarm (A and B) through EXTI Line
DCD OTG_FS_WKUP_IRQHandler ; USB OTG FS Wakeup through EXTI line
DCD TIM8_BRK_TIM12_IRQHandler ; TIM8 Break and TIM12
DCD TIM8_UP_TIM13_IRQHandler ; TIM8 Update and TIM13
DCD TIM8_TRG_COM_TIM14_IRQHandler ; TIM8 Trigger and Commutation and TIM14
DCD TIM8_CC_IRQHandler ; TIM8 Capture Compare
DCD DMA1_Stream7_IRQHandler ; DMA1 Stream7
DCD FSMC_IRQHandler ; FSMC
DCD SDIO_IRQHandler ; SDIO
DCD TIM5_IRQHandler ; TIM5
DCD SPI3_IRQHandler ; SPI3
DCD UART4_IRQHandler ; UART4
DCD UART5_IRQHandler ; UART5
DCD TIM6_DAC_IRQHandler ; TIM6 and DAC1&2 underrun errors
DCD TIM7_IRQHandler ; TIM7
DCD DMA2_Stream0_IRQHandler ; DMA2 Stream 0
DCD DMA2_Stream1_IRQHandler ; DMA2 Stream 1
DCD DMA2_Stream2_IRQHandler ; DMA2 Stream 2
DCD DMA2_Stream3_IRQHandler ; DMA2 Stream 3
DCD DMA2_Stream4_IRQHandler ; DMA2 Stream 4
DCD ETH_IRQHandler ; Ethernet
DCD ETH_WKUP_IRQHandler ; Ethernet Wakeup through EXTI line
DCD CAN2_TX_IRQHandler ; CAN2 TX
DCD CAN2_RX0_IRQHandler ; CAN2 RX0
DCD CAN2_RX1_IRQHandler ; CAN2 RX1
DCD CAN2_SCE_IRQHandler ; CAN2 SCE
DCD OTG_FS_IRQHandler ; USB OTG FS
DCD DMA2_Stream5_IRQHandler ; DMA2 Stream 5
DCD DMA2_Stream6_IRQHandler ; DMA2 Stream 6
DCD DMA2_Stream7_IRQHandler ; DMA2 Stream 7
DCD USART6_IRQHandler ; USART6
DCD I2C3_EV_IRQHandler ; I2C3 event
DCD I2C3_ER_IRQHandler ; I2C3 error
DCD OTG_HS_EP1_OUT_IRQHandler ; USB OTG HS End Point 1 Out
DCD OTG_HS_EP1_IN_IRQHandler ; USB OTG HS End Point 1 In
DCD OTG_HS_WKUP_IRQHandler ; USB OTG HS Wakeup through EXTI
DCD OTG_HS_IRQHandler ; USB OTG HS
DCD DCMI_IRQHandler ; DCMI
DCD CRYP_IRQHandler ; CRYP crypto
DCD HASH_RNG_IRQHandler ; Hash and Rng
DCD FPU_IRQHandler ; FPU
__Vectors_End
__Vectors_Size EQU __Vectors_End - __Vectors
AREA |.text|, CODE, READONLY
; Reset handler
Reset_Handler PROC
EXPORT Reset_Handler [WEAK]
IMPORT SystemInit
IMPORT __main
LDR R0, =SystemInit
BLX R0
LDR R0, =__main
BX R0
ENDP
; Dummy Exception Handlers (infinite loops which can be modified)
NMI_Handler PROC
EXPORT NMI_Handler [WEAK]
B .
ENDP
HardFault_Handler\
PROC
EXPORT HardFault_Handler [WEAK]
B .
ENDP
MemManage_Handler\
PROC
EXPORT MemManage_Handler [WEAK]
B .
ENDP
BusFault_Handler\
PROC
EXPORT BusFault_Handler [WEAK]
B .
ENDP
UsageFault_Handler\
PROC
EXPORT UsageFault_Handler [WEAK]
B .
ENDP
SVC_Handler PROC
EXPORT SVC_Handler [WEAK]
B .
ENDP
DebugMon_Handler\
PROC
EXPORT DebugMon_Handler [WEAK]
B .
ENDP
PendSV_Handler PROC
EXPORT PendSV_Handler [WEAK]
B .
ENDP
SysTick_Handler PROC
EXPORT SysTick_Handler [WEAK]
B .
ENDP
Default_Handler PROC
EXPORT WWDG_IRQHandler [WEAK]
EXPORT PVD_IRQHandler [WEAK]
EXPORT TAMP_STAMP_IRQHandler [WEAK]
EXPORT RTC_WKUP_IRQHandler [WEAK]
EXPORT FLASH_IRQHandler [WEAK]
EXPORT RCC_IRQHandler [WEAK]
EXPORT EXTI0_IRQHandler [WEAK]
EXPORT EXTI1_IRQHandler [WEAK]
EXPORT EXTI2_IRQHandler [WEAK]
EXPORT EXTI3_IRQHandler [WEAK]
EXPORT EXTI4_IRQHandler [WEAK]
EXPORT DMA1_Stream0_IRQHandler [WEAK]
EXPORT DMA1_Stream1_IRQHandler [WEAK]
EXPORT DMA1_Stream2_IRQHandler [WEAK]
EXPORT DMA1_Stream3_IRQHandler [WEAK]
EXPORT DMA1_Stream4_IRQHandler [WEAK]
EXPORT DMA1_Stream5_IRQHandler [WEAK]
EXPORT DMA1_Stream6_IRQHandler [WEAK]
EXPORT ADC_IRQHandler [WEAK]
EXPORT CAN1_TX_IRQHandler [WEAK]
EXPORT CAN1_RX0_IRQHandler [WEAK]
EXPORT CAN1_RX1_IRQHandler [WEAK]
EXPORT CAN1_SCE_IRQHandler [WEAK]
EXPORT EXTI9_5_IRQHandler [WEAK]
EXPORT TIM1_BRK_TIM9_IRQHandler [WEAK]
EXPORT TIM1_UP_TIM10_IRQHandler [WEAK]
EXPORT TIM1_TRG_COM_TIM11_IRQHandler [WEAK]
EXPORT TIM1_CC_IRQHandler [WEAK]
EXPORT TIM2_IRQHandler [WEAK]
EXPORT TIM3_IRQHandler [WEAK]
EXPORT TIM4_IRQHandler [WEAK]
EXPORT I2C1_EV_IRQHandler [WEAK]
EXPORT I2C1_ER_IRQHandler [WEAK]
EXPORT I2C2_EV_IRQHandler [WEAK]
EXPORT I2C2_ER_IRQHandler [WEAK]
EXPORT SPI1_IRQHandler [WEAK]
EXPORT SPI2_IRQHandler [WEAK]
EXPORT USART1_IRQHandler [WEAK]
EXPORT USART2_IRQHandler [WEAK]
EXPORT USART3_IRQHandler [WEAK]
EXPORT EXTI15_10_IRQHandler [WEAK]
EXPORT RTC_Alarm_IRQHandler [WEAK]
EXPORT OTG_FS_WKUP_IRQHandler [WEAK]
EXPORT TIM8_BRK_TIM12_IRQHandler [WEAK]
EXPORT TIM8_UP_TIM13_IRQHandler [WEAK]
EXPORT TIM8_TRG_COM_TIM14_IRQHandler [WEAK]
EXPORT TIM8_CC_IRQHandler [WEAK]
EXPORT DMA1_Stream7_IRQHandler [WEAK]
EXPORT FSMC_IRQHandler [WEAK]
EXPORT SDIO_IRQHandler [WEAK]
EXPORT TIM5_IRQHandler [WEAK]
EXPORT SPI3_IRQHandler [WEAK]
EXPORT UART4_IRQHandler [WEAK]
EXPORT UART5_IRQHandler [WEAK]
EXPORT TIM6_DAC_IRQHandler [WEAK]
EXPORT TIM7_IRQHandler [WEAK]
EXPORT DMA2_Stream0_IRQHandler [WEAK]
EXPORT DMA2_Stream1_IRQHandler [WEAK]
EXPORT DMA2_Stream2_IRQHandler [WEAK]
EXPORT DMA2_Stream3_IRQHandler [WEAK]
EXPORT DMA2_Stream4_IRQHandler [WEAK]
EXPORT ETH_IRQHandler [WEAK]
EXPORT ETH_WKUP_IRQHandler [WEAK]
EXPORT CAN2_TX_IRQHandler [WEAK]
EXPORT CAN2_RX0_IRQHandler [WEAK]
EXPORT CAN2_RX1_IRQHandler [WEAK]
EXPORT CAN2_SCE_IRQHandler [WEAK]
EXPORT OTG_FS_IRQHandler [WEAK]
EXPORT DMA2_Stream5_IRQHandler [WEAK]
EXPORT DMA2_Stream6_IRQHandler [WEAK]
EXPORT DMA2_Stream7_IRQHandler [WEAK]
EXPORT USART6_IRQHandler [WEAK]
EXPORT I2C3_EV_IRQHandler [WEAK]
EXPORT I2C3_ER_IRQHandler [WEAK]
EXPORT OTG_HS_EP1_OUT_IRQHandler [WEAK]
EXPORT OTG_HS_EP1_IN_IRQHandler [WEAK]
EXPORT OTG_HS_WKUP_IRQHandler [WEAK]
EXPORT OTG_HS_IRQHandler [WEAK]
EXPORT DCMI_IRQHandler [WEAK]
EXPORT CRYP_IRQHandler [WEAK]
EXPORT HASH_RNG_IRQHandler [WEAK]
EXPORT FPU_IRQHandler [WEAK]
WWDG_IRQHandler
PVD_IRQHandler
TAMP_STAMP_IRQHandler
RTC_WKUP_IRQHandler
FLASH_IRQHandler
RCC_IRQHandler
EXTI0_IRQHandler
EXTI1_IRQHandler
EXTI2_IRQHandler
EXTI3_IRQHandler
EXTI4_IRQHandler
DMA1_Stream0_IRQHandler
DMA1_Stream1_IRQHandler
DMA1_Stream2_IRQHandler
DMA1_Stream3_IRQHandler
DMA1_Stream4_IRQHandler
DMA1_Stream5_IRQHandler
DMA1_Stream6_IRQHandler
ADC_IRQHandler
CAN1_TX_IRQHandler
CAN1_RX0_IRQHandler
CAN1_RX1_IRQHandler
CAN1_SCE_IRQHandler
EXTI9_5_IRQHandler
TIM1_BRK_TIM9_IRQHandler
TIM1_UP_TIM10_IRQHandler
TIM1_TRG_COM_TIM11_IRQHandler
TIM1_CC_IRQHandler
TIM2_IRQHandler
TIM3_IRQHandler
TIM4_IRQHandler
I2C1_EV_IRQHandler
I2C1_ER_IRQHandler
I2C2_EV_IRQHandler
I2C2_ER_IRQHandler
SPI1_IRQHandler
SPI2_IRQHandler
USART1_IRQHandler
USART2_IRQHandler
USART3_IRQHandler
EXTI15_10_IRQHandler
RTC_Alarm_IRQHandler
OTG_FS_WKUP_IRQHandler
TIM8_BRK_TIM12_IRQHandler
TIM8_UP_TIM13_IRQHandler
TIM8_TRG_COM_TIM14_IRQHandler
TIM8_CC_IRQHandler
DMA1_Stream7_IRQHandler
FSMC_IRQHandler
SDIO_IRQHandler
TIM5_IRQHandler
SPI3_IRQHandler
UART4_IRQHandler
UART5_IRQHandler
TIM6_DAC_IRQHandler
TIM7_IRQHandler
DMA2_Stream0_IRQHandler
DMA2_Stream1_IRQHandler
DMA2_Stream2_IRQHandler
DMA2_Stream3_IRQHandler
DMA2_Stream4_IRQHandler
ETH_IRQHandler
ETH_WKUP_IRQHandler
CAN2_TX_IRQHandler
CAN2_RX0_IRQHandler
CAN2_RX1_IRQHandler
CAN2_SCE_IRQHandler
OTG_FS_IRQHandler
DMA2_Stream5_IRQHandler
DMA2_Stream6_IRQHandler
DMA2_Stream7_IRQHandler
USART6_IRQHandler
I2C3_EV_IRQHandler
I2C3_ER_IRQHandler
OTG_HS_EP1_OUT_IRQHandler
OTG_HS_EP1_IN_IRQHandler
OTG_HS_WKUP_IRQHandler
OTG_HS_IRQHandler
DCMI_IRQHandler
CRYP_IRQHandler
HASH_RNG_IRQHandler
FPU_IRQHandler
B .
ENDP
ALIGN
;*******************************************************************************
; User Stack and Heap initialization
;*******************************************************************************
IF :DEF:__MICROLIB
EXPORT __initial_sp
EXPORT __heap_base
EXPORT __heap_limit
ELSE
IMPORT __use_two_region_memory
EXPORT __user_initial_stackheap
__user_initial_stackheap
LDR R0, = Heap_Mem
LDR R1, =(Stack_Mem + Stack_Size)
LDR R2, = (Heap_Mem + Heap_Size)
LDR R3, = Stack_Mem
BX LR
ALIGN
ENDIF
END
;************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE*****
|
903257958/stm32_oop_driver
| 29,173
|
stm32f405rg_drivers/stm32f405rg_spi_hard_dma_st7789/fireware/cmsis/device/startup_stm32f40_41xxx.s
|
;******************** (C) COPYRIGHT 2016 STMicroelectronics ********************
;* File Name : startup_stm32f40_41xxx.s
;* Author : MCD Application Team
;* @version : V1.8.0
;* @date : 09-November-2016
;* Description : STM32F40xxx/41xxx devices vector table for MDK-ARM toolchain.
;* This module performs:
;* - Set the initial SP
;* - Set the initial PC == Reset_Handler
;* - Set the vector table entries with the exceptions ISR address
;* - Configure the system clock and the external SRAM mounted on
;* STM324xG-EVAL board to be used as data memory (optional,
;* to be enabled by user)
;* - Branches to __main in the C library (which eventually
;* calls main()).
;* After Reset the CortexM4 processor is in Thread mode,
;* priority is Privileged, and the Stack is set to Main.
;* <<< Use Configuration Wizard in Context Menu >>>
;*******************************************************************************
;
; Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
; You may not use this file except in compliance with the License.
; You may obtain a copy of the License at:
;
; http://www.st.com/software_license_agreement_liberty_v2
;
; Unless required by applicable law or agreed to in writing, software
; distributed under the License is distributed on an "AS IS" BASIS,
; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
; See the License for the specific language governing permissions and
; limitations under the License.
;
;*******************************************************************************
; Amount of memory (in bytes) allocated for Stack
; Tailor this value to your application needs
; <h> Stack Configuration
; <o> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
; </h>
Stack_Size EQU 0x00000400
AREA STACK, NOINIT, READWRITE, ALIGN=3
Stack_Mem SPACE Stack_Size
__initial_sp
; <h> Heap Configuration
; <o> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
; </h>
Heap_Size EQU 0x00000200
AREA HEAP, NOINIT, READWRITE, ALIGN=3
__heap_base
Heap_Mem SPACE Heap_Size
__heap_limit
PRESERVE8
THUMB
; Vector Table Mapped to Address 0 at Reset
AREA RESET, DATA, READONLY
EXPORT __Vectors
EXPORT __Vectors_End
EXPORT __Vectors_Size
__Vectors DCD __initial_sp ; Top of Stack
DCD Reset_Handler ; Reset Handler
DCD NMI_Handler ; NMI Handler
DCD HardFault_Handler ; Hard Fault Handler
DCD MemManage_Handler ; MPU Fault Handler
DCD BusFault_Handler ; Bus Fault Handler
DCD UsageFault_Handler ; Usage Fault Handler
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD SVC_Handler ; SVCall Handler
DCD DebugMon_Handler ; Debug Monitor Handler
DCD 0 ; Reserved
DCD PendSV_Handler ; PendSV Handler
DCD SysTick_Handler ; SysTick Handler
; External Interrupts
DCD WWDG_IRQHandler ; Window WatchDog
DCD PVD_IRQHandler ; PVD through EXTI Line detection
DCD TAMP_STAMP_IRQHandler ; Tamper and TimeStamps through the EXTI line
DCD RTC_WKUP_IRQHandler ; RTC Wakeup through the EXTI line
DCD FLASH_IRQHandler ; FLASH
DCD RCC_IRQHandler ; RCC
DCD EXTI0_IRQHandler ; EXTI Line0
DCD EXTI1_IRQHandler ; EXTI Line1
DCD EXTI2_IRQHandler ; EXTI Line2
DCD EXTI3_IRQHandler ; EXTI Line3
DCD EXTI4_IRQHandler ; EXTI Line4
DCD DMA1_Stream0_IRQHandler ; DMA1 Stream 0
DCD DMA1_Stream1_IRQHandler ; DMA1 Stream 1
DCD DMA1_Stream2_IRQHandler ; DMA1 Stream 2
DCD DMA1_Stream3_IRQHandler ; DMA1 Stream 3
DCD DMA1_Stream4_IRQHandler ; DMA1 Stream 4
DCD DMA1_Stream5_IRQHandler ; DMA1 Stream 5
DCD DMA1_Stream6_IRQHandler ; DMA1 Stream 6
DCD ADC_IRQHandler ; ADC1, ADC2 and ADC3s
DCD CAN1_TX_IRQHandler ; CAN1 TX
DCD CAN1_RX0_IRQHandler ; CAN1 RX0
DCD CAN1_RX1_IRQHandler ; CAN1 RX1
DCD CAN1_SCE_IRQHandler ; CAN1 SCE
DCD EXTI9_5_IRQHandler ; External Line[9:5]s
DCD TIM1_BRK_TIM9_IRQHandler ; TIM1 Break and TIM9
DCD TIM1_UP_TIM10_IRQHandler ; TIM1 Update and TIM10
DCD TIM1_TRG_COM_TIM11_IRQHandler ; TIM1 Trigger and Commutation and TIM11
DCD TIM1_CC_IRQHandler ; TIM1 Capture Compare
DCD TIM2_IRQHandler ; TIM2
DCD TIM3_IRQHandler ; TIM3
DCD TIM4_IRQHandler ; TIM4
DCD I2C1_EV_IRQHandler ; I2C1 Event
DCD I2C1_ER_IRQHandler ; I2C1 Error
DCD I2C2_EV_IRQHandler ; I2C2 Event
DCD I2C2_ER_IRQHandler ; I2C2 Error
DCD SPI1_IRQHandler ; SPI1
DCD SPI2_IRQHandler ; SPI2
DCD USART1_IRQHandler ; USART1
DCD USART2_IRQHandler ; USART2
DCD USART3_IRQHandler ; USART3
DCD EXTI15_10_IRQHandler ; External Line[15:10]s
DCD RTC_Alarm_IRQHandler ; RTC Alarm (A and B) through EXTI Line
DCD OTG_FS_WKUP_IRQHandler ; USB OTG FS Wakeup through EXTI line
DCD TIM8_BRK_TIM12_IRQHandler ; TIM8 Break and TIM12
DCD TIM8_UP_TIM13_IRQHandler ; TIM8 Update and TIM13
DCD TIM8_TRG_COM_TIM14_IRQHandler ; TIM8 Trigger and Commutation and TIM14
DCD TIM8_CC_IRQHandler ; TIM8 Capture Compare
DCD DMA1_Stream7_IRQHandler ; DMA1 Stream7
DCD FSMC_IRQHandler ; FSMC
DCD SDIO_IRQHandler ; SDIO
DCD TIM5_IRQHandler ; TIM5
DCD SPI3_IRQHandler ; SPI3
DCD UART4_IRQHandler ; UART4
DCD UART5_IRQHandler ; UART5
DCD TIM6_DAC_IRQHandler ; TIM6 and DAC1&2 underrun errors
DCD TIM7_IRQHandler ; TIM7
DCD DMA2_Stream0_IRQHandler ; DMA2 Stream 0
DCD DMA2_Stream1_IRQHandler ; DMA2 Stream 1
DCD DMA2_Stream2_IRQHandler ; DMA2 Stream 2
DCD DMA2_Stream3_IRQHandler ; DMA2 Stream 3
DCD DMA2_Stream4_IRQHandler ; DMA2 Stream 4
DCD ETH_IRQHandler ; Ethernet
DCD ETH_WKUP_IRQHandler ; Ethernet Wakeup through EXTI line
DCD CAN2_TX_IRQHandler ; CAN2 TX
DCD CAN2_RX0_IRQHandler ; CAN2 RX0
DCD CAN2_RX1_IRQHandler ; CAN2 RX1
DCD CAN2_SCE_IRQHandler ; CAN2 SCE
DCD OTG_FS_IRQHandler ; USB OTG FS
DCD DMA2_Stream5_IRQHandler ; DMA2 Stream 5
DCD DMA2_Stream6_IRQHandler ; DMA2 Stream 6
DCD DMA2_Stream7_IRQHandler ; DMA2 Stream 7
DCD USART6_IRQHandler ; USART6
DCD I2C3_EV_IRQHandler ; I2C3 event
DCD I2C3_ER_IRQHandler ; I2C3 error
DCD OTG_HS_EP1_OUT_IRQHandler ; USB OTG HS End Point 1 Out
DCD OTG_HS_EP1_IN_IRQHandler ; USB OTG HS End Point 1 In
DCD OTG_HS_WKUP_IRQHandler ; USB OTG HS Wakeup through EXTI
DCD OTG_HS_IRQHandler ; USB OTG HS
DCD DCMI_IRQHandler ; DCMI
DCD CRYP_IRQHandler ; CRYP crypto
DCD HASH_RNG_IRQHandler ; Hash and Rng
DCD FPU_IRQHandler ; FPU
__Vectors_End
__Vectors_Size EQU __Vectors_End - __Vectors
AREA |.text|, CODE, READONLY
; Reset handler
Reset_Handler PROC
EXPORT Reset_Handler [WEAK]
IMPORT SystemInit
IMPORT __main
LDR R0, =SystemInit
BLX R0
LDR R0, =__main
BX R0
ENDP
; Dummy Exception Handlers (infinite loops which can be modified)
NMI_Handler PROC
EXPORT NMI_Handler [WEAK]
B .
ENDP
HardFault_Handler\
PROC
EXPORT HardFault_Handler [WEAK]
B .
ENDP
MemManage_Handler\
PROC
EXPORT MemManage_Handler [WEAK]
B .
ENDP
BusFault_Handler\
PROC
EXPORT BusFault_Handler [WEAK]
B .
ENDP
UsageFault_Handler\
PROC
EXPORT UsageFault_Handler [WEAK]
B .
ENDP
SVC_Handler PROC
EXPORT SVC_Handler [WEAK]
B .
ENDP
DebugMon_Handler\
PROC
EXPORT DebugMon_Handler [WEAK]
B .
ENDP
PendSV_Handler PROC
EXPORT PendSV_Handler [WEAK]
B .
ENDP
SysTick_Handler PROC
EXPORT SysTick_Handler [WEAK]
B .
ENDP
Default_Handler PROC
EXPORT WWDG_IRQHandler [WEAK]
EXPORT PVD_IRQHandler [WEAK]
EXPORT TAMP_STAMP_IRQHandler [WEAK]
EXPORT RTC_WKUP_IRQHandler [WEAK]
EXPORT FLASH_IRQHandler [WEAK]
EXPORT RCC_IRQHandler [WEAK]
EXPORT EXTI0_IRQHandler [WEAK]
EXPORT EXTI1_IRQHandler [WEAK]
EXPORT EXTI2_IRQHandler [WEAK]
EXPORT EXTI3_IRQHandler [WEAK]
EXPORT EXTI4_IRQHandler [WEAK]
EXPORT DMA1_Stream0_IRQHandler [WEAK]
EXPORT DMA1_Stream1_IRQHandler [WEAK]
EXPORT DMA1_Stream2_IRQHandler [WEAK]
EXPORT DMA1_Stream3_IRQHandler [WEAK]
EXPORT DMA1_Stream4_IRQHandler [WEAK]
EXPORT DMA1_Stream5_IRQHandler [WEAK]
EXPORT DMA1_Stream6_IRQHandler [WEAK]
EXPORT ADC_IRQHandler [WEAK]
EXPORT CAN1_TX_IRQHandler [WEAK]
EXPORT CAN1_RX0_IRQHandler [WEAK]
EXPORT CAN1_RX1_IRQHandler [WEAK]
EXPORT CAN1_SCE_IRQHandler [WEAK]
EXPORT EXTI9_5_IRQHandler [WEAK]
EXPORT TIM1_BRK_TIM9_IRQHandler [WEAK]
EXPORT TIM1_UP_TIM10_IRQHandler [WEAK]
EXPORT TIM1_TRG_COM_TIM11_IRQHandler [WEAK]
EXPORT TIM1_CC_IRQHandler [WEAK]
EXPORT TIM2_IRQHandler [WEAK]
EXPORT TIM3_IRQHandler [WEAK]
EXPORT TIM4_IRQHandler [WEAK]
EXPORT I2C1_EV_IRQHandler [WEAK]
EXPORT I2C1_ER_IRQHandler [WEAK]
EXPORT I2C2_EV_IRQHandler [WEAK]
EXPORT I2C2_ER_IRQHandler [WEAK]
EXPORT SPI1_IRQHandler [WEAK]
EXPORT SPI2_IRQHandler [WEAK]
EXPORT USART1_IRQHandler [WEAK]
EXPORT USART2_IRQHandler [WEAK]
EXPORT USART3_IRQHandler [WEAK]
EXPORT EXTI15_10_IRQHandler [WEAK]
EXPORT RTC_Alarm_IRQHandler [WEAK]
EXPORT OTG_FS_WKUP_IRQHandler [WEAK]
EXPORT TIM8_BRK_TIM12_IRQHandler [WEAK]
EXPORT TIM8_UP_TIM13_IRQHandler [WEAK]
EXPORT TIM8_TRG_COM_TIM14_IRQHandler [WEAK]
EXPORT TIM8_CC_IRQHandler [WEAK]
EXPORT DMA1_Stream7_IRQHandler [WEAK]
EXPORT FSMC_IRQHandler [WEAK]
EXPORT SDIO_IRQHandler [WEAK]
EXPORT TIM5_IRQHandler [WEAK]
EXPORT SPI3_IRQHandler [WEAK]
EXPORT UART4_IRQHandler [WEAK]
EXPORT UART5_IRQHandler [WEAK]
EXPORT TIM6_DAC_IRQHandler [WEAK]
EXPORT TIM7_IRQHandler [WEAK]
EXPORT DMA2_Stream0_IRQHandler [WEAK]
EXPORT DMA2_Stream1_IRQHandler [WEAK]
EXPORT DMA2_Stream2_IRQHandler [WEAK]
EXPORT DMA2_Stream3_IRQHandler [WEAK]
EXPORT DMA2_Stream4_IRQHandler [WEAK]
EXPORT ETH_IRQHandler [WEAK]
EXPORT ETH_WKUP_IRQHandler [WEAK]
EXPORT CAN2_TX_IRQHandler [WEAK]
EXPORT CAN2_RX0_IRQHandler [WEAK]
EXPORT CAN2_RX1_IRQHandler [WEAK]
EXPORT CAN2_SCE_IRQHandler [WEAK]
EXPORT OTG_FS_IRQHandler [WEAK]
EXPORT DMA2_Stream5_IRQHandler [WEAK]
EXPORT DMA2_Stream6_IRQHandler [WEAK]
EXPORT DMA2_Stream7_IRQHandler [WEAK]
EXPORT USART6_IRQHandler [WEAK]
EXPORT I2C3_EV_IRQHandler [WEAK]
EXPORT I2C3_ER_IRQHandler [WEAK]
EXPORT OTG_HS_EP1_OUT_IRQHandler [WEAK]
EXPORT OTG_HS_EP1_IN_IRQHandler [WEAK]
EXPORT OTG_HS_WKUP_IRQHandler [WEAK]
EXPORT OTG_HS_IRQHandler [WEAK]
EXPORT DCMI_IRQHandler [WEAK]
EXPORT CRYP_IRQHandler [WEAK]
EXPORT HASH_RNG_IRQHandler [WEAK]
EXPORT FPU_IRQHandler [WEAK]
WWDG_IRQHandler
PVD_IRQHandler
TAMP_STAMP_IRQHandler
RTC_WKUP_IRQHandler
FLASH_IRQHandler
RCC_IRQHandler
EXTI0_IRQHandler
EXTI1_IRQHandler
EXTI2_IRQHandler
EXTI3_IRQHandler
EXTI4_IRQHandler
DMA1_Stream0_IRQHandler
DMA1_Stream1_IRQHandler
DMA1_Stream2_IRQHandler
DMA1_Stream3_IRQHandler
DMA1_Stream4_IRQHandler
DMA1_Stream5_IRQHandler
DMA1_Stream6_IRQHandler
ADC_IRQHandler
CAN1_TX_IRQHandler
CAN1_RX0_IRQHandler
CAN1_RX1_IRQHandler
CAN1_SCE_IRQHandler
EXTI9_5_IRQHandler
TIM1_BRK_TIM9_IRQHandler
TIM1_UP_TIM10_IRQHandler
TIM1_TRG_COM_TIM11_IRQHandler
TIM1_CC_IRQHandler
TIM2_IRQHandler
TIM3_IRQHandler
TIM4_IRQHandler
I2C1_EV_IRQHandler
I2C1_ER_IRQHandler
I2C2_EV_IRQHandler
I2C2_ER_IRQHandler
SPI1_IRQHandler
SPI2_IRQHandler
USART1_IRQHandler
USART2_IRQHandler
USART3_IRQHandler
EXTI15_10_IRQHandler
RTC_Alarm_IRQHandler
OTG_FS_WKUP_IRQHandler
TIM8_BRK_TIM12_IRQHandler
TIM8_UP_TIM13_IRQHandler
TIM8_TRG_COM_TIM14_IRQHandler
TIM8_CC_IRQHandler
DMA1_Stream7_IRQHandler
FSMC_IRQHandler
SDIO_IRQHandler
TIM5_IRQHandler
SPI3_IRQHandler
UART4_IRQHandler
UART5_IRQHandler
TIM6_DAC_IRQHandler
TIM7_IRQHandler
DMA2_Stream0_IRQHandler
DMA2_Stream1_IRQHandler
DMA2_Stream2_IRQHandler
DMA2_Stream3_IRQHandler
DMA2_Stream4_IRQHandler
ETH_IRQHandler
ETH_WKUP_IRQHandler
CAN2_TX_IRQHandler
CAN2_RX0_IRQHandler
CAN2_RX1_IRQHandler
CAN2_SCE_IRQHandler
OTG_FS_IRQHandler
DMA2_Stream5_IRQHandler
DMA2_Stream6_IRQHandler
DMA2_Stream7_IRQHandler
USART6_IRQHandler
I2C3_EV_IRQHandler
I2C3_ER_IRQHandler
OTG_HS_EP1_OUT_IRQHandler
OTG_HS_EP1_IN_IRQHandler
OTG_HS_WKUP_IRQHandler
OTG_HS_IRQHandler
DCMI_IRQHandler
CRYP_IRQHandler
HASH_RNG_IRQHandler
FPU_IRQHandler
B .
ENDP
ALIGN
;*******************************************************************************
; User Stack and Heap initialization
;*******************************************************************************
IF :DEF:__MICROLIB
EXPORT __initial_sp
EXPORT __heap_base
EXPORT __heap_limit
ELSE
IMPORT __use_two_region_memory
EXPORT __user_initial_stackheap
__user_initial_stackheap
LDR R0, = Heap_Mem
LDR R1, =(Stack_Mem + Stack_Size)
LDR R2, = (Heap_Mem + Heap_Size)
LDR R3, = Stack_Mem
BX LR
ALIGN
ENDIF
END
;************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE*****
|
8MiYile/LSPatch-OP
| 1,077
|
core/external/dobby/source/TrampolineBridge/ClosureTrampolineBridge/arm/dummy/closure-trampoline-template-arm.S
|
// .section __TEXT,__text,regular,pure_instructions
#if defined(ENABLE_CLOSURE_BRIDGE_TEMPLATE)
#if defined(__WIN32__) || defined(__APPLE__)
#define cdecl(s) _##s
#else
#define cdecl(s) s
#endif
.align 4
#if !defined(ENABLE_CLOSURE_TRAMPOLINE_CARRY_OBJECT_PTR)
// closure trampoline carray the object pointer, and fetch required members at the runtime assembly code.
// #include "TrampolineBridge/ClosureTrampolineBridge/ClosureTrampoline.h"
// #define OFFSETOF(TYPE, ELEMENT) ((size_t)&(((TYPE *)0)->ELEMENT))
#define OFFSETOF_ClourseTrampolineEntry_carry_data 4
#define OFFSETOF_ClourseTrampolineEntry_carry_handler 0
.globl cdecl(closure_trampoline_template)
cdecl(closure_trampoline_template):
ldr r12, ClourseTrampolineEntryPtr
ldr pc, [r12, #0]
ClourseTrampolineEntryPtr:
.long 0
#else
; closure trampoline just carray the required members from the object.
.globl cdecl(closure_trampoline_template)
cdecl(closure_trampoline_template):
ldr r12, =carry_data
ldr pc, =carry_handler
carry_data:
.long 0
carry_handler:
.long 0
#endif
#endif
|
8MiYile/LSPatch-OP
| 1,230
|
core/external/dobby/source/TrampolineBridge/ClosureTrampolineBridge/arm64/dummy/closure-trampoline-template-arm64.S
|
// .section __TEXT,__text,regular,pure_instructions
#if defined(ENABLE_CLOSURE_BRIDGE_TEMPLATE)
#if defined(__WIN32__) || defined(__APPLE__)
#define cdecl(s) _##s
#else
#define cdecl(s) s
#endif
.align 4
#if !defined(ENABLE_CLOSURE_TRAMPOLINE_CARRY_OBJECT_PTR)
// closure trampoline carray the object pointer, and fetch required members at the runtime assembly code.
// #include "TrampolineBridge/ClosureTrampolineBridge/ClosureTrampoline.h"
// #define OFFSETOF(TYPE, ELEMENT) ((size_t)&(((TYPE *)0)->ELEMENT))
#define OFFSETOF_ClourseTrampolineEntry_carry_data 8
#define OFFSETOF_ClourseTrampolineEntry_carry_handler 0
.globl cdecl(closure_trampoline_template)
cdecl(closure_trampoline_template):
ldr x17, ClourseTrampolineEntryPtr
ldr x16, OFFSETOF_ClourseTrampolineEntry_carry_data
ldr x17, OFFSETOF_ClourseTrampolineEntry_carry_handler
br x17
ClourseTrampolineEntryPtr:
.long 0
.long 0
#else
; closure trampoline just carray the required members from the object.
.globl cdecl(closure_trampoline_template)
cdecl(closure_trampoline_template):
ldr x16, =carry_data
ldr x17, =carry_handler
br x17
carry_data:
.long 0
.long 0
carry_handler:
.long 0
.long 0
#endif
#endif
|
903257958/stm32_oop_driver
| 29,173
|
stm32f405rg_drivers/stm32f405rg_i2c_soft_eeprom/firmware/cmsis/device/startup_stm32f40_41xxx.s
|
;******************** (C) COPYRIGHT 2016 STMicroelectronics ********************
;* File Name : startup_stm32f40_41xxx.s
;* Author : MCD Application Team
;* @version : V1.8.0
;* @date : 09-November-2016
;* Description : STM32F40xxx/41xxx devices vector table for MDK-ARM toolchain.
;* This module performs:
;* - Set the initial SP
;* - Set the initial PC == Reset_Handler
;* - Set the vector table entries with the exceptions ISR address
;* - Configure the system clock and the external SRAM mounted on
;* STM324xG-EVAL board to be used as data memory (optional,
;* to be enabled by user)
;* - Branches to __main in the C library (which eventually
;* calls main()).
;* After Reset the CortexM4 processor is in Thread mode,
;* priority is Privileged, and the Stack is set to Main.
;* <<< Use Configuration Wizard in Context Menu >>>
;*******************************************************************************
;
; Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
; You may not use this file except in compliance with the License.
; You may obtain a copy of the License at:
;
; http://www.st.com/software_license_agreement_liberty_v2
;
; Unless required by applicable law or agreed to in writing, software
; distributed under the License is distributed on an "AS IS" BASIS,
; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
; See the License for the specific language governing permissions and
; limitations under the License.
;
;*******************************************************************************
; Amount of memory (in bytes) allocated for Stack
; Tailor this value to your application needs
; <h> Stack Configuration
; <o> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
; </h>
Stack_Size EQU 0x00000400
AREA STACK, NOINIT, READWRITE, ALIGN=3
Stack_Mem SPACE Stack_Size
__initial_sp
; <h> Heap Configuration
; <o> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
; </h>
Heap_Size EQU 0x00000200
AREA HEAP, NOINIT, READWRITE, ALIGN=3
__heap_base
Heap_Mem SPACE Heap_Size
__heap_limit
PRESERVE8
THUMB
; Vector Table Mapped to Address 0 at Reset
AREA RESET, DATA, READONLY
EXPORT __Vectors
EXPORT __Vectors_End
EXPORT __Vectors_Size
__Vectors DCD __initial_sp ; Top of Stack
DCD Reset_Handler ; Reset Handler
DCD NMI_Handler ; NMI Handler
DCD HardFault_Handler ; Hard Fault Handler
DCD MemManage_Handler ; MPU Fault Handler
DCD BusFault_Handler ; Bus Fault Handler
DCD UsageFault_Handler ; Usage Fault Handler
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD SVC_Handler ; SVCall Handler
DCD DebugMon_Handler ; Debug Monitor Handler
DCD 0 ; Reserved
DCD PendSV_Handler ; PendSV Handler
DCD SysTick_Handler ; SysTick Handler
; External Interrupts
DCD WWDG_IRQHandler ; Window WatchDog
DCD PVD_IRQHandler ; PVD through EXTI Line detection
DCD TAMP_STAMP_IRQHandler ; Tamper and TimeStamps through the EXTI line
DCD RTC_WKUP_IRQHandler ; RTC Wakeup through the EXTI line
DCD FLASH_IRQHandler ; FLASH
DCD RCC_IRQHandler ; RCC
DCD EXTI0_IRQHandler ; EXTI Line0
DCD EXTI1_IRQHandler ; EXTI Line1
DCD EXTI2_IRQHandler ; EXTI Line2
DCD EXTI3_IRQHandler ; EXTI Line3
DCD EXTI4_IRQHandler ; EXTI Line4
DCD DMA1_Stream0_IRQHandler ; DMA1 Stream 0
DCD DMA1_Stream1_IRQHandler ; DMA1 Stream 1
DCD DMA1_Stream2_IRQHandler ; DMA1 Stream 2
DCD DMA1_Stream3_IRQHandler ; DMA1 Stream 3
DCD DMA1_Stream4_IRQHandler ; DMA1 Stream 4
DCD DMA1_Stream5_IRQHandler ; DMA1 Stream 5
DCD DMA1_Stream6_IRQHandler ; DMA1 Stream 6
DCD ADC_IRQHandler ; ADC1, ADC2 and ADC3s
DCD CAN1_TX_IRQHandler ; CAN1 TX
DCD CAN1_RX0_IRQHandler ; CAN1 RX0
DCD CAN1_RX1_IRQHandler ; CAN1 RX1
DCD CAN1_SCE_IRQHandler ; CAN1 SCE
DCD EXTI9_5_IRQHandler ; External Line[9:5]s
DCD TIM1_BRK_TIM9_IRQHandler ; TIM1 Break and TIM9
DCD TIM1_UP_TIM10_IRQHandler ; TIM1 Update and TIM10
DCD TIM1_TRG_COM_TIM11_IRQHandler ; TIM1 Trigger and Commutation and TIM11
DCD TIM1_CC_IRQHandler ; TIM1 Capture Compare
DCD TIM2_IRQHandler ; TIM2
DCD TIM3_IRQHandler ; TIM3
DCD TIM4_IRQHandler ; TIM4
DCD I2C1_EV_IRQHandler ; I2C1 Event
DCD I2C1_ER_IRQHandler ; I2C1 Error
DCD I2C2_EV_IRQHandler ; I2C2 Event
DCD I2C2_ER_IRQHandler ; I2C2 Error
DCD SPI1_IRQHandler ; SPI1
DCD SPI2_IRQHandler ; SPI2
DCD USART1_IRQHandler ; USART1
DCD USART2_IRQHandler ; USART2
DCD USART3_IRQHandler ; USART3
DCD EXTI15_10_IRQHandler ; External Line[15:10]s
DCD RTC_Alarm_IRQHandler ; RTC Alarm (A and B) through EXTI Line
DCD OTG_FS_WKUP_IRQHandler ; USB OTG FS Wakeup through EXTI line
DCD TIM8_BRK_TIM12_IRQHandler ; TIM8 Break and TIM12
DCD TIM8_UP_TIM13_IRQHandler ; TIM8 Update and TIM13
DCD TIM8_TRG_COM_TIM14_IRQHandler ; TIM8 Trigger and Commutation and TIM14
DCD TIM8_CC_IRQHandler ; TIM8 Capture Compare
DCD DMA1_Stream7_IRQHandler ; DMA1 Stream7
DCD FSMC_IRQHandler ; FSMC
DCD SDIO_IRQHandler ; SDIO
DCD TIM5_IRQHandler ; TIM5
DCD SPI3_IRQHandler ; SPI3
DCD UART4_IRQHandler ; UART4
DCD UART5_IRQHandler ; UART5
DCD TIM6_DAC_IRQHandler ; TIM6 and DAC1&2 underrun errors
DCD TIM7_IRQHandler ; TIM7
DCD DMA2_Stream0_IRQHandler ; DMA2 Stream 0
DCD DMA2_Stream1_IRQHandler ; DMA2 Stream 1
DCD DMA2_Stream2_IRQHandler ; DMA2 Stream 2
DCD DMA2_Stream3_IRQHandler ; DMA2 Stream 3
DCD DMA2_Stream4_IRQHandler ; DMA2 Stream 4
DCD ETH_IRQHandler ; Ethernet
DCD ETH_WKUP_IRQHandler ; Ethernet Wakeup through EXTI line
DCD CAN2_TX_IRQHandler ; CAN2 TX
DCD CAN2_RX0_IRQHandler ; CAN2 RX0
DCD CAN2_RX1_IRQHandler ; CAN2 RX1
DCD CAN2_SCE_IRQHandler ; CAN2 SCE
DCD OTG_FS_IRQHandler ; USB OTG FS
DCD DMA2_Stream5_IRQHandler ; DMA2 Stream 5
DCD DMA2_Stream6_IRQHandler ; DMA2 Stream 6
DCD DMA2_Stream7_IRQHandler ; DMA2 Stream 7
DCD USART6_IRQHandler ; USART6
DCD I2C3_EV_IRQHandler ; I2C3 event
DCD I2C3_ER_IRQHandler ; I2C3 error
DCD OTG_HS_EP1_OUT_IRQHandler ; USB OTG HS End Point 1 Out
DCD OTG_HS_EP1_IN_IRQHandler ; USB OTG HS End Point 1 In
DCD OTG_HS_WKUP_IRQHandler ; USB OTG HS Wakeup through EXTI
DCD OTG_HS_IRQHandler ; USB OTG HS
DCD DCMI_IRQHandler ; DCMI
DCD CRYP_IRQHandler ; CRYP crypto
DCD HASH_RNG_IRQHandler ; Hash and Rng
DCD FPU_IRQHandler ; FPU
__Vectors_End
__Vectors_Size EQU __Vectors_End - __Vectors
AREA |.text|, CODE, READONLY
; Reset handler
Reset_Handler PROC
EXPORT Reset_Handler [WEAK]
IMPORT SystemInit
IMPORT __main
LDR R0, =SystemInit
BLX R0
LDR R0, =__main
BX R0
ENDP
; Dummy Exception Handlers (infinite loops which can be modified)
NMI_Handler PROC
EXPORT NMI_Handler [WEAK]
B .
ENDP
HardFault_Handler\
PROC
EXPORT HardFault_Handler [WEAK]
B .
ENDP
MemManage_Handler\
PROC
EXPORT MemManage_Handler [WEAK]
B .
ENDP
BusFault_Handler\
PROC
EXPORT BusFault_Handler [WEAK]
B .
ENDP
UsageFault_Handler\
PROC
EXPORT UsageFault_Handler [WEAK]
B .
ENDP
SVC_Handler PROC
EXPORT SVC_Handler [WEAK]
B .
ENDP
DebugMon_Handler\
PROC
EXPORT DebugMon_Handler [WEAK]
B .
ENDP
PendSV_Handler PROC
EXPORT PendSV_Handler [WEAK]
B .
ENDP
SysTick_Handler PROC
EXPORT SysTick_Handler [WEAK]
B .
ENDP
Default_Handler PROC
EXPORT WWDG_IRQHandler [WEAK]
EXPORT PVD_IRQHandler [WEAK]
EXPORT TAMP_STAMP_IRQHandler [WEAK]
EXPORT RTC_WKUP_IRQHandler [WEAK]
EXPORT FLASH_IRQHandler [WEAK]
EXPORT RCC_IRQHandler [WEAK]
EXPORT EXTI0_IRQHandler [WEAK]
EXPORT EXTI1_IRQHandler [WEAK]
EXPORT EXTI2_IRQHandler [WEAK]
EXPORT EXTI3_IRQHandler [WEAK]
EXPORT EXTI4_IRQHandler [WEAK]
EXPORT DMA1_Stream0_IRQHandler [WEAK]
EXPORT DMA1_Stream1_IRQHandler [WEAK]
EXPORT DMA1_Stream2_IRQHandler [WEAK]
EXPORT DMA1_Stream3_IRQHandler [WEAK]
EXPORT DMA1_Stream4_IRQHandler [WEAK]
EXPORT DMA1_Stream5_IRQHandler [WEAK]
EXPORT DMA1_Stream6_IRQHandler [WEAK]
EXPORT ADC_IRQHandler [WEAK]
EXPORT CAN1_TX_IRQHandler [WEAK]
EXPORT CAN1_RX0_IRQHandler [WEAK]
EXPORT CAN1_RX1_IRQHandler [WEAK]
EXPORT CAN1_SCE_IRQHandler [WEAK]
EXPORT EXTI9_5_IRQHandler [WEAK]
EXPORT TIM1_BRK_TIM9_IRQHandler [WEAK]
EXPORT TIM1_UP_TIM10_IRQHandler [WEAK]
EXPORT TIM1_TRG_COM_TIM11_IRQHandler [WEAK]
EXPORT TIM1_CC_IRQHandler [WEAK]
EXPORT TIM2_IRQHandler [WEAK]
EXPORT TIM3_IRQHandler [WEAK]
EXPORT TIM4_IRQHandler [WEAK]
EXPORT I2C1_EV_IRQHandler [WEAK]
EXPORT I2C1_ER_IRQHandler [WEAK]
EXPORT I2C2_EV_IRQHandler [WEAK]
EXPORT I2C2_ER_IRQHandler [WEAK]
EXPORT SPI1_IRQHandler [WEAK]
EXPORT SPI2_IRQHandler [WEAK]
EXPORT USART1_IRQHandler [WEAK]
EXPORT USART2_IRQHandler [WEAK]
EXPORT USART3_IRQHandler [WEAK]
EXPORT EXTI15_10_IRQHandler [WEAK]
EXPORT RTC_Alarm_IRQHandler [WEAK]
EXPORT OTG_FS_WKUP_IRQHandler [WEAK]
EXPORT TIM8_BRK_TIM12_IRQHandler [WEAK]
EXPORT TIM8_UP_TIM13_IRQHandler [WEAK]
EXPORT TIM8_TRG_COM_TIM14_IRQHandler [WEAK]
EXPORT TIM8_CC_IRQHandler [WEAK]
EXPORT DMA1_Stream7_IRQHandler [WEAK]
EXPORT FSMC_IRQHandler [WEAK]
EXPORT SDIO_IRQHandler [WEAK]
EXPORT TIM5_IRQHandler [WEAK]
EXPORT SPI3_IRQHandler [WEAK]
EXPORT UART4_IRQHandler [WEAK]
EXPORT UART5_IRQHandler [WEAK]
EXPORT TIM6_DAC_IRQHandler [WEAK]
EXPORT TIM7_IRQHandler [WEAK]
EXPORT DMA2_Stream0_IRQHandler [WEAK]
EXPORT DMA2_Stream1_IRQHandler [WEAK]
EXPORT DMA2_Stream2_IRQHandler [WEAK]
EXPORT DMA2_Stream3_IRQHandler [WEAK]
EXPORT DMA2_Stream4_IRQHandler [WEAK]
EXPORT ETH_IRQHandler [WEAK]
EXPORT ETH_WKUP_IRQHandler [WEAK]
EXPORT CAN2_TX_IRQHandler [WEAK]
EXPORT CAN2_RX0_IRQHandler [WEAK]
EXPORT CAN2_RX1_IRQHandler [WEAK]
EXPORT CAN2_SCE_IRQHandler [WEAK]
EXPORT OTG_FS_IRQHandler [WEAK]
EXPORT DMA2_Stream5_IRQHandler [WEAK]
EXPORT DMA2_Stream6_IRQHandler [WEAK]
EXPORT DMA2_Stream7_IRQHandler [WEAK]
EXPORT USART6_IRQHandler [WEAK]
EXPORT I2C3_EV_IRQHandler [WEAK]
EXPORT I2C3_ER_IRQHandler [WEAK]
EXPORT OTG_HS_EP1_OUT_IRQHandler [WEAK]
EXPORT OTG_HS_EP1_IN_IRQHandler [WEAK]
EXPORT OTG_HS_WKUP_IRQHandler [WEAK]
EXPORT OTG_HS_IRQHandler [WEAK]
EXPORT DCMI_IRQHandler [WEAK]
EXPORT CRYP_IRQHandler [WEAK]
EXPORT HASH_RNG_IRQHandler [WEAK]
EXPORT FPU_IRQHandler [WEAK]
WWDG_IRQHandler
PVD_IRQHandler
TAMP_STAMP_IRQHandler
RTC_WKUP_IRQHandler
FLASH_IRQHandler
RCC_IRQHandler
EXTI0_IRQHandler
EXTI1_IRQHandler
EXTI2_IRQHandler
EXTI3_IRQHandler
EXTI4_IRQHandler
DMA1_Stream0_IRQHandler
DMA1_Stream1_IRQHandler
DMA1_Stream2_IRQHandler
DMA1_Stream3_IRQHandler
DMA1_Stream4_IRQHandler
DMA1_Stream5_IRQHandler
DMA1_Stream6_IRQHandler
ADC_IRQHandler
CAN1_TX_IRQHandler
CAN1_RX0_IRQHandler
CAN1_RX1_IRQHandler
CAN1_SCE_IRQHandler
EXTI9_5_IRQHandler
TIM1_BRK_TIM9_IRQHandler
TIM1_UP_TIM10_IRQHandler
TIM1_TRG_COM_TIM11_IRQHandler
TIM1_CC_IRQHandler
TIM2_IRQHandler
TIM3_IRQHandler
TIM4_IRQHandler
I2C1_EV_IRQHandler
I2C1_ER_IRQHandler
I2C2_EV_IRQHandler
I2C2_ER_IRQHandler
SPI1_IRQHandler
SPI2_IRQHandler
USART1_IRQHandler
USART2_IRQHandler
USART3_IRQHandler
EXTI15_10_IRQHandler
RTC_Alarm_IRQHandler
OTG_FS_WKUP_IRQHandler
TIM8_BRK_TIM12_IRQHandler
TIM8_UP_TIM13_IRQHandler
TIM8_TRG_COM_TIM14_IRQHandler
TIM8_CC_IRQHandler
DMA1_Stream7_IRQHandler
FSMC_IRQHandler
SDIO_IRQHandler
TIM5_IRQHandler
SPI3_IRQHandler
UART4_IRQHandler
UART5_IRQHandler
TIM6_DAC_IRQHandler
TIM7_IRQHandler
DMA2_Stream0_IRQHandler
DMA2_Stream1_IRQHandler
DMA2_Stream2_IRQHandler
DMA2_Stream3_IRQHandler
DMA2_Stream4_IRQHandler
ETH_IRQHandler
ETH_WKUP_IRQHandler
CAN2_TX_IRQHandler
CAN2_RX0_IRQHandler
CAN2_RX1_IRQHandler
CAN2_SCE_IRQHandler
OTG_FS_IRQHandler
DMA2_Stream5_IRQHandler
DMA2_Stream6_IRQHandler
DMA2_Stream7_IRQHandler
USART6_IRQHandler
I2C3_EV_IRQHandler
I2C3_ER_IRQHandler
OTG_HS_EP1_OUT_IRQHandler
OTG_HS_EP1_IN_IRQHandler
OTG_HS_WKUP_IRQHandler
OTG_HS_IRQHandler
DCMI_IRQHandler
CRYP_IRQHandler
HASH_RNG_IRQHandler
FPU_IRQHandler
B .
ENDP
ALIGN
;*******************************************************************************
; User Stack and Heap initialization
;*******************************************************************************
IF :DEF:__MICROLIB
EXPORT __initial_sp
EXPORT __heap_base
EXPORT __heap_limit
ELSE
IMPORT __use_two_region_memory
EXPORT __user_initial_stackheap
__user_initial_stackheap
LDR R0, = Heap_Mem
LDR R1, =(Stack_Mem + Stack_Size)
LDR R2, = (Heap_Mem + Heap_Size)
LDR R3, = Stack_Mem
BX LR
ALIGN
ENDIF
END
;************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE*****
|
903257958/stm32_oop_driver
| 29,173
|
stm32f405rg_drivers/stm32f405rg_vibration_motor/firmware/cmsis/device/startup_stm32f40_41xxx.s
|
;******************** (C) COPYRIGHT 2016 STMicroelectronics ********************
;* File Name : startup_stm32f40_41xxx.s
;* Author : MCD Application Team
;* @version : V1.8.0
;* @date : 09-November-2016
;* Description : STM32F40xxx/41xxx devices vector table for MDK-ARM toolchain.
;* This module performs:
;* - Set the initial SP
;* - Set the initial PC == Reset_Handler
;* - Set the vector table entries with the exceptions ISR address
;* - Configure the system clock and the external SRAM mounted on
;* STM324xG-EVAL board to be used as data memory (optional,
;* to be enabled by user)
;* - Branches to __main in the C library (which eventually
;* calls main()).
;* After Reset the CortexM4 processor is in Thread mode,
;* priority is Privileged, and the Stack is set to Main.
;* <<< Use Configuration Wizard in Context Menu >>>
;*******************************************************************************
;
; Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
; You may not use this file except in compliance with the License.
; You may obtain a copy of the License at:
;
; http://www.st.com/software_license_agreement_liberty_v2
;
; Unless required by applicable law or agreed to in writing, software
; distributed under the License is distributed on an "AS IS" BASIS,
; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
; See the License for the specific language governing permissions and
; limitations under the License.
;
;*******************************************************************************
; Amount of memory (in bytes) allocated for Stack
; Tailor this value to your application needs
; <h> Stack Configuration
; <o> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
; </h>
Stack_Size EQU 0x00000400
AREA STACK, NOINIT, READWRITE, ALIGN=3
Stack_Mem SPACE Stack_Size
__initial_sp
; <h> Heap Configuration
; <o> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
; </h>
Heap_Size EQU 0x00000200
AREA HEAP, NOINIT, READWRITE, ALIGN=3
__heap_base
Heap_Mem SPACE Heap_Size
__heap_limit
PRESERVE8
THUMB
; Vector Table Mapped to Address 0 at Reset
AREA RESET, DATA, READONLY
EXPORT __Vectors
EXPORT __Vectors_End
EXPORT __Vectors_Size
__Vectors DCD __initial_sp ; Top of Stack
DCD Reset_Handler ; Reset Handler
DCD NMI_Handler ; NMI Handler
DCD HardFault_Handler ; Hard Fault Handler
DCD MemManage_Handler ; MPU Fault Handler
DCD BusFault_Handler ; Bus Fault Handler
DCD UsageFault_Handler ; Usage Fault Handler
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD SVC_Handler ; SVCall Handler
DCD DebugMon_Handler ; Debug Monitor Handler
DCD 0 ; Reserved
DCD PendSV_Handler ; PendSV Handler
DCD SysTick_Handler ; SysTick Handler
; External Interrupts
DCD WWDG_IRQHandler ; Window WatchDog
DCD PVD_IRQHandler ; PVD through EXTI Line detection
DCD TAMP_STAMP_IRQHandler ; Tamper and TimeStamps through the EXTI line
DCD RTC_WKUP_IRQHandler ; RTC Wakeup through the EXTI line
DCD FLASH_IRQHandler ; FLASH
DCD RCC_IRQHandler ; RCC
DCD EXTI0_IRQHandler ; EXTI Line0
DCD EXTI1_IRQHandler ; EXTI Line1
DCD EXTI2_IRQHandler ; EXTI Line2
DCD EXTI3_IRQHandler ; EXTI Line3
DCD EXTI4_IRQHandler ; EXTI Line4
DCD DMA1_Stream0_IRQHandler ; DMA1 Stream 0
DCD DMA1_Stream1_IRQHandler ; DMA1 Stream 1
DCD DMA1_Stream2_IRQHandler ; DMA1 Stream 2
DCD DMA1_Stream3_IRQHandler ; DMA1 Stream 3
DCD DMA1_Stream4_IRQHandler ; DMA1 Stream 4
DCD DMA1_Stream5_IRQHandler ; DMA1 Stream 5
DCD DMA1_Stream6_IRQHandler ; DMA1 Stream 6
DCD ADC_IRQHandler ; ADC1, ADC2 and ADC3s
DCD CAN1_TX_IRQHandler ; CAN1 TX
DCD CAN1_RX0_IRQHandler ; CAN1 RX0
DCD CAN1_RX1_IRQHandler ; CAN1 RX1
DCD CAN1_SCE_IRQHandler ; CAN1 SCE
DCD EXTI9_5_IRQHandler ; External Line[9:5]s
DCD TIM1_BRK_TIM9_IRQHandler ; TIM1 Break and TIM9
DCD TIM1_UP_TIM10_IRQHandler ; TIM1 Update and TIM10
DCD TIM1_TRG_COM_TIM11_IRQHandler ; TIM1 Trigger and Commutation and TIM11
DCD TIM1_CC_IRQHandler ; TIM1 Capture Compare
DCD TIM2_IRQHandler ; TIM2
DCD TIM3_IRQHandler ; TIM3
DCD TIM4_IRQHandler ; TIM4
DCD I2C1_EV_IRQHandler ; I2C1 Event
DCD I2C1_ER_IRQHandler ; I2C1 Error
DCD I2C2_EV_IRQHandler ; I2C2 Event
DCD I2C2_ER_IRQHandler ; I2C2 Error
DCD SPI1_IRQHandler ; SPI1
DCD SPI2_IRQHandler ; SPI2
DCD USART1_IRQHandler ; USART1
DCD USART2_IRQHandler ; USART2
DCD USART3_IRQHandler ; USART3
DCD EXTI15_10_IRQHandler ; External Line[15:10]s
DCD RTC_Alarm_IRQHandler ; RTC Alarm (A and B) through EXTI Line
DCD OTG_FS_WKUP_IRQHandler ; USB OTG FS Wakeup through EXTI line
DCD TIM8_BRK_TIM12_IRQHandler ; TIM8 Break and TIM12
DCD TIM8_UP_TIM13_IRQHandler ; TIM8 Update and TIM13
DCD TIM8_TRG_COM_TIM14_IRQHandler ; TIM8 Trigger and Commutation and TIM14
DCD TIM8_CC_IRQHandler ; TIM8 Capture Compare
DCD DMA1_Stream7_IRQHandler ; DMA1 Stream7
DCD FSMC_IRQHandler ; FSMC
DCD SDIO_IRQHandler ; SDIO
DCD TIM5_IRQHandler ; TIM5
DCD SPI3_IRQHandler ; SPI3
DCD UART4_IRQHandler ; UART4
DCD UART5_IRQHandler ; UART5
DCD TIM6_DAC_IRQHandler ; TIM6 and DAC1&2 underrun errors
DCD TIM7_IRQHandler ; TIM7
DCD DMA2_Stream0_IRQHandler ; DMA2 Stream 0
DCD DMA2_Stream1_IRQHandler ; DMA2 Stream 1
DCD DMA2_Stream2_IRQHandler ; DMA2 Stream 2
DCD DMA2_Stream3_IRQHandler ; DMA2 Stream 3
DCD DMA2_Stream4_IRQHandler ; DMA2 Stream 4
DCD ETH_IRQHandler ; Ethernet
DCD ETH_WKUP_IRQHandler ; Ethernet Wakeup through EXTI line
DCD CAN2_TX_IRQHandler ; CAN2 TX
DCD CAN2_RX0_IRQHandler ; CAN2 RX0
DCD CAN2_RX1_IRQHandler ; CAN2 RX1
DCD CAN2_SCE_IRQHandler ; CAN2 SCE
DCD OTG_FS_IRQHandler ; USB OTG FS
DCD DMA2_Stream5_IRQHandler ; DMA2 Stream 5
DCD DMA2_Stream6_IRQHandler ; DMA2 Stream 6
DCD DMA2_Stream7_IRQHandler ; DMA2 Stream 7
DCD USART6_IRQHandler ; USART6
DCD I2C3_EV_IRQHandler ; I2C3 event
DCD I2C3_ER_IRQHandler ; I2C3 error
DCD OTG_HS_EP1_OUT_IRQHandler ; USB OTG HS End Point 1 Out
DCD OTG_HS_EP1_IN_IRQHandler ; USB OTG HS End Point 1 In
DCD OTG_HS_WKUP_IRQHandler ; USB OTG HS Wakeup through EXTI
DCD OTG_HS_IRQHandler ; USB OTG HS
DCD DCMI_IRQHandler ; DCMI
DCD CRYP_IRQHandler ; CRYP crypto
DCD HASH_RNG_IRQHandler ; Hash and Rng
DCD FPU_IRQHandler ; FPU
__Vectors_End
__Vectors_Size EQU __Vectors_End - __Vectors
AREA |.text|, CODE, READONLY
; Reset handler
Reset_Handler PROC
EXPORT Reset_Handler [WEAK]
IMPORT SystemInit
IMPORT __main
LDR R0, =SystemInit
BLX R0
LDR R0, =__main
BX R0
ENDP
; Dummy Exception Handlers (infinite loops which can be modified)
NMI_Handler PROC
EXPORT NMI_Handler [WEAK]
B .
ENDP
HardFault_Handler\
PROC
EXPORT HardFault_Handler [WEAK]
B .
ENDP
MemManage_Handler\
PROC
EXPORT MemManage_Handler [WEAK]
B .
ENDP
BusFault_Handler\
PROC
EXPORT BusFault_Handler [WEAK]
B .
ENDP
UsageFault_Handler\
PROC
EXPORT UsageFault_Handler [WEAK]
B .
ENDP
SVC_Handler PROC
EXPORT SVC_Handler [WEAK]
B .
ENDP
DebugMon_Handler\
PROC
EXPORT DebugMon_Handler [WEAK]
B .
ENDP
PendSV_Handler PROC
EXPORT PendSV_Handler [WEAK]
B .
ENDP
SysTick_Handler PROC
EXPORT SysTick_Handler [WEAK]
B .
ENDP
Default_Handler PROC
EXPORT WWDG_IRQHandler [WEAK]
EXPORT PVD_IRQHandler [WEAK]
EXPORT TAMP_STAMP_IRQHandler [WEAK]
EXPORT RTC_WKUP_IRQHandler [WEAK]
EXPORT FLASH_IRQHandler [WEAK]
EXPORT RCC_IRQHandler [WEAK]
EXPORT EXTI0_IRQHandler [WEAK]
EXPORT EXTI1_IRQHandler [WEAK]
EXPORT EXTI2_IRQHandler [WEAK]
EXPORT EXTI3_IRQHandler [WEAK]
EXPORT EXTI4_IRQHandler [WEAK]
EXPORT DMA1_Stream0_IRQHandler [WEAK]
EXPORT DMA1_Stream1_IRQHandler [WEAK]
EXPORT DMA1_Stream2_IRQHandler [WEAK]
EXPORT DMA1_Stream3_IRQHandler [WEAK]
EXPORT DMA1_Stream4_IRQHandler [WEAK]
EXPORT DMA1_Stream5_IRQHandler [WEAK]
EXPORT DMA1_Stream6_IRQHandler [WEAK]
EXPORT ADC_IRQHandler [WEAK]
EXPORT CAN1_TX_IRQHandler [WEAK]
EXPORT CAN1_RX0_IRQHandler [WEAK]
EXPORT CAN1_RX1_IRQHandler [WEAK]
EXPORT CAN1_SCE_IRQHandler [WEAK]
EXPORT EXTI9_5_IRQHandler [WEAK]
EXPORT TIM1_BRK_TIM9_IRQHandler [WEAK]
EXPORT TIM1_UP_TIM10_IRQHandler [WEAK]
EXPORT TIM1_TRG_COM_TIM11_IRQHandler [WEAK]
EXPORT TIM1_CC_IRQHandler [WEAK]
EXPORT TIM2_IRQHandler [WEAK]
EXPORT TIM3_IRQHandler [WEAK]
EXPORT TIM4_IRQHandler [WEAK]
EXPORT I2C1_EV_IRQHandler [WEAK]
EXPORT I2C1_ER_IRQHandler [WEAK]
EXPORT I2C2_EV_IRQHandler [WEAK]
EXPORT I2C2_ER_IRQHandler [WEAK]
EXPORT SPI1_IRQHandler [WEAK]
EXPORT SPI2_IRQHandler [WEAK]
EXPORT USART1_IRQHandler [WEAK]
EXPORT USART2_IRQHandler [WEAK]
EXPORT USART3_IRQHandler [WEAK]
EXPORT EXTI15_10_IRQHandler [WEAK]
EXPORT RTC_Alarm_IRQHandler [WEAK]
EXPORT OTG_FS_WKUP_IRQHandler [WEAK]
EXPORT TIM8_BRK_TIM12_IRQHandler [WEAK]
EXPORT TIM8_UP_TIM13_IRQHandler [WEAK]
EXPORT TIM8_TRG_COM_TIM14_IRQHandler [WEAK]
EXPORT TIM8_CC_IRQHandler [WEAK]
EXPORT DMA1_Stream7_IRQHandler [WEAK]
EXPORT FSMC_IRQHandler [WEAK]
EXPORT SDIO_IRQHandler [WEAK]
EXPORT TIM5_IRQHandler [WEAK]
EXPORT SPI3_IRQHandler [WEAK]
EXPORT UART4_IRQHandler [WEAK]
EXPORT UART5_IRQHandler [WEAK]
EXPORT TIM6_DAC_IRQHandler [WEAK]
EXPORT TIM7_IRQHandler [WEAK]
EXPORT DMA2_Stream0_IRQHandler [WEAK]
EXPORT DMA2_Stream1_IRQHandler [WEAK]
EXPORT DMA2_Stream2_IRQHandler [WEAK]
EXPORT DMA2_Stream3_IRQHandler [WEAK]
EXPORT DMA2_Stream4_IRQHandler [WEAK]
EXPORT ETH_IRQHandler [WEAK]
EXPORT ETH_WKUP_IRQHandler [WEAK]
EXPORT CAN2_TX_IRQHandler [WEAK]
EXPORT CAN2_RX0_IRQHandler [WEAK]
EXPORT CAN2_RX1_IRQHandler [WEAK]
EXPORT CAN2_SCE_IRQHandler [WEAK]
EXPORT OTG_FS_IRQHandler [WEAK]
EXPORT DMA2_Stream5_IRQHandler [WEAK]
EXPORT DMA2_Stream6_IRQHandler [WEAK]
EXPORT DMA2_Stream7_IRQHandler [WEAK]
EXPORT USART6_IRQHandler [WEAK]
EXPORT I2C3_EV_IRQHandler [WEAK]
EXPORT I2C3_ER_IRQHandler [WEAK]
EXPORT OTG_HS_EP1_OUT_IRQHandler [WEAK]
EXPORT OTG_HS_EP1_IN_IRQHandler [WEAK]
EXPORT OTG_HS_WKUP_IRQHandler [WEAK]
EXPORT OTG_HS_IRQHandler [WEAK]
EXPORT DCMI_IRQHandler [WEAK]
EXPORT CRYP_IRQHandler [WEAK]
EXPORT HASH_RNG_IRQHandler [WEAK]
EXPORT FPU_IRQHandler [WEAK]
WWDG_IRQHandler
PVD_IRQHandler
TAMP_STAMP_IRQHandler
RTC_WKUP_IRQHandler
FLASH_IRQHandler
RCC_IRQHandler
EXTI0_IRQHandler
EXTI1_IRQHandler
EXTI2_IRQHandler
EXTI3_IRQHandler
EXTI4_IRQHandler
DMA1_Stream0_IRQHandler
DMA1_Stream1_IRQHandler
DMA1_Stream2_IRQHandler
DMA1_Stream3_IRQHandler
DMA1_Stream4_IRQHandler
DMA1_Stream5_IRQHandler
DMA1_Stream6_IRQHandler
ADC_IRQHandler
CAN1_TX_IRQHandler
CAN1_RX0_IRQHandler
CAN1_RX1_IRQHandler
CAN1_SCE_IRQHandler
EXTI9_5_IRQHandler
TIM1_BRK_TIM9_IRQHandler
TIM1_UP_TIM10_IRQHandler
TIM1_TRG_COM_TIM11_IRQHandler
TIM1_CC_IRQHandler
TIM2_IRQHandler
TIM3_IRQHandler
TIM4_IRQHandler
I2C1_EV_IRQHandler
I2C1_ER_IRQHandler
I2C2_EV_IRQHandler
I2C2_ER_IRQHandler
SPI1_IRQHandler
SPI2_IRQHandler
USART1_IRQHandler
USART2_IRQHandler
USART3_IRQHandler
EXTI15_10_IRQHandler
RTC_Alarm_IRQHandler
OTG_FS_WKUP_IRQHandler
TIM8_BRK_TIM12_IRQHandler
TIM8_UP_TIM13_IRQHandler
TIM8_TRG_COM_TIM14_IRQHandler
TIM8_CC_IRQHandler
DMA1_Stream7_IRQHandler
FSMC_IRQHandler
SDIO_IRQHandler
TIM5_IRQHandler
SPI3_IRQHandler
UART4_IRQHandler
UART5_IRQHandler
TIM6_DAC_IRQHandler
TIM7_IRQHandler
DMA2_Stream0_IRQHandler
DMA2_Stream1_IRQHandler
DMA2_Stream2_IRQHandler
DMA2_Stream3_IRQHandler
DMA2_Stream4_IRQHandler
ETH_IRQHandler
ETH_WKUP_IRQHandler
CAN2_TX_IRQHandler
CAN2_RX0_IRQHandler
CAN2_RX1_IRQHandler
CAN2_SCE_IRQHandler
OTG_FS_IRQHandler
DMA2_Stream5_IRQHandler
DMA2_Stream6_IRQHandler
DMA2_Stream7_IRQHandler
USART6_IRQHandler
I2C3_EV_IRQHandler
I2C3_ER_IRQHandler
OTG_HS_EP1_OUT_IRQHandler
OTG_HS_EP1_IN_IRQHandler
OTG_HS_WKUP_IRQHandler
OTG_HS_IRQHandler
DCMI_IRQHandler
CRYP_IRQHandler
HASH_RNG_IRQHandler
FPU_IRQHandler
B .
ENDP
ALIGN
;*******************************************************************************
; User Stack and Heap initialization
;*******************************************************************************
IF :DEF:__MICROLIB
EXPORT __initial_sp
EXPORT __heap_base
EXPORT __heap_limit
ELSE
IMPORT __use_two_region_memory
EXPORT __user_initial_stackheap
__user_initial_stackheap
LDR R0, = Heap_Mem
LDR R1, =(Stack_Mem + Stack_Size)
LDR R2, = (Heap_Mem + Heap_Size)
LDR R3, = Stack_Mem
BX LR
ALIGN
ENDIF
END
;************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE*****
|
903257958/stm32_oop_driver
| 29,173
|
stm32f405rg_drivers/stm32f405rg_spi_hard_w25qx/firmware/cmsis/device/startup_stm32f40_41xxx.s
|
;******************** (C) COPYRIGHT 2016 STMicroelectronics ********************
;* File Name : startup_stm32f40_41xxx.s
;* Author : MCD Application Team
;* @version : V1.8.0
;* @date : 09-November-2016
;* Description : STM32F40xxx/41xxx devices vector table for MDK-ARM toolchain.
;* This module performs:
;* - Set the initial SP
;* - Set the initial PC == Reset_Handler
;* - Set the vector table entries with the exceptions ISR address
;* - Configure the system clock and the external SRAM mounted on
;* STM324xG-EVAL board to be used as data memory (optional,
;* to be enabled by user)
;* - Branches to __main in the C library (which eventually
;* calls main()).
;* After Reset the CortexM4 processor is in Thread mode,
;* priority is Privileged, and the Stack is set to Main.
;* <<< Use Configuration Wizard in Context Menu >>>
;*******************************************************************************
;
; Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
; You may not use this file except in compliance with the License.
; You may obtain a copy of the License at:
;
; http://www.st.com/software_license_agreement_liberty_v2
;
; Unless required by applicable law or agreed to in writing, software
; distributed under the License is distributed on an "AS IS" BASIS,
; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
; See the License for the specific language governing permissions and
; limitations under the License.
;
;*******************************************************************************
; Amount of memory (in bytes) allocated for Stack
; Tailor this value to your application needs
; <h> Stack Configuration
; <o> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
; </h>
Stack_Size EQU 0x00000400
AREA STACK, NOINIT, READWRITE, ALIGN=3
Stack_Mem SPACE Stack_Size
__initial_sp
; <h> Heap Configuration
; <o> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
; </h>
Heap_Size EQU 0x00000200
AREA HEAP, NOINIT, READWRITE, ALIGN=3
__heap_base
Heap_Mem SPACE Heap_Size
__heap_limit
PRESERVE8
THUMB
; Vector Table Mapped to Address 0 at Reset
AREA RESET, DATA, READONLY
EXPORT __Vectors
EXPORT __Vectors_End
EXPORT __Vectors_Size
__Vectors DCD __initial_sp ; Top of Stack
DCD Reset_Handler ; Reset Handler
DCD NMI_Handler ; NMI Handler
DCD HardFault_Handler ; Hard Fault Handler
DCD MemManage_Handler ; MPU Fault Handler
DCD BusFault_Handler ; Bus Fault Handler
DCD UsageFault_Handler ; Usage Fault Handler
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD SVC_Handler ; SVCall Handler
DCD DebugMon_Handler ; Debug Monitor Handler
DCD 0 ; Reserved
DCD PendSV_Handler ; PendSV Handler
DCD SysTick_Handler ; SysTick Handler
; External Interrupts
DCD WWDG_IRQHandler ; Window WatchDog
DCD PVD_IRQHandler ; PVD through EXTI Line detection
DCD TAMP_STAMP_IRQHandler ; Tamper and TimeStamps through the EXTI line
DCD RTC_WKUP_IRQHandler ; RTC Wakeup through the EXTI line
DCD FLASH_IRQHandler ; FLASH
DCD RCC_IRQHandler ; RCC
DCD EXTI0_IRQHandler ; EXTI Line0
DCD EXTI1_IRQHandler ; EXTI Line1
DCD EXTI2_IRQHandler ; EXTI Line2
DCD EXTI3_IRQHandler ; EXTI Line3
DCD EXTI4_IRQHandler ; EXTI Line4
DCD DMA1_Stream0_IRQHandler ; DMA1 Stream 0
DCD DMA1_Stream1_IRQHandler ; DMA1 Stream 1
DCD DMA1_Stream2_IRQHandler ; DMA1 Stream 2
DCD DMA1_Stream3_IRQHandler ; DMA1 Stream 3
DCD DMA1_Stream4_IRQHandler ; DMA1 Stream 4
DCD DMA1_Stream5_IRQHandler ; DMA1 Stream 5
DCD DMA1_Stream6_IRQHandler ; DMA1 Stream 6
DCD ADC_IRQHandler ; ADC1, ADC2 and ADC3s
DCD CAN1_TX_IRQHandler ; CAN1 TX
DCD CAN1_RX0_IRQHandler ; CAN1 RX0
DCD CAN1_RX1_IRQHandler ; CAN1 RX1
DCD CAN1_SCE_IRQHandler ; CAN1 SCE
DCD EXTI9_5_IRQHandler ; External Line[9:5]s
DCD TIM1_BRK_TIM9_IRQHandler ; TIM1 Break and TIM9
DCD TIM1_UP_TIM10_IRQHandler ; TIM1 Update and TIM10
DCD TIM1_TRG_COM_TIM11_IRQHandler ; TIM1 Trigger and Commutation and TIM11
DCD TIM1_CC_IRQHandler ; TIM1 Capture Compare
DCD TIM2_IRQHandler ; TIM2
DCD TIM3_IRQHandler ; TIM3
DCD TIM4_IRQHandler ; TIM4
DCD I2C1_EV_IRQHandler ; I2C1 Event
DCD I2C1_ER_IRQHandler ; I2C1 Error
DCD I2C2_EV_IRQHandler ; I2C2 Event
DCD I2C2_ER_IRQHandler ; I2C2 Error
DCD SPI1_IRQHandler ; SPI1
DCD SPI2_IRQHandler ; SPI2
DCD USART1_IRQHandler ; USART1
DCD USART2_IRQHandler ; USART2
DCD USART3_IRQHandler ; USART3
DCD EXTI15_10_IRQHandler ; External Line[15:10]s
DCD RTC_Alarm_IRQHandler ; RTC Alarm (A and B) through EXTI Line
DCD OTG_FS_WKUP_IRQHandler ; USB OTG FS Wakeup through EXTI line
DCD TIM8_BRK_TIM12_IRQHandler ; TIM8 Break and TIM12
DCD TIM8_UP_TIM13_IRQHandler ; TIM8 Update and TIM13
DCD TIM8_TRG_COM_TIM14_IRQHandler ; TIM8 Trigger and Commutation and TIM14
DCD TIM8_CC_IRQHandler ; TIM8 Capture Compare
DCD DMA1_Stream7_IRQHandler ; DMA1 Stream7
DCD FSMC_IRQHandler ; FSMC
DCD SDIO_IRQHandler ; SDIO
DCD TIM5_IRQHandler ; TIM5
DCD SPI3_IRQHandler ; SPI3
DCD UART4_IRQHandler ; UART4
DCD UART5_IRQHandler ; UART5
DCD TIM6_DAC_IRQHandler ; TIM6 and DAC1&2 underrun errors
DCD TIM7_IRQHandler ; TIM7
DCD DMA2_Stream0_IRQHandler ; DMA2 Stream 0
DCD DMA2_Stream1_IRQHandler ; DMA2 Stream 1
DCD DMA2_Stream2_IRQHandler ; DMA2 Stream 2
DCD DMA2_Stream3_IRQHandler ; DMA2 Stream 3
DCD DMA2_Stream4_IRQHandler ; DMA2 Stream 4
DCD ETH_IRQHandler ; Ethernet
DCD ETH_WKUP_IRQHandler ; Ethernet Wakeup through EXTI line
DCD CAN2_TX_IRQHandler ; CAN2 TX
DCD CAN2_RX0_IRQHandler ; CAN2 RX0
DCD CAN2_RX1_IRQHandler ; CAN2 RX1
DCD CAN2_SCE_IRQHandler ; CAN2 SCE
DCD OTG_FS_IRQHandler ; USB OTG FS
DCD DMA2_Stream5_IRQHandler ; DMA2 Stream 5
DCD DMA2_Stream6_IRQHandler ; DMA2 Stream 6
DCD DMA2_Stream7_IRQHandler ; DMA2 Stream 7
DCD USART6_IRQHandler ; USART6
DCD I2C3_EV_IRQHandler ; I2C3 event
DCD I2C3_ER_IRQHandler ; I2C3 error
DCD OTG_HS_EP1_OUT_IRQHandler ; USB OTG HS End Point 1 Out
DCD OTG_HS_EP1_IN_IRQHandler ; USB OTG HS End Point 1 In
DCD OTG_HS_WKUP_IRQHandler ; USB OTG HS Wakeup through EXTI
DCD OTG_HS_IRQHandler ; USB OTG HS
DCD DCMI_IRQHandler ; DCMI
DCD CRYP_IRQHandler ; CRYP crypto
DCD HASH_RNG_IRQHandler ; Hash and Rng
DCD FPU_IRQHandler ; FPU
__Vectors_End
__Vectors_Size EQU __Vectors_End - __Vectors
AREA |.text|, CODE, READONLY
; Reset handler
Reset_Handler PROC
EXPORT Reset_Handler [WEAK]
IMPORT SystemInit
IMPORT __main
LDR R0, =SystemInit
BLX R0
LDR R0, =__main
BX R0
ENDP
; Dummy Exception Handlers (infinite loops which can be modified)
NMI_Handler PROC
EXPORT NMI_Handler [WEAK]
B .
ENDP
HardFault_Handler\
PROC
EXPORT HardFault_Handler [WEAK]
B .
ENDP
MemManage_Handler\
PROC
EXPORT MemManage_Handler [WEAK]
B .
ENDP
BusFault_Handler\
PROC
EXPORT BusFault_Handler [WEAK]
B .
ENDP
UsageFault_Handler\
PROC
EXPORT UsageFault_Handler [WEAK]
B .
ENDP
SVC_Handler PROC
EXPORT SVC_Handler [WEAK]
B .
ENDP
DebugMon_Handler\
PROC
EXPORT DebugMon_Handler [WEAK]
B .
ENDP
PendSV_Handler PROC
EXPORT PendSV_Handler [WEAK]
B .
ENDP
SysTick_Handler PROC
EXPORT SysTick_Handler [WEAK]
B .
ENDP
Default_Handler PROC
EXPORT WWDG_IRQHandler [WEAK]
EXPORT PVD_IRQHandler [WEAK]
EXPORT TAMP_STAMP_IRQHandler [WEAK]
EXPORT RTC_WKUP_IRQHandler [WEAK]
EXPORT FLASH_IRQHandler [WEAK]
EXPORT RCC_IRQHandler [WEAK]
EXPORT EXTI0_IRQHandler [WEAK]
EXPORT EXTI1_IRQHandler [WEAK]
EXPORT EXTI2_IRQHandler [WEAK]
EXPORT EXTI3_IRQHandler [WEAK]
EXPORT EXTI4_IRQHandler [WEAK]
EXPORT DMA1_Stream0_IRQHandler [WEAK]
EXPORT DMA1_Stream1_IRQHandler [WEAK]
EXPORT DMA1_Stream2_IRQHandler [WEAK]
EXPORT DMA1_Stream3_IRQHandler [WEAK]
EXPORT DMA1_Stream4_IRQHandler [WEAK]
EXPORT DMA1_Stream5_IRQHandler [WEAK]
EXPORT DMA1_Stream6_IRQHandler [WEAK]
EXPORT ADC_IRQHandler [WEAK]
EXPORT CAN1_TX_IRQHandler [WEAK]
EXPORT CAN1_RX0_IRQHandler [WEAK]
EXPORT CAN1_RX1_IRQHandler [WEAK]
EXPORT CAN1_SCE_IRQHandler [WEAK]
EXPORT EXTI9_5_IRQHandler [WEAK]
EXPORT TIM1_BRK_TIM9_IRQHandler [WEAK]
EXPORT TIM1_UP_TIM10_IRQHandler [WEAK]
EXPORT TIM1_TRG_COM_TIM11_IRQHandler [WEAK]
EXPORT TIM1_CC_IRQHandler [WEAK]
EXPORT TIM2_IRQHandler [WEAK]
EXPORT TIM3_IRQHandler [WEAK]
EXPORT TIM4_IRQHandler [WEAK]
EXPORT I2C1_EV_IRQHandler [WEAK]
EXPORT I2C1_ER_IRQHandler [WEAK]
EXPORT I2C2_EV_IRQHandler [WEAK]
EXPORT I2C2_ER_IRQHandler [WEAK]
EXPORT SPI1_IRQHandler [WEAK]
EXPORT SPI2_IRQHandler [WEAK]
EXPORT USART1_IRQHandler [WEAK]
EXPORT USART2_IRQHandler [WEAK]
EXPORT USART3_IRQHandler [WEAK]
EXPORT EXTI15_10_IRQHandler [WEAK]
EXPORT RTC_Alarm_IRQHandler [WEAK]
EXPORT OTG_FS_WKUP_IRQHandler [WEAK]
EXPORT TIM8_BRK_TIM12_IRQHandler [WEAK]
EXPORT TIM8_UP_TIM13_IRQHandler [WEAK]
EXPORT TIM8_TRG_COM_TIM14_IRQHandler [WEAK]
EXPORT TIM8_CC_IRQHandler [WEAK]
EXPORT DMA1_Stream7_IRQHandler [WEAK]
EXPORT FSMC_IRQHandler [WEAK]
EXPORT SDIO_IRQHandler [WEAK]
EXPORT TIM5_IRQHandler [WEAK]
EXPORT SPI3_IRQHandler [WEAK]
EXPORT UART4_IRQHandler [WEAK]
EXPORT UART5_IRQHandler [WEAK]
EXPORT TIM6_DAC_IRQHandler [WEAK]
EXPORT TIM7_IRQHandler [WEAK]
EXPORT DMA2_Stream0_IRQHandler [WEAK]
EXPORT DMA2_Stream1_IRQHandler [WEAK]
EXPORT DMA2_Stream2_IRQHandler [WEAK]
EXPORT DMA2_Stream3_IRQHandler [WEAK]
EXPORT DMA2_Stream4_IRQHandler [WEAK]
EXPORT ETH_IRQHandler [WEAK]
EXPORT ETH_WKUP_IRQHandler [WEAK]
EXPORT CAN2_TX_IRQHandler [WEAK]
EXPORT CAN2_RX0_IRQHandler [WEAK]
EXPORT CAN2_RX1_IRQHandler [WEAK]
EXPORT CAN2_SCE_IRQHandler [WEAK]
EXPORT OTG_FS_IRQHandler [WEAK]
EXPORT DMA2_Stream5_IRQHandler [WEAK]
EXPORT DMA2_Stream6_IRQHandler [WEAK]
EXPORT DMA2_Stream7_IRQHandler [WEAK]
EXPORT USART6_IRQHandler [WEAK]
EXPORT I2C3_EV_IRQHandler [WEAK]
EXPORT I2C3_ER_IRQHandler [WEAK]
EXPORT OTG_HS_EP1_OUT_IRQHandler [WEAK]
EXPORT OTG_HS_EP1_IN_IRQHandler [WEAK]
EXPORT OTG_HS_WKUP_IRQHandler [WEAK]
EXPORT OTG_HS_IRQHandler [WEAK]
EXPORT DCMI_IRQHandler [WEAK]
EXPORT CRYP_IRQHandler [WEAK]
EXPORT HASH_RNG_IRQHandler [WEAK]
EXPORT FPU_IRQHandler [WEAK]
WWDG_IRQHandler
PVD_IRQHandler
TAMP_STAMP_IRQHandler
RTC_WKUP_IRQHandler
FLASH_IRQHandler
RCC_IRQHandler
EXTI0_IRQHandler
EXTI1_IRQHandler
EXTI2_IRQHandler
EXTI3_IRQHandler
EXTI4_IRQHandler
DMA1_Stream0_IRQHandler
DMA1_Stream1_IRQHandler
DMA1_Stream2_IRQHandler
DMA1_Stream3_IRQHandler
DMA1_Stream4_IRQHandler
DMA1_Stream5_IRQHandler
DMA1_Stream6_IRQHandler
ADC_IRQHandler
CAN1_TX_IRQHandler
CAN1_RX0_IRQHandler
CAN1_RX1_IRQHandler
CAN1_SCE_IRQHandler
EXTI9_5_IRQHandler
TIM1_BRK_TIM9_IRQHandler
TIM1_UP_TIM10_IRQHandler
TIM1_TRG_COM_TIM11_IRQHandler
TIM1_CC_IRQHandler
TIM2_IRQHandler
TIM3_IRQHandler
TIM4_IRQHandler
I2C1_EV_IRQHandler
I2C1_ER_IRQHandler
I2C2_EV_IRQHandler
I2C2_ER_IRQHandler
SPI1_IRQHandler
SPI2_IRQHandler
USART1_IRQHandler
USART2_IRQHandler
USART3_IRQHandler
EXTI15_10_IRQHandler
RTC_Alarm_IRQHandler
OTG_FS_WKUP_IRQHandler
TIM8_BRK_TIM12_IRQHandler
TIM8_UP_TIM13_IRQHandler
TIM8_TRG_COM_TIM14_IRQHandler
TIM8_CC_IRQHandler
DMA1_Stream7_IRQHandler
FSMC_IRQHandler
SDIO_IRQHandler
TIM5_IRQHandler
SPI3_IRQHandler
UART4_IRQHandler
UART5_IRQHandler
TIM6_DAC_IRQHandler
TIM7_IRQHandler
DMA2_Stream0_IRQHandler
DMA2_Stream1_IRQHandler
DMA2_Stream2_IRQHandler
DMA2_Stream3_IRQHandler
DMA2_Stream4_IRQHandler
ETH_IRQHandler
ETH_WKUP_IRQHandler
CAN2_TX_IRQHandler
CAN2_RX0_IRQHandler
CAN2_RX1_IRQHandler
CAN2_SCE_IRQHandler
OTG_FS_IRQHandler
DMA2_Stream5_IRQHandler
DMA2_Stream6_IRQHandler
DMA2_Stream7_IRQHandler
USART6_IRQHandler
I2C3_EV_IRQHandler
I2C3_ER_IRQHandler
OTG_HS_EP1_OUT_IRQHandler
OTG_HS_EP1_IN_IRQHandler
OTG_HS_WKUP_IRQHandler
OTG_HS_IRQHandler
DCMI_IRQHandler
CRYP_IRQHandler
HASH_RNG_IRQHandler
FPU_IRQHandler
B .
ENDP
ALIGN
;*******************************************************************************
; User Stack and Heap initialization
;*******************************************************************************
IF :DEF:__MICROLIB
EXPORT __initial_sp
EXPORT __heap_base
EXPORT __heap_limit
ELSE
IMPORT __use_two_region_memory
EXPORT __user_initial_stackheap
__user_initial_stackheap
LDR R0, = Heap_Mem
LDR R1, =(Stack_Mem + Stack_Size)
LDR R2, = (Heap_Mem + Heap_Size)
LDR R3, = Stack_Mem
BX LR
ALIGN
ENDIF
END
;************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE*****
|
903257958/stm32_oop_driver
| 29,173
|
stm32f405rg_drivers/stm32f405rg_i2c_soft_aht21/firmware/cmsis/device/startup_stm32f40_41xxx.s
|
;******************** (C) COPYRIGHT 2016 STMicroelectronics ********************
;* File Name : startup_stm32f40_41xxx.s
;* Author : MCD Application Team
;* @version : V1.8.0
;* @date : 09-November-2016
;* Description : STM32F40xxx/41xxx devices vector table for MDK-ARM toolchain.
;* This module performs:
;* - Set the initial SP
;* - Set the initial PC == Reset_Handler
;* - Set the vector table entries with the exceptions ISR address
;* - Configure the system clock and the external SRAM mounted on
;* STM324xG-EVAL board to be used as data memory (optional,
;* to be enabled by user)
;* - Branches to __main in the C library (which eventually
;* calls main()).
;* After Reset the CortexM4 processor is in Thread mode,
;* priority is Privileged, and the Stack is set to Main.
;* <<< Use Configuration Wizard in Context Menu >>>
;*******************************************************************************
;
; Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
; You may not use this file except in compliance with the License.
; You may obtain a copy of the License at:
;
; http://www.st.com/software_license_agreement_liberty_v2
;
; Unless required by applicable law or agreed to in writing, software
; distributed under the License is distributed on an "AS IS" BASIS,
; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
; See the License for the specific language governing permissions and
; limitations under the License.
;
;*******************************************************************************
; Amount of memory (in bytes) allocated for Stack
; Tailor this value to your application needs
; <h> Stack Configuration
; <o> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
; </h>
Stack_Size EQU 0x00000400
AREA STACK, NOINIT, READWRITE, ALIGN=3
Stack_Mem SPACE Stack_Size
__initial_sp
; <h> Heap Configuration
; <o> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
; </h>
Heap_Size EQU 0x00000200
AREA HEAP, NOINIT, READWRITE, ALIGN=3
__heap_base
Heap_Mem SPACE Heap_Size
__heap_limit
PRESERVE8
THUMB
; Vector Table Mapped to Address 0 at Reset
AREA RESET, DATA, READONLY
EXPORT __Vectors
EXPORT __Vectors_End
EXPORT __Vectors_Size
__Vectors DCD __initial_sp ; Top of Stack
DCD Reset_Handler ; Reset Handler
DCD NMI_Handler ; NMI Handler
DCD HardFault_Handler ; Hard Fault Handler
DCD MemManage_Handler ; MPU Fault Handler
DCD BusFault_Handler ; Bus Fault Handler
DCD UsageFault_Handler ; Usage Fault Handler
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD SVC_Handler ; SVCall Handler
DCD DebugMon_Handler ; Debug Monitor Handler
DCD 0 ; Reserved
DCD PendSV_Handler ; PendSV Handler
DCD SysTick_Handler ; SysTick Handler
; External Interrupts
DCD WWDG_IRQHandler ; Window WatchDog
DCD PVD_IRQHandler ; PVD through EXTI Line detection
DCD TAMP_STAMP_IRQHandler ; Tamper and TimeStamps through the EXTI line
DCD RTC_WKUP_IRQHandler ; RTC Wakeup through the EXTI line
DCD FLASH_IRQHandler ; FLASH
DCD RCC_IRQHandler ; RCC
DCD EXTI0_IRQHandler ; EXTI Line0
DCD EXTI1_IRQHandler ; EXTI Line1
DCD EXTI2_IRQHandler ; EXTI Line2
DCD EXTI3_IRQHandler ; EXTI Line3
DCD EXTI4_IRQHandler ; EXTI Line4
DCD DMA1_Stream0_IRQHandler ; DMA1 Stream 0
DCD DMA1_Stream1_IRQHandler ; DMA1 Stream 1
DCD DMA1_Stream2_IRQHandler ; DMA1 Stream 2
DCD DMA1_Stream3_IRQHandler ; DMA1 Stream 3
DCD DMA1_Stream4_IRQHandler ; DMA1 Stream 4
DCD DMA1_Stream5_IRQHandler ; DMA1 Stream 5
DCD DMA1_Stream6_IRQHandler ; DMA1 Stream 6
DCD ADC_IRQHandler ; ADC1, ADC2 and ADC3s
DCD CAN1_TX_IRQHandler ; CAN1 TX
DCD CAN1_RX0_IRQHandler ; CAN1 RX0
DCD CAN1_RX1_IRQHandler ; CAN1 RX1
DCD CAN1_SCE_IRQHandler ; CAN1 SCE
DCD EXTI9_5_IRQHandler ; External Line[9:5]s
DCD TIM1_BRK_TIM9_IRQHandler ; TIM1 Break and TIM9
DCD TIM1_UP_TIM10_IRQHandler ; TIM1 Update and TIM10
DCD TIM1_TRG_COM_TIM11_IRQHandler ; TIM1 Trigger and Commutation and TIM11
DCD TIM1_CC_IRQHandler ; TIM1 Capture Compare
DCD TIM2_IRQHandler ; TIM2
DCD TIM3_IRQHandler ; TIM3
DCD TIM4_IRQHandler ; TIM4
DCD I2C1_EV_IRQHandler ; I2C1 Event
DCD I2C1_ER_IRQHandler ; I2C1 Error
DCD I2C2_EV_IRQHandler ; I2C2 Event
DCD I2C2_ER_IRQHandler ; I2C2 Error
DCD SPI1_IRQHandler ; SPI1
DCD SPI2_IRQHandler ; SPI2
DCD USART1_IRQHandler ; USART1
DCD USART2_IRQHandler ; USART2
DCD USART3_IRQHandler ; USART3
DCD EXTI15_10_IRQHandler ; External Line[15:10]s
DCD RTC_Alarm_IRQHandler ; RTC Alarm (A and B) through EXTI Line
DCD OTG_FS_WKUP_IRQHandler ; USB OTG FS Wakeup through EXTI line
DCD TIM8_BRK_TIM12_IRQHandler ; TIM8 Break and TIM12
DCD TIM8_UP_TIM13_IRQHandler ; TIM8 Update and TIM13
DCD TIM8_TRG_COM_TIM14_IRQHandler ; TIM8 Trigger and Commutation and TIM14
DCD TIM8_CC_IRQHandler ; TIM8 Capture Compare
DCD DMA1_Stream7_IRQHandler ; DMA1 Stream7
DCD FSMC_IRQHandler ; FSMC
DCD SDIO_IRQHandler ; SDIO
DCD TIM5_IRQHandler ; TIM5
DCD SPI3_IRQHandler ; SPI3
DCD UART4_IRQHandler ; UART4
DCD UART5_IRQHandler ; UART5
DCD TIM6_DAC_IRQHandler ; TIM6 and DAC1&2 underrun errors
DCD TIM7_IRQHandler ; TIM7
DCD DMA2_Stream0_IRQHandler ; DMA2 Stream 0
DCD DMA2_Stream1_IRQHandler ; DMA2 Stream 1
DCD DMA2_Stream2_IRQHandler ; DMA2 Stream 2
DCD DMA2_Stream3_IRQHandler ; DMA2 Stream 3
DCD DMA2_Stream4_IRQHandler ; DMA2 Stream 4
DCD ETH_IRQHandler ; Ethernet
DCD ETH_WKUP_IRQHandler ; Ethernet Wakeup through EXTI line
DCD CAN2_TX_IRQHandler ; CAN2 TX
DCD CAN2_RX0_IRQHandler ; CAN2 RX0
DCD CAN2_RX1_IRQHandler ; CAN2 RX1
DCD CAN2_SCE_IRQHandler ; CAN2 SCE
DCD OTG_FS_IRQHandler ; USB OTG FS
DCD DMA2_Stream5_IRQHandler ; DMA2 Stream 5
DCD DMA2_Stream6_IRQHandler ; DMA2 Stream 6
DCD DMA2_Stream7_IRQHandler ; DMA2 Stream 7
DCD USART6_IRQHandler ; USART6
DCD I2C3_EV_IRQHandler ; I2C3 event
DCD I2C3_ER_IRQHandler ; I2C3 error
DCD OTG_HS_EP1_OUT_IRQHandler ; USB OTG HS End Point 1 Out
DCD OTG_HS_EP1_IN_IRQHandler ; USB OTG HS End Point 1 In
DCD OTG_HS_WKUP_IRQHandler ; USB OTG HS Wakeup through EXTI
DCD OTG_HS_IRQHandler ; USB OTG HS
DCD DCMI_IRQHandler ; DCMI
DCD CRYP_IRQHandler ; CRYP crypto
DCD HASH_RNG_IRQHandler ; Hash and Rng
DCD FPU_IRQHandler ; FPU
__Vectors_End
__Vectors_Size EQU __Vectors_End - __Vectors
AREA |.text|, CODE, READONLY
; Reset handler
Reset_Handler PROC
EXPORT Reset_Handler [WEAK]
IMPORT SystemInit
IMPORT __main
LDR R0, =SystemInit
BLX R0
LDR R0, =__main
BX R0
ENDP
; Dummy Exception Handlers (infinite loops which can be modified)
NMI_Handler PROC
EXPORT NMI_Handler [WEAK]
B .
ENDP
HardFault_Handler\
PROC
EXPORT HardFault_Handler [WEAK]
B .
ENDP
MemManage_Handler\
PROC
EXPORT MemManage_Handler [WEAK]
B .
ENDP
BusFault_Handler\
PROC
EXPORT BusFault_Handler [WEAK]
B .
ENDP
UsageFault_Handler\
PROC
EXPORT UsageFault_Handler [WEAK]
B .
ENDP
SVC_Handler PROC
EXPORT SVC_Handler [WEAK]
B .
ENDP
DebugMon_Handler\
PROC
EXPORT DebugMon_Handler [WEAK]
B .
ENDP
PendSV_Handler PROC
EXPORT PendSV_Handler [WEAK]
B .
ENDP
SysTick_Handler PROC
EXPORT SysTick_Handler [WEAK]
B .
ENDP
Default_Handler PROC
EXPORT WWDG_IRQHandler [WEAK]
EXPORT PVD_IRQHandler [WEAK]
EXPORT TAMP_STAMP_IRQHandler [WEAK]
EXPORT RTC_WKUP_IRQHandler [WEAK]
EXPORT FLASH_IRQHandler [WEAK]
EXPORT RCC_IRQHandler [WEAK]
EXPORT EXTI0_IRQHandler [WEAK]
EXPORT EXTI1_IRQHandler [WEAK]
EXPORT EXTI2_IRQHandler [WEAK]
EXPORT EXTI3_IRQHandler [WEAK]
EXPORT EXTI4_IRQHandler [WEAK]
EXPORT DMA1_Stream0_IRQHandler [WEAK]
EXPORT DMA1_Stream1_IRQHandler [WEAK]
EXPORT DMA1_Stream2_IRQHandler [WEAK]
EXPORT DMA1_Stream3_IRQHandler [WEAK]
EXPORT DMA1_Stream4_IRQHandler [WEAK]
EXPORT DMA1_Stream5_IRQHandler [WEAK]
EXPORT DMA1_Stream6_IRQHandler [WEAK]
EXPORT ADC_IRQHandler [WEAK]
EXPORT CAN1_TX_IRQHandler [WEAK]
EXPORT CAN1_RX0_IRQHandler [WEAK]
EXPORT CAN1_RX1_IRQHandler [WEAK]
EXPORT CAN1_SCE_IRQHandler [WEAK]
EXPORT EXTI9_5_IRQHandler [WEAK]
EXPORT TIM1_BRK_TIM9_IRQHandler [WEAK]
EXPORT TIM1_UP_TIM10_IRQHandler [WEAK]
EXPORT TIM1_TRG_COM_TIM11_IRQHandler [WEAK]
EXPORT TIM1_CC_IRQHandler [WEAK]
EXPORT TIM2_IRQHandler [WEAK]
EXPORT TIM3_IRQHandler [WEAK]
EXPORT TIM4_IRQHandler [WEAK]
EXPORT I2C1_EV_IRQHandler [WEAK]
EXPORT I2C1_ER_IRQHandler [WEAK]
EXPORT I2C2_EV_IRQHandler [WEAK]
EXPORT I2C2_ER_IRQHandler [WEAK]
EXPORT SPI1_IRQHandler [WEAK]
EXPORT SPI2_IRQHandler [WEAK]
EXPORT USART1_IRQHandler [WEAK]
EXPORT USART2_IRQHandler [WEAK]
EXPORT USART3_IRQHandler [WEAK]
EXPORT EXTI15_10_IRQHandler [WEAK]
EXPORT RTC_Alarm_IRQHandler [WEAK]
EXPORT OTG_FS_WKUP_IRQHandler [WEAK]
EXPORT TIM8_BRK_TIM12_IRQHandler [WEAK]
EXPORT TIM8_UP_TIM13_IRQHandler [WEAK]
EXPORT TIM8_TRG_COM_TIM14_IRQHandler [WEAK]
EXPORT TIM8_CC_IRQHandler [WEAK]
EXPORT DMA1_Stream7_IRQHandler [WEAK]
EXPORT FSMC_IRQHandler [WEAK]
EXPORT SDIO_IRQHandler [WEAK]
EXPORT TIM5_IRQHandler [WEAK]
EXPORT SPI3_IRQHandler [WEAK]
EXPORT UART4_IRQHandler [WEAK]
EXPORT UART5_IRQHandler [WEAK]
EXPORT TIM6_DAC_IRQHandler [WEAK]
EXPORT TIM7_IRQHandler [WEAK]
EXPORT DMA2_Stream0_IRQHandler [WEAK]
EXPORT DMA2_Stream1_IRQHandler [WEAK]
EXPORT DMA2_Stream2_IRQHandler [WEAK]
EXPORT DMA2_Stream3_IRQHandler [WEAK]
EXPORT DMA2_Stream4_IRQHandler [WEAK]
EXPORT ETH_IRQHandler [WEAK]
EXPORT ETH_WKUP_IRQHandler [WEAK]
EXPORT CAN2_TX_IRQHandler [WEAK]
EXPORT CAN2_RX0_IRQHandler [WEAK]
EXPORT CAN2_RX1_IRQHandler [WEAK]
EXPORT CAN2_SCE_IRQHandler [WEAK]
EXPORT OTG_FS_IRQHandler [WEAK]
EXPORT DMA2_Stream5_IRQHandler [WEAK]
EXPORT DMA2_Stream6_IRQHandler [WEAK]
EXPORT DMA2_Stream7_IRQHandler [WEAK]
EXPORT USART6_IRQHandler [WEAK]
EXPORT I2C3_EV_IRQHandler [WEAK]
EXPORT I2C3_ER_IRQHandler [WEAK]
EXPORT OTG_HS_EP1_OUT_IRQHandler [WEAK]
EXPORT OTG_HS_EP1_IN_IRQHandler [WEAK]
EXPORT OTG_HS_WKUP_IRQHandler [WEAK]
EXPORT OTG_HS_IRQHandler [WEAK]
EXPORT DCMI_IRQHandler [WEAK]
EXPORT CRYP_IRQHandler [WEAK]
EXPORT HASH_RNG_IRQHandler [WEAK]
EXPORT FPU_IRQHandler [WEAK]
WWDG_IRQHandler
PVD_IRQHandler
TAMP_STAMP_IRQHandler
RTC_WKUP_IRQHandler
FLASH_IRQHandler
RCC_IRQHandler
EXTI0_IRQHandler
EXTI1_IRQHandler
EXTI2_IRQHandler
EXTI3_IRQHandler
EXTI4_IRQHandler
DMA1_Stream0_IRQHandler
DMA1_Stream1_IRQHandler
DMA1_Stream2_IRQHandler
DMA1_Stream3_IRQHandler
DMA1_Stream4_IRQHandler
DMA1_Stream5_IRQHandler
DMA1_Stream6_IRQHandler
ADC_IRQHandler
CAN1_TX_IRQHandler
CAN1_RX0_IRQHandler
CAN1_RX1_IRQHandler
CAN1_SCE_IRQHandler
EXTI9_5_IRQHandler
TIM1_BRK_TIM9_IRQHandler
TIM1_UP_TIM10_IRQHandler
TIM1_TRG_COM_TIM11_IRQHandler
TIM1_CC_IRQHandler
TIM2_IRQHandler
TIM3_IRQHandler
TIM4_IRQHandler
I2C1_EV_IRQHandler
I2C1_ER_IRQHandler
I2C2_EV_IRQHandler
I2C2_ER_IRQHandler
SPI1_IRQHandler
SPI2_IRQHandler
USART1_IRQHandler
USART2_IRQHandler
USART3_IRQHandler
EXTI15_10_IRQHandler
RTC_Alarm_IRQHandler
OTG_FS_WKUP_IRQHandler
TIM8_BRK_TIM12_IRQHandler
TIM8_UP_TIM13_IRQHandler
TIM8_TRG_COM_TIM14_IRQHandler
TIM8_CC_IRQHandler
DMA1_Stream7_IRQHandler
FSMC_IRQHandler
SDIO_IRQHandler
TIM5_IRQHandler
SPI3_IRQHandler
UART4_IRQHandler
UART5_IRQHandler
TIM6_DAC_IRQHandler
TIM7_IRQHandler
DMA2_Stream0_IRQHandler
DMA2_Stream1_IRQHandler
DMA2_Stream2_IRQHandler
DMA2_Stream3_IRQHandler
DMA2_Stream4_IRQHandler
ETH_IRQHandler
ETH_WKUP_IRQHandler
CAN2_TX_IRQHandler
CAN2_RX0_IRQHandler
CAN2_RX1_IRQHandler
CAN2_SCE_IRQHandler
OTG_FS_IRQHandler
DMA2_Stream5_IRQHandler
DMA2_Stream6_IRQHandler
DMA2_Stream7_IRQHandler
USART6_IRQHandler
I2C3_EV_IRQHandler
I2C3_ER_IRQHandler
OTG_HS_EP1_OUT_IRQHandler
OTG_HS_EP1_IN_IRQHandler
OTG_HS_WKUP_IRQHandler
OTG_HS_IRQHandler
DCMI_IRQHandler
CRYP_IRQHandler
HASH_RNG_IRQHandler
FPU_IRQHandler
B .
ENDP
ALIGN
;*******************************************************************************
; User Stack and Heap initialization
;*******************************************************************************
IF :DEF:__MICROLIB
EXPORT __initial_sp
EXPORT __heap_base
EXPORT __heap_limit
ELSE
IMPORT __use_two_region_memory
EXPORT __user_initial_stackheap
__user_initial_stackheap
LDR R0, = Heap_Mem
LDR R1, =(Stack_Mem + Stack_Size)
LDR R2, = (Heap_Mem + Heap_Size)
LDR R3, = Stack_Mem
BX LR
ALIGN
ENDIF
END
;************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE*****
|
903257958/stm32_oop_driver
| 29,173
|
stm32f405rg_drivers/stm32f405rg_esp8266/firmware/cmsis/device/startup_stm32f40_41xxx.s
|
;******************** (C) COPYRIGHT 2016 STMicroelectronics ********************
;* File Name : startup_stm32f40_41xxx.s
;* Author : MCD Application Team
;* @version : V1.8.0
;* @date : 09-November-2016
;* Description : STM32F40xxx/41xxx devices vector table for MDK-ARM toolchain.
;* This module performs:
;* - Set the initial SP
;* - Set the initial PC == Reset_Handler
;* - Set the vector table entries with the exceptions ISR address
;* - Configure the system clock and the external SRAM mounted on
;* STM324xG-EVAL board to be used as data memory (optional,
;* to be enabled by user)
;* - Branches to __main in the C library (which eventually
;* calls main()).
;* After Reset the CortexM4 processor is in Thread mode,
;* priority is Privileged, and the Stack is set to Main.
;* <<< Use Configuration Wizard in Context Menu >>>
;*******************************************************************************
;
; Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
; You may not use this file except in compliance with the License.
; You may obtain a copy of the License at:
;
; http://www.st.com/software_license_agreement_liberty_v2
;
; Unless required by applicable law or agreed to in writing, software
; distributed under the License is distributed on an "AS IS" BASIS,
; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
; See the License for the specific language governing permissions and
; limitations under the License.
;
;*******************************************************************************
; Amount of memory (in bytes) allocated for Stack
; Tailor this value to your application needs
; <h> Stack Configuration
; <o> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
; </h>
Stack_Size EQU 0x00000F00
AREA STACK, NOINIT, READWRITE, ALIGN=3
Stack_Mem SPACE Stack_Size
__initial_sp
; <h> Heap Configuration
; <o> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
; </h>
Heap_Size EQU 0x00000200
AREA HEAP, NOINIT, READWRITE, ALIGN=3
__heap_base
Heap_Mem SPACE Heap_Size
__heap_limit
PRESERVE8
THUMB
; Vector Table Mapped to Address 0 at Reset
AREA RESET, DATA, READONLY
EXPORT __Vectors
EXPORT __Vectors_End
EXPORT __Vectors_Size
__Vectors DCD __initial_sp ; Top of Stack
DCD Reset_Handler ; Reset Handler
DCD NMI_Handler ; NMI Handler
DCD HardFault_Handler ; Hard Fault Handler
DCD MemManage_Handler ; MPU Fault Handler
DCD BusFault_Handler ; Bus Fault Handler
DCD UsageFault_Handler ; Usage Fault Handler
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD SVC_Handler ; SVCall Handler
DCD DebugMon_Handler ; Debug Monitor Handler
DCD 0 ; Reserved
DCD PendSV_Handler ; PendSV Handler
DCD SysTick_Handler ; SysTick Handler
; External Interrupts
DCD WWDG_IRQHandler ; Window WatchDog
DCD PVD_IRQHandler ; PVD through EXTI Line detection
DCD TAMP_STAMP_IRQHandler ; Tamper and TimeStamps through the EXTI line
DCD RTC_WKUP_IRQHandler ; RTC Wakeup through the EXTI line
DCD FLASH_IRQHandler ; FLASH
DCD RCC_IRQHandler ; RCC
DCD EXTI0_IRQHandler ; EXTI Line0
DCD EXTI1_IRQHandler ; EXTI Line1
DCD EXTI2_IRQHandler ; EXTI Line2
DCD EXTI3_IRQHandler ; EXTI Line3
DCD EXTI4_IRQHandler ; EXTI Line4
DCD DMA1_Stream0_IRQHandler ; DMA1 Stream 0
DCD DMA1_Stream1_IRQHandler ; DMA1 Stream 1
DCD DMA1_Stream2_IRQHandler ; DMA1 Stream 2
DCD DMA1_Stream3_IRQHandler ; DMA1 Stream 3
DCD DMA1_Stream4_IRQHandler ; DMA1 Stream 4
DCD DMA1_Stream5_IRQHandler ; DMA1 Stream 5
DCD DMA1_Stream6_IRQHandler ; DMA1 Stream 6
DCD ADC_IRQHandler ; ADC1, ADC2 and ADC3s
DCD CAN1_TX_IRQHandler ; CAN1 TX
DCD CAN1_RX0_IRQHandler ; CAN1 RX0
DCD CAN1_RX1_IRQHandler ; CAN1 RX1
DCD CAN1_SCE_IRQHandler ; CAN1 SCE
DCD EXTI9_5_IRQHandler ; External Line[9:5]s
DCD TIM1_BRK_TIM9_IRQHandler ; TIM1 Break and TIM9
DCD TIM1_UP_TIM10_IRQHandler ; TIM1 Update and TIM10
DCD TIM1_TRG_COM_TIM11_IRQHandler ; TIM1 Trigger and Commutation and TIM11
DCD TIM1_CC_IRQHandler ; TIM1 Capture Compare
DCD TIM2_IRQHandler ; TIM2
DCD TIM3_IRQHandler ; TIM3
DCD TIM4_IRQHandler ; TIM4
DCD I2C1_EV_IRQHandler ; I2C1 Event
DCD I2C1_ER_IRQHandler ; I2C1 Error
DCD I2C2_EV_IRQHandler ; I2C2 Event
DCD I2C2_ER_IRQHandler ; I2C2 Error
DCD SPI1_IRQHandler ; SPI1
DCD SPI2_IRQHandler ; SPI2
DCD USART1_IRQHandler ; USART1
DCD USART2_IRQHandler ; USART2
DCD USART3_IRQHandler ; USART3
DCD EXTI15_10_IRQHandler ; External Line[15:10]s
DCD RTC_Alarm_IRQHandler ; RTC Alarm (A and B) through EXTI Line
DCD OTG_FS_WKUP_IRQHandler ; USB OTG FS Wakeup through EXTI line
DCD TIM8_BRK_TIM12_IRQHandler ; TIM8 Break and TIM12
DCD TIM8_UP_TIM13_IRQHandler ; TIM8 Update and TIM13
DCD TIM8_TRG_COM_TIM14_IRQHandler ; TIM8 Trigger and Commutation and TIM14
DCD TIM8_CC_IRQHandler ; TIM8 Capture Compare
DCD DMA1_Stream7_IRQHandler ; DMA1 Stream7
DCD FSMC_IRQHandler ; FSMC
DCD SDIO_IRQHandler ; SDIO
DCD TIM5_IRQHandler ; TIM5
DCD SPI3_IRQHandler ; SPI3
DCD UART4_IRQHandler ; UART4
DCD UART5_IRQHandler ; UART5
DCD TIM6_DAC_IRQHandler ; TIM6 and DAC1&2 underrun errors
DCD TIM7_IRQHandler ; TIM7
DCD DMA2_Stream0_IRQHandler ; DMA2 Stream 0
DCD DMA2_Stream1_IRQHandler ; DMA2 Stream 1
DCD DMA2_Stream2_IRQHandler ; DMA2 Stream 2
DCD DMA2_Stream3_IRQHandler ; DMA2 Stream 3
DCD DMA2_Stream4_IRQHandler ; DMA2 Stream 4
DCD ETH_IRQHandler ; Ethernet
DCD ETH_WKUP_IRQHandler ; Ethernet Wakeup through EXTI line
DCD CAN2_TX_IRQHandler ; CAN2 TX
DCD CAN2_RX0_IRQHandler ; CAN2 RX0
DCD CAN2_RX1_IRQHandler ; CAN2 RX1
DCD CAN2_SCE_IRQHandler ; CAN2 SCE
DCD OTG_FS_IRQHandler ; USB OTG FS
DCD DMA2_Stream5_IRQHandler ; DMA2 Stream 5
DCD DMA2_Stream6_IRQHandler ; DMA2 Stream 6
DCD DMA2_Stream7_IRQHandler ; DMA2 Stream 7
DCD USART6_IRQHandler ; USART6
DCD I2C3_EV_IRQHandler ; I2C3 event
DCD I2C3_ER_IRQHandler ; I2C3 error
DCD OTG_HS_EP1_OUT_IRQHandler ; USB OTG HS End Point 1 Out
DCD OTG_HS_EP1_IN_IRQHandler ; USB OTG HS End Point 1 In
DCD OTG_HS_WKUP_IRQHandler ; USB OTG HS Wakeup through EXTI
DCD OTG_HS_IRQHandler ; USB OTG HS
DCD DCMI_IRQHandler ; DCMI
DCD CRYP_IRQHandler ; CRYP crypto
DCD HASH_RNG_IRQHandler ; Hash and Rng
DCD FPU_IRQHandler ; FPU
__Vectors_End
__Vectors_Size EQU __Vectors_End - __Vectors
AREA |.text|, CODE, READONLY
; Reset handler
Reset_Handler PROC
EXPORT Reset_Handler [WEAK]
IMPORT SystemInit
IMPORT __main
LDR R0, =SystemInit
BLX R0
LDR R0, =__main
BX R0
ENDP
; Dummy Exception Handlers (infinite loops which can be modified)
NMI_Handler PROC
EXPORT NMI_Handler [WEAK]
B .
ENDP
HardFault_Handler\
PROC
EXPORT HardFault_Handler [WEAK]
B .
ENDP
MemManage_Handler\
PROC
EXPORT MemManage_Handler [WEAK]
B .
ENDP
BusFault_Handler\
PROC
EXPORT BusFault_Handler [WEAK]
B .
ENDP
UsageFault_Handler\
PROC
EXPORT UsageFault_Handler [WEAK]
B .
ENDP
SVC_Handler PROC
EXPORT SVC_Handler [WEAK]
B .
ENDP
DebugMon_Handler\
PROC
EXPORT DebugMon_Handler [WEAK]
B .
ENDP
PendSV_Handler PROC
EXPORT PendSV_Handler [WEAK]
B .
ENDP
SysTick_Handler PROC
EXPORT SysTick_Handler [WEAK]
B .
ENDP
Default_Handler PROC
EXPORT WWDG_IRQHandler [WEAK]
EXPORT PVD_IRQHandler [WEAK]
EXPORT TAMP_STAMP_IRQHandler [WEAK]
EXPORT RTC_WKUP_IRQHandler [WEAK]
EXPORT FLASH_IRQHandler [WEAK]
EXPORT RCC_IRQHandler [WEAK]
EXPORT EXTI0_IRQHandler [WEAK]
EXPORT EXTI1_IRQHandler [WEAK]
EXPORT EXTI2_IRQHandler [WEAK]
EXPORT EXTI3_IRQHandler [WEAK]
EXPORT EXTI4_IRQHandler [WEAK]
EXPORT DMA1_Stream0_IRQHandler [WEAK]
EXPORT DMA1_Stream1_IRQHandler [WEAK]
EXPORT DMA1_Stream2_IRQHandler [WEAK]
EXPORT DMA1_Stream3_IRQHandler [WEAK]
EXPORT DMA1_Stream4_IRQHandler [WEAK]
EXPORT DMA1_Stream5_IRQHandler [WEAK]
EXPORT DMA1_Stream6_IRQHandler [WEAK]
EXPORT ADC_IRQHandler [WEAK]
EXPORT CAN1_TX_IRQHandler [WEAK]
EXPORT CAN1_RX0_IRQHandler [WEAK]
EXPORT CAN1_RX1_IRQHandler [WEAK]
EXPORT CAN1_SCE_IRQHandler [WEAK]
EXPORT EXTI9_5_IRQHandler [WEAK]
EXPORT TIM1_BRK_TIM9_IRQHandler [WEAK]
EXPORT TIM1_UP_TIM10_IRQHandler [WEAK]
EXPORT TIM1_TRG_COM_TIM11_IRQHandler [WEAK]
EXPORT TIM1_CC_IRQHandler [WEAK]
EXPORT TIM2_IRQHandler [WEAK]
EXPORT TIM3_IRQHandler [WEAK]
EXPORT TIM4_IRQHandler [WEAK]
EXPORT I2C1_EV_IRQHandler [WEAK]
EXPORT I2C1_ER_IRQHandler [WEAK]
EXPORT I2C2_EV_IRQHandler [WEAK]
EXPORT I2C2_ER_IRQHandler [WEAK]
EXPORT SPI1_IRQHandler [WEAK]
EXPORT SPI2_IRQHandler [WEAK]
EXPORT USART1_IRQHandler [WEAK]
EXPORT USART2_IRQHandler [WEAK]
EXPORT USART3_IRQHandler [WEAK]
EXPORT EXTI15_10_IRQHandler [WEAK]
EXPORT RTC_Alarm_IRQHandler [WEAK]
EXPORT OTG_FS_WKUP_IRQHandler [WEAK]
EXPORT TIM8_BRK_TIM12_IRQHandler [WEAK]
EXPORT TIM8_UP_TIM13_IRQHandler [WEAK]
EXPORT TIM8_TRG_COM_TIM14_IRQHandler [WEAK]
EXPORT TIM8_CC_IRQHandler [WEAK]
EXPORT DMA1_Stream7_IRQHandler [WEAK]
EXPORT FSMC_IRQHandler [WEAK]
EXPORT SDIO_IRQHandler [WEAK]
EXPORT TIM5_IRQHandler [WEAK]
EXPORT SPI3_IRQHandler [WEAK]
EXPORT UART4_IRQHandler [WEAK]
EXPORT UART5_IRQHandler [WEAK]
EXPORT TIM6_DAC_IRQHandler [WEAK]
EXPORT TIM7_IRQHandler [WEAK]
EXPORT DMA2_Stream0_IRQHandler [WEAK]
EXPORT DMA2_Stream1_IRQHandler [WEAK]
EXPORT DMA2_Stream2_IRQHandler [WEAK]
EXPORT DMA2_Stream3_IRQHandler [WEAK]
EXPORT DMA2_Stream4_IRQHandler [WEAK]
EXPORT ETH_IRQHandler [WEAK]
EXPORT ETH_WKUP_IRQHandler [WEAK]
EXPORT CAN2_TX_IRQHandler [WEAK]
EXPORT CAN2_RX0_IRQHandler [WEAK]
EXPORT CAN2_RX1_IRQHandler [WEAK]
EXPORT CAN2_SCE_IRQHandler [WEAK]
EXPORT OTG_FS_IRQHandler [WEAK]
EXPORT DMA2_Stream5_IRQHandler [WEAK]
EXPORT DMA2_Stream6_IRQHandler [WEAK]
EXPORT DMA2_Stream7_IRQHandler [WEAK]
EXPORT USART6_IRQHandler [WEAK]
EXPORT I2C3_EV_IRQHandler [WEAK]
EXPORT I2C3_ER_IRQHandler [WEAK]
EXPORT OTG_HS_EP1_OUT_IRQHandler [WEAK]
EXPORT OTG_HS_EP1_IN_IRQHandler [WEAK]
EXPORT OTG_HS_WKUP_IRQHandler [WEAK]
EXPORT OTG_HS_IRQHandler [WEAK]
EXPORT DCMI_IRQHandler [WEAK]
EXPORT CRYP_IRQHandler [WEAK]
EXPORT HASH_RNG_IRQHandler [WEAK]
EXPORT FPU_IRQHandler [WEAK]
WWDG_IRQHandler
PVD_IRQHandler
TAMP_STAMP_IRQHandler
RTC_WKUP_IRQHandler
FLASH_IRQHandler
RCC_IRQHandler
EXTI0_IRQHandler
EXTI1_IRQHandler
EXTI2_IRQHandler
EXTI3_IRQHandler
EXTI4_IRQHandler
DMA1_Stream0_IRQHandler
DMA1_Stream1_IRQHandler
DMA1_Stream2_IRQHandler
DMA1_Stream3_IRQHandler
DMA1_Stream4_IRQHandler
DMA1_Stream5_IRQHandler
DMA1_Stream6_IRQHandler
ADC_IRQHandler
CAN1_TX_IRQHandler
CAN1_RX0_IRQHandler
CAN1_RX1_IRQHandler
CAN1_SCE_IRQHandler
EXTI9_5_IRQHandler
TIM1_BRK_TIM9_IRQHandler
TIM1_UP_TIM10_IRQHandler
TIM1_TRG_COM_TIM11_IRQHandler
TIM1_CC_IRQHandler
TIM2_IRQHandler
TIM3_IRQHandler
TIM4_IRQHandler
I2C1_EV_IRQHandler
I2C1_ER_IRQHandler
I2C2_EV_IRQHandler
I2C2_ER_IRQHandler
SPI1_IRQHandler
SPI2_IRQHandler
USART1_IRQHandler
USART2_IRQHandler
USART3_IRQHandler
EXTI15_10_IRQHandler
RTC_Alarm_IRQHandler
OTG_FS_WKUP_IRQHandler
TIM8_BRK_TIM12_IRQHandler
TIM8_UP_TIM13_IRQHandler
TIM8_TRG_COM_TIM14_IRQHandler
TIM8_CC_IRQHandler
DMA1_Stream7_IRQHandler
FSMC_IRQHandler
SDIO_IRQHandler
TIM5_IRQHandler
SPI3_IRQHandler
UART4_IRQHandler
UART5_IRQHandler
TIM6_DAC_IRQHandler
TIM7_IRQHandler
DMA2_Stream0_IRQHandler
DMA2_Stream1_IRQHandler
DMA2_Stream2_IRQHandler
DMA2_Stream3_IRQHandler
DMA2_Stream4_IRQHandler
ETH_IRQHandler
ETH_WKUP_IRQHandler
CAN2_TX_IRQHandler
CAN2_RX0_IRQHandler
CAN2_RX1_IRQHandler
CAN2_SCE_IRQHandler
OTG_FS_IRQHandler
DMA2_Stream5_IRQHandler
DMA2_Stream6_IRQHandler
DMA2_Stream7_IRQHandler
USART6_IRQHandler
I2C3_EV_IRQHandler
I2C3_ER_IRQHandler
OTG_HS_EP1_OUT_IRQHandler
OTG_HS_EP1_IN_IRQHandler
OTG_HS_WKUP_IRQHandler
OTG_HS_IRQHandler
DCMI_IRQHandler
CRYP_IRQHandler
HASH_RNG_IRQHandler
FPU_IRQHandler
B .
ENDP
ALIGN
;*******************************************************************************
; User Stack and Heap initialization
;*******************************************************************************
IF :DEF:__MICROLIB
EXPORT __initial_sp
EXPORT __heap_base
EXPORT __heap_limit
ELSE
IMPORT __use_two_region_memory
EXPORT __user_initial_stackheap
__user_initial_stackheap
LDR R0, = Heap_Mem
LDR R1, =(Stack_Mem + Stack_Size)
LDR R2, = (Heap_Mem + Heap_Size)
LDR R3, = Stack_Mem
BX LR
ALIGN
ENDIF
END
;************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE*****
|
903257958/stm32_oop_driver
| 29,173
|
stm32f405rg_drivers/stm32f405rg_key_fifo/firmware/cmsis/device/startup_stm32f40_41xxx.s
|
;******************** (C) COPYRIGHT 2016 STMicroelectronics ********************
;* File Name : startup_stm32f40_41xxx.s
;* Author : MCD Application Team
;* @version : V1.8.0
;* @date : 09-November-2016
;* Description : STM32F40xxx/41xxx devices vector table for MDK-ARM toolchain.
;* This module performs:
;* - Set the initial SP
;* - Set the initial PC == Reset_Handler
;* - Set the vector table entries with the exceptions ISR address
;* - Configure the system clock and the external SRAM mounted on
;* STM324xG-EVAL board to be used as data memory (optional,
;* to be enabled by user)
;* - Branches to __main in the C library (which eventually
;* calls main()).
;* After Reset the CortexM4 processor is in Thread mode,
;* priority is Privileged, and the Stack is set to Main.
;* <<< Use Configuration Wizard in Context Menu >>>
;*******************************************************************************
;
; Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
; You may not use this file except in compliance with the License.
; You may obtain a copy of the License at:
;
; http://www.st.com/software_license_agreement_liberty_v2
;
; Unless required by applicable law or agreed to in writing, software
; distributed under the License is distributed on an "AS IS" BASIS,
; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
; See the License for the specific language governing permissions and
; limitations under the License.
;
;*******************************************************************************
; Amount of memory (in bytes) allocated for Stack
; Tailor this value to your application needs
; <h> Stack Configuration
; <o> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
; </h>
Stack_Size EQU 0x00000400
AREA STACK, NOINIT, READWRITE, ALIGN=3
Stack_Mem SPACE Stack_Size
__initial_sp
; <h> Heap Configuration
; <o> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
; </h>
Heap_Size EQU 0x00000200
AREA HEAP, NOINIT, READWRITE, ALIGN=3
__heap_base
Heap_Mem SPACE Heap_Size
__heap_limit
PRESERVE8
THUMB
; Vector Table Mapped to Address 0 at Reset
AREA RESET, DATA, READONLY
EXPORT __Vectors
EXPORT __Vectors_End
EXPORT __Vectors_Size
__Vectors DCD __initial_sp ; Top of Stack
DCD Reset_Handler ; Reset Handler
DCD NMI_Handler ; NMI Handler
DCD HardFault_Handler ; Hard Fault Handler
DCD MemManage_Handler ; MPU Fault Handler
DCD BusFault_Handler ; Bus Fault Handler
DCD UsageFault_Handler ; Usage Fault Handler
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD SVC_Handler ; SVCall Handler
DCD DebugMon_Handler ; Debug Monitor Handler
DCD 0 ; Reserved
DCD PendSV_Handler ; PendSV Handler
DCD SysTick_Handler ; SysTick Handler
; External Interrupts
DCD WWDG_IRQHandler ; Window WatchDog
DCD PVD_IRQHandler ; PVD through EXTI Line detection
DCD TAMP_STAMP_IRQHandler ; Tamper and TimeStamps through the EXTI line
DCD RTC_WKUP_IRQHandler ; RTC Wakeup through the EXTI line
DCD FLASH_IRQHandler ; FLASH
DCD RCC_IRQHandler ; RCC
DCD EXTI0_IRQHandler ; EXTI Line0
DCD EXTI1_IRQHandler ; EXTI Line1
DCD EXTI2_IRQHandler ; EXTI Line2
DCD EXTI3_IRQHandler ; EXTI Line3
DCD EXTI4_IRQHandler ; EXTI Line4
DCD DMA1_Stream0_IRQHandler ; DMA1 Stream 0
DCD DMA1_Stream1_IRQHandler ; DMA1 Stream 1
DCD DMA1_Stream2_IRQHandler ; DMA1 Stream 2
DCD DMA1_Stream3_IRQHandler ; DMA1 Stream 3
DCD DMA1_Stream4_IRQHandler ; DMA1 Stream 4
DCD DMA1_Stream5_IRQHandler ; DMA1 Stream 5
DCD DMA1_Stream6_IRQHandler ; DMA1 Stream 6
DCD ADC_IRQHandler ; ADC1, ADC2 and ADC3s
DCD CAN1_TX_IRQHandler ; CAN1 TX
DCD CAN1_RX0_IRQHandler ; CAN1 RX0
DCD CAN1_RX1_IRQHandler ; CAN1 RX1
DCD CAN1_SCE_IRQHandler ; CAN1 SCE
DCD EXTI9_5_IRQHandler ; External Line[9:5]s
DCD TIM1_BRK_TIM9_IRQHandler ; TIM1 Break and TIM9
DCD TIM1_UP_TIM10_IRQHandler ; TIM1 Update and TIM10
DCD TIM1_TRG_COM_TIM11_IRQHandler ; TIM1 Trigger and Commutation and TIM11
DCD TIM1_CC_IRQHandler ; TIM1 Capture Compare
DCD TIM2_IRQHandler ; TIM2
DCD TIM3_IRQHandler ; TIM3
DCD TIM4_IRQHandler ; TIM4
DCD I2C1_EV_IRQHandler ; I2C1 Event
DCD I2C1_ER_IRQHandler ; I2C1 Error
DCD I2C2_EV_IRQHandler ; I2C2 Event
DCD I2C2_ER_IRQHandler ; I2C2 Error
DCD SPI1_IRQHandler ; SPI1
DCD SPI2_IRQHandler ; SPI2
DCD USART1_IRQHandler ; USART1
DCD USART2_IRQHandler ; USART2
DCD USART3_IRQHandler ; USART3
DCD EXTI15_10_IRQHandler ; External Line[15:10]s
DCD RTC_Alarm_IRQHandler ; RTC Alarm (A and B) through EXTI Line
DCD OTG_FS_WKUP_IRQHandler ; USB OTG FS Wakeup through EXTI line
DCD TIM8_BRK_TIM12_IRQHandler ; TIM8 Break and TIM12
DCD TIM8_UP_TIM13_IRQHandler ; TIM8 Update and TIM13
DCD TIM8_TRG_COM_TIM14_IRQHandler ; TIM8 Trigger and Commutation and TIM14
DCD TIM8_CC_IRQHandler ; TIM8 Capture Compare
DCD DMA1_Stream7_IRQHandler ; DMA1 Stream7
DCD FSMC_IRQHandler ; FSMC
DCD SDIO_IRQHandler ; SDIO
DCD TIM5_IRQHandler ; TIM5
DCD SPI3_IRQHandler ; SPI3
DCD UART4_IRQHandler ; UART4
DCD UART5_IRQHandler ; UART5
DCD TIM6_DAC_IRQHandler ; TIM6 and DAC1&2 underrun errors
DCD TIM7_IRQHandler ; TIM7
DCD DMA2_Stream0_IRQHandler ; DMA2 Stream 0
DCD DMA2_Stream1_IRQHandler ; DMA2 Stream 1
DCD DMA2_Stream2_IRQHandler ; DMA2 Stream 2
DCD DMA2_Stream3_IRQHandler ; DMA2 Stream 3
DCD DMA2_Stream4_IRQHandler ; DMA2 Stream 4
DCD ETH_IRQHandler ; Ethernet
DCD ETH_WKUP_IRQHandler ; Ethernet Wakeup through EXTI line
DCD CAN2_TX_IRQHandler ; CAN2 TX
DCD CAN2_RX0_IRQHandler ; CAN2 RX0
DCD CAN2_RX1_IRQHandler ; CAN2 RX1
DCD CAN2_SCE_IRQHandler ; CAN2 SCE
DCD OTG_FS_IRQHandler ; USB OTG FS
DCD DMA2_Stream5_IRQHandler ; DMA2 Stream 5
DCD DMA2_Stream6_IRQHandler ; DMA2 Stream 6
DCD DMA2_Stream7_IRQHandler ; DMA2 Stream 7
DCD USART6_IRQHandler ; USART6
DCD I2C3_EV_IRQHandler ; I2C3 event
DCD I2C3_ER_IRQHandler ; I2C3 error
DCD OTG_HS_EP1_OUT_IRQHandler ; USB OTG HS End Point 1 Out
DCD OTG_HS_EP1_IN_IRQHandler ; USB OTG HS End Point 1 In
DCD OTG_HS_WKUP_IRQHandler ; USB OTG HS Wakeup through EXTI
DCD OTG_HS_IRQHandler ; USB OTG HS
DCD DCMI_IRQHandler ; DCMI
DCD CRYP_IRQHandler ; CRYP crypto
DCD HASH_RNG_IRQHandler ; Hash and Rng
DCD FPU_IRQHandler ; FPU
__Vectors_End
__Vectors_Size EQU __Vectors_End - __Vectors
AREA |.text|, CODE, READONLY
; Reset handler
Reset_Handler PROC
EXPORT Reset_Handler [WEAK]
IMPORT SystemInit
IMPORT __main
LDR R0, =SystemInit
BLX R0
LDR R0, =__main
BX R0
ENDP
; Dummy Exception Handlers (infinite loops which can be modified)
NMI_Handler PROC
EXPORT NMI_Handler [WEAK]
B .
ENDP
HardFault_Handler\
PROC
EXPORT HardFault_Handler [WEAK]
B .
ENDP
MemManage_Handler\
PROC
EXPORT MemManage_Handler [WEAK]
B .
ENDP
BusFault_Handler\
PROC
EXPORT BusFault_Handler [WEAK]
B .
ENDP
UsageFault_Handler\
PROC
EXPORT UsageFault_Handler [WEAK]
B .
ENDP
SVC_Handler PROC
EXPORT SVC_Handler [WEAK]
B .
ENDP
DebugMon_Handler\
PROC
EXPORT DebugMon_Handler [WEAK]
B .
ENDP
PendSV_Handler PROC
EXPORT PendSV_Handler [WEAK]
B .
ENDP
SysTick_Handler PROC
EXPORT SysTick_Handler [WEAK]
B .
ENDP
Default_Handler PROC
EXPORT WWDG_IRQHandler [WEAK]
EXPORT PVD_IRQHandler [WEAK]
EXPORT TAMP_STAMP_IRQHandler [WEAK]
EXPORT RTC_WKUP_IRQHandler [WEAK]
EXPORT FLASH_IRQHandler [WEAK]
EXPORT RCC_IRQHandler [WEAK]
EXPORT EXTI0_IRQHandler [WEAK]
EXPORT EXTI1_IRQHandler [WEAK]
EXPORT EXTI2_IRQHandler [WEAK]
EXPORT EXTI3_IRQHandler [WEAK]
EXPORT EXTI4_IRQHandler [WEAK]
EXPORT DMA1_Stream0_IRQHandler [WEAK]
EXPORT DMA1_Stream1_IRQHandler [WEAK]
EXPORT DMA1_Stream2_IRQHandler [WEAK]
EXPORT DMA1_Stream3_IRQHandler [WEAK]
EXPORT DMA1_Stream4_IRQHandler [WEAK]
EXPORT DMA1_Stream5_IRQHandler [WEAK]
EXPORT DMA1_Stream6_IRQHandler [WEAK]
EXPORT ADC_IRQHandler [WEAK]
EXPORT CAN1_TX_IRQHandler [WEAK]
EXPORT CAN1_RX0_IRQHandler [WEAK]
EXPORT CAN1_RX1_IRQHandler [WEAK]
EXPORT CAN1_SCE_IRQHandler [WEAK]
EXPORT EXTI9_5_IRQHandler [WEAK]
EXPORT TIM1_BRK_TIM9_IRQHandler [WEAK]
EXPORT TIM1_UP_TIM10_IRQHandler [WEAK]
EXPORT TIM1_TRG_COM_TIM11_IRQHandler [WEAK]
EXPORT TIM1_CC_IRQHandler [WEAK]
EXPORT TIM2_IRQHandler [WEAK]
EXPORT TIM3_IRQHandler [WEAK]
EXPORT TIM4_IRQHandler [WEAK]
EXPORT I2C1_EV_IRQHandler [WEAK]
EXPORT I2C1_ER_IRQHandler [WEAK]
EXPORT I2C2_EV_IRQHandler [WEAK]
EXPORT I2C2_ER_IRQHandler [WEAK]
EXPORT SPI1_IRQHandler [WEAK]
EXPORT SPI2_IRQHandler [WEAK]
EXPORT USART1_IRQHandler [WEAK]
EXPORT USART2_IRQHandler [WEAK]
EXPORT USART3_IRQHandler [WEAK]
EXPORT EXTI15_10_IRQHandler [WEAK]
EXPORT RTC_Alarm_IRQHandler [WEAK]
EXPORT OTG_FS_WKUP_IRQHandler [WEAK]
EXPORT TIM8_BRK_TIM12_IRQHandler [WEAK]
EXPORT TIM8_UP_TIM13_IRQHandler [WEAK]
EXPORT TIM8_TRG_COM_TIM14_IRQHandler [WEAK]
EXPORT TIM8_CC_IRQHandler [WEAK]
EXPORT DMA1_Stream7_IRQHandler [WEAK]
EXPORT FSMC_IRQHandler [WEAK]
EXPORT SDIO_IRQHandler [WEAK]
EXPORT TIM5_IRQHandler [WEAK]
EXPORT SPI3_IRQHandler [WEAK]
EXPORT UART4_IRQHandler [WEAK]
EXPORT UART5_IRQHandler [WEAK]
EXPORT TIM6_DAC_IRQHandler [WEAK]
EXPORT TIM7_IRQHandler [WEAK]
EXPORT DMA2_Stream0_IRQHandler [WEAK]
EXPORT DMA2_Stream1_IRQHandler [WEAK]
EXPORT DMA2_Stream2_IRQHandler [WEAK]
EXPORT DMA2_Stream3_IRQHandler [WEAK]
EXPORT DMA2_Stream4_IRQHandler [WEAK]
EXPORT ETH_IRQHandler [WEAK]
EXPORT ETH_WKUP_IRQHandler [WEAK]
EXPORT CAN2_TX_IRQHandler [WEAK]
EXPORT CAN2_RX0_IRQHandler [WEAK]
EXPORT CAN2_RX1_IRQHandler [WEAK]
EXPORT CAN2_SCE_IRQHandler [WEAK]
EXPORT OTG_FS_IRQHandler [WEAK]
EXPORT DMA2_Stream5_IRQHandler [WEAK]
EXPORT DMA2_Stream6_IRQHandler [WEAK]
EXPORT DMA2_Stream7_IRQHandler [WEAK]
EXPORT USART6_IRQHandler [WEAK]
EXPORT I2C3_EV_IRQHandler [WEAK]
EXPORT I2C3_ER_IRQHandler [WEAK]
EXPORT OTG_HS_EP1_OUT_IRQHandler [WEAK]
EXPORT OTG_HS_EP1_IN_IRQHandler [WEAK]
EXPORT OTG_HS_WKUP_IRQHandler [WEAK]
EXPORT OTG_HS_IRQHandler [WEAK]
EXPORT DCMI_IRQHandler [WEAK]
EXPORT CRYP_IRQHandler [WEAK]
EXPORT HASH_RNG_IRQHandler [WEAK]
EXPORT FPU_IRQHandler [WEAK]
WWDG_IRQHandler
PVD_IRQHandler
TAMP_STAMP_IRQHandler
RTC_WKUP_IRQHandler
FLASH_IRQHandler
RCC_IRQHandler
EXTI0_IRQHandler
EXTI1_IRQHandler
EXTI2_IRQHandler
EXTI3_IRQHandler
EXTI4_IRQHandler
DMA1_Stream0_IRQHandler
DMA1_Stream1_IRQHandler
DMA1_Stream2_IRQHandler
DMA1_Stream3_IRQHandler
DMA1_Stream4_IRQHandler
DMA1_Stream5_IRQHandler
DMA1_Stream6_IRQHandler
ADC_IRQHandler
CAN1_TX_IRQHandler
CAN1_RX0_IRQHandler
CAN1_RX1_IRQHandler
CAN1_SCE_IRQHandler
EXTI9_5_IRQHandler
TIM1_BRK_TIM9_IRQHandler
TIM1_UP_TIM10_IRQHandler
TIM1_TRG_COM_TIM11_IRQHandler
TIM1_CC_IRQHandler
TIM2_IRQHandler
TIM3_IRQHandler
TIM4_IRQHandler
I2C1_EV_IRQHandler
I2C1_ER_IRQHandler
I2C2_EV_IRQHandler
I2C2_ER_IRQHandler
SPI1_IRQHandler
SPI2_IRQHandler
USART1_IRQHandler
USART2_IRQHandler
USART3_IRQHandler
EXTI15_10_IRQHandler
RTC_Alarm_IRQHandler
OTG_FS_WKUP_IRQHandler
TIM8_BRK_TIM12_IRQHandler
TIM8_UP_TIM13_IRQHandler
TIM8_TRG_COM_TIM14_IRQHandler
TIM8_CC_IRQHandler
DMA1_Stream7_IRQHandler
FSMC_IRQHandler
SDIO_IRQHandler
TIM5_IRQHandler
SPI3_IRQHandler
UART4_IRQHandler
UART5_IRQHandler
TIM6_DAC_IRQHandler
TIM7_IRQHandler
DMA2_Stream0_IRQHandler
DMA2_Stream1_IRQHandler
DMA2_Stream2_IRQHandler
DMA2_Stream3_IRQHandler
DMA2_Stream4_IRQHandler
ETH_IRQHandler
ETH_WKUP_IRQHandler
CAN2_TX_IRQHandler
CAN2_RX0_IRQHandler
CAN2_RX1_IRQHandler
CAN2_SCE_IRQHandler
OTG_FS_IRQHandler
DMA2_Stream5_IRQHandler
DMA2_Stream6_IRQHandler
DMA2_Stream7_IRQHandler
USART6_IRQHandler
I2C3_EV_IRQHandler
I2C3_ER_IRQHandler
OTG_HS_EP1_OUT_IRQHandler
OTG_HS_EP1_IN_IRQHandler
OTG_HS_WKUP_IRQHandler
OTG_HS_IRQHandler
DCMI_IRQHandler
CRYP_IRQHandler
HASH_RNG_IRQHandler
FPU_IRQHandler
B .
ENDP
ALIGN
;*******************************************************************************
; User Stack and Heap initialization
;*******************************************************************************
IF :DEF:__MICROLIB
EXPORT __initial_sp
EXPORT __heap_base
EXPORT __heap_limit
ELSE
IMPORT __use_two_region_memory
EXPORT __user_initial_stackheap
__user_initial_stackheap
LDR R0, = Heap_Mem
LDR R1, =(Stack_Mem + Stack_Size)
LDR R2, = (Heap_Mem + Heap_Size)
LDR R3, = Stack_Mem
BX LR
ALIGN
ENDIF
END
;************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE*****
|
903257958/stm32_oop_driver
| 29,173
|
stm32f405rg_drivers/stm32f405rg_i2c_soft_max30102/firmware/cmsis/device/startup_stm32f40_41xxx.s
|
;******************** (C) COPYRIGHT 2016 STMicroelectronics ********************
;* File Name : startup_stm32f40_41xxx.s
;* Author : MCD Application Team
;* @version : V1.8.0
;* @date : 09-November-2016
;* Description : STM32F40xxx/41xxx devices vector table for MDK-ARM toolchain.
;* This module performs:
;* - Set the initial SP
;* - Set the initial PC == Reset_Handler
;* - Set the vector table entries with the exceptions ISR address
;* - Configure the system clock and the external SRAM mounted on
;* STM324xG-EVAL board to be used as data memory (optional,
;* to be enabled by user)
;* - Branches to __main in the C library (which eventually
;* calls main()).
;* After Reset the CortexM4 processor is in Thread mode,
;* priority is Privileged, and the Stack is set to Main.
;* <<< Use Configuration Wizard in Context Menu >>>
;*******************************************************************************
;
; Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
; You may not use this file except in compliance with the License.
; You may obtain a copy of the License at:
;
; http://www.st.com/software_license_agreement_liberty_v2
;
; Unless required by applicable law or agreed to in writing, software
; distributed under the License is distributed on an "AS IS" BASIS,
; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
; See the License for the specific language governing permissions and
; limitations under the License.
;
;*******************************************************************************
; Amount of memory (in bytes) allocated for Stack
; Tailor this value to your application needs
; <h> Stack Configuration
; <o> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
; </h>
Stack_Size EQU 0x00000400
AREA STACK, NOINIT, READWRITE, ALIGN=3
Stack_Mem SPACE Stack_Size
__initial_sp
; <h> Heap Configuration
; <o> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
; </h>
Heap_Size EQU 0x00000200
AREA HEAP, NOINIT, READWRITE, ALIGN=3
__heap_base
Heap_Mem SPACE Heap_Size
__heap_limit
PRESERVE8
THUMB
; Vector Table Mapped to Address 0 at Reset
AREA RESET, DATA, READONLY
EXPORT __Vectors
EXPORT __Vectors_End
EXPORT __Vectors_Size
__Vectors DCD __initial_sp ; Top of Stack
DCD Reset_Handler ; Reset Handler
DCD NMI_Handler ; NMI Handler
DCD HardFault_Handler ; Hard Fault Handler
DCD MemManage_Handler ; MPU Fault Handler
DCD BusFault_Handler ; Bus Fault Handler
DCD UsageFault_Handler ; Usage Fault Handler
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD SVC_Handler ; SVCall Handler
DCD DebugMon_Handler ; Debug Monitor Handler
DCD 0 ; Reserved
DCD PendSV_Handler ; PendSV Handler
DCD SysTick_Handler ; SysTick Handler
; External Interrupts
DCD WWDG_IRQHandler ; Window WatchDog
DCD PVD_IRQHandler ; PVD through EXTI Line detection
DCD TAMP_STAMP_IRQHandler ; Tamper and TimeStamps through the EXTI line
DCD RTC_WKUP_IRQHandler ; RTC Wakeup through the EXTI line
DCD FLASH_IRQHandler ; FLASH
DCD RCC_IRQHandler ; RCC
DCD EXTI0_IRQHandler ; EXTI Line0
DCD EXTI1_IRQHandler ; EXTI Line1
DCD EXTI2_IRQHandler ; EXTI Line2
DCD EXTI3_IRQHandler ; EXTI Line3
DCD EXTI4_IRQHandler ; EXTI Line4
DCD DMA1_Stream0_IRQHandler ; DMA1 Stream 0
DCD DMA1_Stream1_IRQHandler ; DMA1 Stream 1
DCD DMA1_Stream2_IRQHandler ; DMA1 Stream 2
DCD DMA1_Stream3_IRQHandler ; DMA1 Stream 3
DCD DMA1_Stream4_IRQHandler ; DMA1 Stream 4
DCD DMA1_Stream5_IRQHandler ; DMA1 Stream 5
DCD DMA1_Stream6_IRQHandler ; DMA1 Stream 6
DCD ADC_IRQHandler ; ADC1, ADC2 and ADC3s
DCD CAN1_TX_IRQHandler ; CAN1 TX
DCD CAN1_RX0_IRQHandler ; CAN1 RX0
DCD CAN1_RX1_IRQHandler ; CAN1 RX1
DCD CAN1_SCE_IRQHandler ; CAN1 SCE
DCD EXTI9_5_IRQHandler ; External Line[9:5]s
DCD TIM1_BRK_TIM9_IRQHandler ; TIM1 Break and TIM9
DCD TIM1_UP_TIM10_IRQHandler ; TIM1 Update and TIM10
DCD TIM1_TRG_COM_TIM11_IRQHandler ; TIM1 Trigger and Commutation and TIM11
DCD TIM1_CC_IRQHandler ; TIM1 Capture Compare
DCD TIM2_IRQHandler ; TIM2
DCD TIM3_IRQHandler ; TIM3
DCD TIM4_IRQHandler ; TIM4
DCD I2C1_EV_IRQHandler ; I2C1 Event
DCD I2C1_ER_IRQHandler ; I2C1 Error
DCD I2C2_EV_IRQHandler ; I2C2 Event
DCD I2C2_ER_IRQHandler ; I2C2 Error
DCD SPI1_IRQHandler ; SPI1
DCD SPI2_IRQHandler ; SPI2
DCD USART1_IRQHandler ; USART1
DCD USART2_IRQHandler ; USART2
DCD USART3_IRQHandler ; USART3
DCD EXTI15_10_IRQHandler ; External Line[15:10]s
DCD RTC_Alarm_IRQHandler ; RTC Alarm (A and B) through EXTI Line
DCD OTG_FS_WKUP_IRQHandler ; USB OTG FS Wakeup through EXTI line
DCD TIM8_BRK_TIM12_IRQHandler ; TIM8 Break and TIM12
DCD TIM8_UP_TIM13_IRQHandler ; TIM8 Update and TIM13
DCD TIM8_TRG_COM_TIM14_IRQHandler ; TIM8 Trigger and Commutation and TIM14
DCD TIM8_CC_IRQHandler ; TIM8 Capture Compare
DCD DMA1_Stream7_IRQHandler ; DMA1 Stream7
DCD FSMC_IRQHandler ; FSMC
DCD SDIO_IRQHandler ; SDIO
DCD TIM5_IRQHandler ; TIM5
DCD SPI3_IRQHandler ; SPI3
DCD UART4_IRQHandler ; UART4
DCD UART5_IRQHandler ; UART5
DCD TIM6_DAC_IRQHandler ; TIM6 and DAC1&2 underrun errors
DCD TIM7_IRQHandler ; TIM7
DCD DMA2_Stream0_IRQHandler ; DMA2 Stream 0
DCD DMA2_Stream1_IRQHandler ; DMA2 Stream 1
DCD DMA2_Stream2_IRQHandler ; DMA2 Stream 2
DCD DMA2_Stream3_IRQHandler ; DMA2 Stream 3
DCD DMA2_Stream4_IRQHandler ; DMA2 Stream 4
DCD ETH_IRQHandler ; Ethernet
DCD ETH_WKUP_IRQHandler ; Ethernet Wakeup through EXTI line
DCD CAN2_TX_IRQHandler ; CAN2 TX
DCD CAN2_RX0_IRQHandler ; CAN2 RX0
DCD CAN2_RX1_IRQHandler ; CAN2 RX1
DCD CAN2_SCE_IRQHandler ; CAN2 SCE
DCD OTG_FS_IRQHandler ; USB OTG FS
DCD DMA2_Stream5_IRQHandler ; DMA2 Stream 5
DCD DMA2_Stream6_IRQHandler ; DMA2 Stream 6
DCD DMA2_Stream7_IRQHandler ; DMA2 Stream 7
DCD USART6_IRQHandler ; USART6
DCD I2C3_EV_IRQHandler ; I2C3 event
DCD I2C3_ER_IRQHandler ; I2C3 error
DCD OTG_HS_EP1_OUT_IRQHandler ; USB OTG HS End Point 1 Out
DCD OTG_HS_EP1_IN_IRQHandler ; USB OTG HS End Point 1 In
DCD OTG_HS_WKUP_IRQHandler ; USB OTG HS Wakeup through EXTI
DCD OTG_HS_IRQHandler ; USB OTG HS
DCD DCMI_IRQHandler ; DCMI
DCD CRYP_IRQHandler ; CRYP crypto
DCD HASH_RNG_IRQHandler ; Hash and Rng
DCD FPU_IRQHandler ; FPU
__Vectors_End
__Vectors_Size EQU __Vectors_End - __Vectors
AREA |.text|, CODE, READONLY
; Reset handler
Reset_Handler PROC
EXPORT Reset_Handler [WEAK]
IMPORT SystemInit
IMPORT __main
LDR R0, =SystemInit
BLX R0
LDR R0, =__main
BX R0
ENDP
; Dummy Exception Handlers (infinite loops which can be modified)
NMI_Handler PROC
EXPORT NMI_Handler [WEAK]
B .
ENDP
HardFault_Handler\
PROC
EXPORT HardFault_Handler [WEAK]
B .
ENDP
MemManage_Handler\
PROC
EXPORT MemManage_Handler [WEAK]
B .
ENDP
BusFault_Handler\
PROC
EXPORT BusFault_Handler [WEAK]
B .
ENDP
UsageFault_Handler\
PROC
EXPORT UsageFault_Handler [WEAK]
B .
ENDP
SVC_Handler PROC
EXPORT SVC_Handler [WEAK]
B .
ENDP
DebugMon_Handler\
PROC
EXPORT DebugMon_Handler [WEAK]
B .
ENDP
PendSV_Handler PROC
EXPORT PendSV_Handler [WEAK]
B .
ENDP
SysTick_Handler PROC
EXPORT SysTick_Handler [WEAK]
B .
ENDP
Default_Handler PROC
EXPORT WWDG_IRQHandler [WEAK]
EXPORT PVD_IRQHandler [WEAK]
EXPORT TAMP_STAMP_IRQHandler [WEAK]
EXPORT RTC_WKUP_IRQHandler [WEAK]
EXPORT FLASH_IRQHandler [WEAK]
EXPORT RCC_IRQHandler [WEAK]
EXPORT EXTI0_IRQHandler [WEAK]
EXPORT EXTI1_IRQHandler [WEAK]
EXPORT EXTI2_IRQHandler [WEAK]
EXPORT EXTI3_IRQHandler [WEAK]
EXPORT EXTI4_IRQHandler [WEAK]
EXPORT DMA1_Stream0_IRQHandler [WEAK]
EXPORT DMA1_Stream1_IRQHandler [WEAK]
EXPORT DMA1_Stream2_IRQHandler [WEAK]
EXPORT DMA1_Stream3_IRQHandler [WEAK]
EXPORT DMA1_Stream4_IRQHandler [WEAK]
EXPORT DMA1_Stream5_IRQHandler [WEAK]
EXPORT DMA1_Stream6_IRQHandler [WEAK]
EXPORT ADC_IRQHandler [WEAK]
EXPORT CAN1_TX_IRQHandler [WEAK]
EXPORT CAN1_RX0_IRQHandler [WEAK]
EXPORT CAN1_RX1_IRQHandler [WEAK]
EXPORT CAN1_SCE_IRQHandler [WEAK]
EXPORT EXTI9_5_IRQHandler [WEAK]
EXPORT TIM1_BRK_TIM9_IRQHandler [WEAK]
EXPORT TIM1_UP_TIM10_IRQHandler [WEAK]
EXPORT TIM1_TRG_COM_TIM11_IRQHandler [WEAK]
EXPORT TIM1_CC_IRQHandler [WEAK]
EXPORT TIM2_IRQHandler [WEAK]
EXPORT TIM3_IRQHandler [WEAK]
EXPORT TIM4_IRQHandler [WEAK]
EXPORT I2C1_EV_IRQHandler [WEAK]
EXPORT I2C1_ER_IRQHandler [WEAK]
EXPORT I2C2_EV_IRQHandler [WEAK]
EXPORT I2C2_ER_IRQHandler [WEAK]
EXPORT SPI1_IRQHandler [WEAK]
EXPORT SPI2_IRQHandler [WEAK]
EXPORT USART1_IRQHandler [WEAK]
EXPORT USART2_IRQHandler [WEAK]
EXPORT USART3_IRQHandler [WEAK]
EXPORT EXTI15_10_IRQHandler [WEAK]
EXPORT RTC_Alarm_IRQHandler [WEAK]
EXPORT OTG_FS_WKUP_IRQHandler [WEAK]
EXPORT TIM8_BRK_TIM12_IRQHandler [WEAK]
EXPORT TIM8_UP_TIM13_IRQHandler [WEAK]
EXPORT TIM8_TRG_COM_TIM14_IRQHandler [WEAK]
EXPORT TIM8_CC_IRQHandler [WEAK]
EXPORT DMA1_Stream7_IRQHandler [WEAK]
EXPORT FSMC_IRQHandler [WEAK]
EXPORT SDIO_IRQHandler [WEAK]
EXPORT TIM5_IRQHandler [WEAK]
EXPORT SPI3_IRQHandler [WEAK]
EXPORT UART4_IRQHandler [WEAK]
EXPORT UART5_IRQHandler [WEAK]
EXPORT TIM6_DAC_IRQHandler [WEAK]
EXPORT TIM7_IRQHandler [WEAK]
EXPORT DMA2_Stream0_IRQHandler [WEAK]
EXPORT DMA2_Stream1_IRQHandler [WEAK]
EXPORT DMA2_Stream2_IRQHandler [WEAK]
EXPORT DMA2_Stream3_IRQHandler [WEAK]
EXPORT DMA2_Stream4_IRQHandler [WEAK]
EXPORT ETH_IRQHandler [WEAK]
EXPORT ETH_WKUP_IRQHandler [WEAK]
EXPORT CAN2_TX_IRQHandler [WEAK]
EXPORT CAN2_RX0_IRQHandler [WEAK]
EXPORT CAN2_RX1_IRQHandler [WEAK]
EXPORT CAN2_SCE_IRQHandler [WEAK]
EXPORT OTG_FS_IRQHandler [WEAK]
EXPORT DMA2_Stream5_IRQHandler [WEAK]
EXPORT DMA2_Stream6_IRQHandler [WEAK]
EXPORT DMA2_Stream7_IRQHandler [WEAK]
EXPORT USART6_IRQHandler [WEAK]
EXPORT I2C3_EV_IRQHandler [WEAK]
EXPORT I2C3_ER_IRQHandler [WEAK]
EXPORT OTG_HS_EP1_OUT_IRQHandler [WEAK]
EXPORT OTG_HS_EP1_IN_IRQHandler [WEAK]
EXPORT OTG_HS_WKUP_IRQHandler [WEAK]
EXPORT OTG_HS_IRQHandler [WEAK]
EXPORT DCMI_IRQHandler [WEAK]
EXPORT CRYP_IRQHandler [WEAK]
EXPORT HASH_RNG_IRQHandler [WEAK]
EXPORT FPU_IRQHandler [WEAK]
WWDG_IRQHandler
PVD_IRQHandler
TAMP_STAMP_IRQHandler
RTC_WKUP_IRQHandler
FLASH_IRQHandler
RCC_IRQHandler
EXTI0_IRQHandler
EXTI1_IRQHandler
EXTI2_IRQHandler
EXTI3_IRQHandler
EXTI4_IRQHandler
DMA1_Stream0_IRQHandler
DMA1_Stream1_IRQHandler
DMA1_Stream2_IRQHandler
DMA1_Stream3_IRQHandler
DMA1_Stream4_IRQHandler
DMA1_Stream5_IRQHandler
DMA1_Stream6_IRQHandler
ADC_IRQHandler
CAN1_TX_IRQHandler
CAN1_RX0_IRQHandler
CAN1_RX1_IRQHandler
CAN1_SCE_IRQHandler
EXTI9_5_IRQHandler
TIM1_BRK_TIM9_IRQHandler
TIM1_UP_TIM10_IRQHandler
TIM1_TRG_COM_TIM11_IRQHandler
TIM1_CC_IRQHandler
TIM2_IRQHandler
TIM3_IRQHandler
TIM4_IRQHandler
I2C1_EV_IRQHandler
I2C1_ER_IRQHandler
I2C2_EV_IRQHandler
I2C2_ER_IRQHandler
SPI1_IRQHandler
SPI2_IRQHandler
USART1_IRQHandler
USART2_IRQHandler
USART3_IRQHandler
EXTI15_10_IRQHandler
RTC_Alarm_IRQHandler
OTG_FS_WKUP_IRQHandler
TIM8_BRK_TIM12_IRQHandler
TIM8_UP_TIM13_IRQHandler
TIM8_TRG_COM_TIM14_IRQHandler
TIM8_CC_IRQHandler
DMA1_Stream7_IRQHandler
FSMC_IRQHandler
SDIO_IRQHandler
TIM5_IRQHandler
SPI3_IRQHandler
UART4_IRQHandler
UART5_IRQHandler
TIM6_DAC_IRQHandler
TIM7_IRQHandler
DMA2_Stream0_IRQHandler
DMA2_Stream1_IRQHandler
DMA2_Stream2_IRQHandler
DMA2_Stream3_IRQHandler
DMA2_Stream4_IRQHandler
ETH_IRQHandler
ETH_WKUP_IRQHandler
CAN2_TX_IRQHandler
CAN2_RX0_IRQHandler
CAN2_RX1_IRQHandler
CAN2_SCE_IRQHandler
OTG_FS_IRQHandler
DMA2_Stream5_IRQHandler
DMA2_Stream6_IRQHandler
DMA2_Stream7_IRQHandler
USART6_IRQHandler
I2C3_EV_IRQHandler
I2C3_ER_IRQHandler
OTG_HS_EP1_OUT_IRQHandler
OTG_HS_EP1_IN_IRQHandler
OTG_HS_WKUP_IRQHandler
OTG_HS_IRQHandler
DCMI_IRQHandler
CRYP_IRQHandler
HASH_RNG_IRQHandler
FPU_IRQHandler
B .
ENDP
ALIGN
;*******************************************************************************
; User Stack and Heap initialization
;*******************************************************************************
IF :DEF:__MICROLIB
EXPORT __initial_sp
EXPORT __heap_base
EXPORT __heap_limit
ELSE
IMPORT __use_two_region_memory
EXPORT __user_initial_stackheap
__user_initial_stackheap
LDR R0, = Heap_Mem
LDR R1, =(Stack_Mem + Stack_Size)
LDR R2, = (Heap_Mem + Heap_Size)
LDR R3, = Stack_Mem
BX LR
ALIGN
ENDIF
END
;************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE*****
|
903257958/stm32_oop_driver
| 12,458
|
stm32f103ve_drivers/stm32f103ve_uart/firmware/cmsis/device/startup_stm32f10x_md.s
|
;******************** (C) COPYRIGHT 2011 STMicroelectronics ********************
;* File Name : startup_stm32f10x_md.s
;* Author : MCD Application Team
;* Version : V3.5.0
;* Date : 11-March-2011
;* Description : STM32F10x Medium Density Devices vector table for MDK-ARM
;* toolchain.
;* This module performs:
;* - Set the initial SP
;* - Set the initial PC == Reset_Handler
;* - Set the vector table entries with the exceptions ISR address
;* - Configure the clock system
;* - Branches to __main in the C library (which eventually
;* calls main()).
;* After Reset the CortexM3 processor is in Thread mode,
;* priority is Privileged, and the Stack is set to Main.
;* <<< Use Configuration Wizard in Context Menu >>>
;*******************************************************************************
; THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
; WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
; AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
; INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
; CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
; INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
;*******************************************************************************
; Amount of memory (in bytes) allocated for Stack
; Tailor this value to your application needs
; <h> Stack Configuration
; <o> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
; </h>
Stack_Size EQU 0x00000400
AREA STACK, NOINIT, READWRITE, ALIGN=3
Stack_Mem SPACE Stack_Size
__initial_sp
; <h> Heap Configuration
; <o> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
; </h>
Heap_Size EQU 0x00000200
AREA HEAP, NOINIT, READWRITE, ALIGN=3
__heap_base
Heap_Mem SPACE Heap_Size
__heap_limit
PRESERVE8
THUMB
; Vector Table Mapped to Address 0 at Reset
AREA RESET, DATA, READONLY
EXPORT __Vectors
EXPORT __Vectors_End
EXPORT __Vectors_Size
__Vectors DCD __initial_sp ; Top of Stack
DCD Reset_Handler ; Reset Handler
DCD NMI_Handler ; NMI Handler
DCD HardFault_Handler ; Hard Fault Handler
DCD MemManage_Handler ; MPU Fault Handler
DCD BusFault_Handler ; Bus Fault Handler
DCD UsageFault_Handler ; Usage Fault Handler
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD SVC_Handler ; SVCall Handler
DCD DebugMon_Handler ; Debug Monitor Handler
DCD 0 ; Reserved
DCD PendSV_Handler ; PendSV Handler
DCD SysTick_Handler ; SysTick Handler
; External Interrupts
DCD WWDG_IRQHandler ; Window Watchdog
DCD PVD_IRQHandler ; PVD through EXTI Line detect
DCD TAMPER_IRQHandler ; Tamper
DCD RTC_IRQHandler ; RTC
DCD FLASH_IRQHandler ; Flash
DCD RCC_IRQHandler ; RCC
DCD EXTI0_IRQHandler ; EXTI Line 0
DCD EXTI1_IRQHandler ; EXTI Line 1
DCD EXTI2_IRQHandler ; EXTI Line 2
DCD EXTI3_IRQHandler ; EXTI Line 3
DCD EXTI4_IRQHandler ; EXTI Line 4
DCD DMA1_Channel1_IRQHandler ; DMA1 Channel 1
DCD DMA1_Channel2_IRQHandler ; DMA1 Channel 2
DCD DMA1_Channel3_IRQHandler ; DMA1 Channel 3
DCD DMA1_Channel4_IRQHandler ; DMA1 Channel 4
DCD DMA1_Channel5_IRQHandler ; DMA1 Channel 5
DCD DMA1_Channel6_IRQHandler ; DMA1 Channel 6
DCD DMA1_Channel7_IRQHandler ; DMA1 Channel 7
DCD ADC1_2_IRQHandler ; ADC1_2
DCD USB_HP_CAN1_TX_IRQHandler ; USB High Priority or CAN1 TX
DCD USB_LP_CAN1_RX0_IRQHandler ; USB Low Priority or CAN1 RX0
DCD CAN1_RX1_IRQHandler ; CAN1 RX1
DCD CAN1_SCE_IRQHandler ; CAN1 SCE
DCD EXTI9_5_IRQHandler ; EXTI Line 9..5
DCD TIM1_BRK_IRQHandler ; TIM1 Break
DCD TIM1_UP_IRQHandler ; TIM1 Update
DCD TIM1_TRG_COM_IRQHandler ; TIM1 Trigger and Commutation
DCD TIM1_CC_IRQHandler ; TIM1 Capture Compare
DCD TIM2_IRQHandler ; TIM2
DCD TIM3_IRQHandler ; TIM3
DCD TIM4_IRQHandler ; TIM4
DCD I2C1_EV_IRQHandler ; I2C1 Event
DCD I2C1_ER_IRQHandler ; I2C1 Error
DCD I2C2_EV_IRQHandler ; I2C2 Event
DCD I2C2_ER_IRQHandler ; I2C2 Error
DCD SPI1_IRQHandler ; SPI1
DCD SPI2_IRQHandler ; SPI2
DCD USART1_IRQHandler ; USART1
DCD USART2_IRQHandler ; USART2
DCD USART3_IRQHandler ; USART3
DCD EXTI15_10_IRQHandler ; EXTI Line 15..10
DCD RTCAlarm_IRQHandler ; RTC Alarm through EXTI Line
DCD USBWakeUp_IRQHandler ; USB Wakeup from suspend
__Vectors_End
__Vectors_Size EQU __Vectors_End - __Vectors
AREA |.text|, CODE, READONLY
; Reset handler
Reset_Handler PROC
EXPORT Reset_Handler [WEAK]
IMPORT __main
IMPORT SystemInit
LDR R0, =SystemInit
BLX R0
LDR R0, =__main
BX R0
ENDP
; Dummy Exception Handlers (infinite loops which can be modified)
NMI_Handler PROC
EXPORT NMI_Handler [WEAK]
B .
ENDP
HardFault_Handler\
PROC
EXPORT HardFault_Handler [WEAK]
B .
ENDP
MemManage_Handler\
PROC
EXPORT MemManage_Handler [WEAK]
B .
ENDP
BusFault_Handler\
PROC
EXPORT BusFault_Handler [WEAK]
B .
ENDP
UsageFault_Handler\
PROC
EXPORT UsageFault_Handler [WEAK]
B .
ENDP
SVC_Handler PROC
EXPORT SVC_Handler [WEAK]
B .
ENDP
DebugMon_Handler\
PROC
EXPORT DebugMon_Handler [WEAK]
B .
ENDP
PendSV_Handler PROC
EXPORT PendSV_Handler [WEAK]
B .
ENDP
SysTick_Handler PROC
EXPORT SysTick_Handler [WEAK]
B .
ENDP
Default_Handler PROC
EXPORT WWDG_IRQHandler [WEAK]
EXPORT PVD_IRQHandler [WEAK]
EXPORT TAMPER_IRQHandler [WEAK]
EXPORT RTC_IRQHandler [WEAK]
EXPORT FLASH_IRQHandler [WEAK]
EXPORT RCC_IRQHandler [WEAK]
EXPORT EXTI0_IRQHandler [WEAK]
EXPORT EXTI1_IRQHandler [WEAK]
EXPORT EXTI2_IRQHandler [WEAK]
EXPORT EXTI3_IRQHandler [WEAK]
EXPORT EXTI4_IRQHandler [WEAK]
EXPORT DMA1_Channel1_IRQHandler [WEAK]
EXPORT DMA1_Channel2_IRQHandler [WEAK]
EXPORT DMA1_Channel3_IRQHandler [WEAK]
EXPORT DMA1_Channel4_IRQHandler [WEAK]
EXPORT DMA1_Channel5_IRQHandler [WEAK]
EXPORT DMA1_Channel6_IRQHandler [WEAK]
EXPORT DMA1_Channel7_IRQHandler [WEAK]
EXPORT ADC1_2_IRQHandler [WEAK]
EXPORT USB_HP_CAN1_TX_IRQHandler [WEAK]
EXPORT USB_LP_CAN1_RX0_IRQHandler [WEAK]
EXPORT CAN1_RX1_IRQHandler [WEAK]
EXPORT CAN1_SCE_IRQHandler [WEAK]
EXPORT EXTI9_5_IRQHandler [WEAK]
EXPORT TIM1_BRK_IRQHandler [WEAK]
EXPORT TIM1_UP_IRQHandler [WEAK]
EXPORT TIM1_TRG_COM_IRQHandler [WEAK]
EXPORT TIM1_CC_IRQHandler [WEAK]
EXPORT TIM2_IRQHandler [WEAK]
EXPORT TIM3_IRQHandler [WEAK]
EXPORT TIM4_IRQHandler [WEAK]
EXPORT I2C1_EV_IRQHandler [WEAK]
EXPORT I2C1_ER_IRQHandler [WEAK]
EXPORT I2C2_EV_IRQHandler [WEAK]
EXPORT I2C2_ER_IRQHandler [WEAK]
EXPORT SPI1_IRQHandler [WEAK]
EXPORT SPI2_IRQHandler [WEAK]
EXPORT USART1_IRQHandler [WEAK]
EXPORT USART2_IRQHandler [WEAK]
EXPORT USART3_IRQHandler [WEAK]
EXPORT EXTI15_10_IRQHandler [WEAK]
EXPORT RTCAlarm_IRQHandler [WEAK]
EXPORT USBWakeUp_IRQHandler [WEAK]
WWDG_IRQHandler
PVD_IRQHandler
TAMPER_IRQHandler
RTC_IRQHandler
FLASH_IRQHandler
RCC_IRQHandler
EXTI0_IRQHandler
EXTI1_IRQHandler
EXTI2_IRQHandler
EXTI3_IRQHandler
EXTI4_IRQHandler
DMA1_Channel1_IRQHandler
DMA1_Channel2_IRQHandler
DMA1_Channel3_IRQHandler
DMA1_Channel4_IRQHandler
DMA1_Channel5_IRQHandler
DMA1_Channel6_IRQHandler
DMA1_Channel7_IRQHandler
ADC1_2_IRQHandler
USB_HP_CAN1_TX_IRQHandler
USB_LP_CAN1_RX0_IRQHandler
CAN1_RX1_IRQHandler
CAN1_SCE_IRQHandler
EXTI9_5_IRQHandler
TIM1_BRK_IRQHandler
TIM1_UP_IRQHandler
TIM1_TRG_COM_IRQHandler
TIM1_CC_IRQHandler
TIM2_IRQHandler
TIM3_IRQHandler
TIM4_IRQHandler
I2C1_EV_IRQHandler
I2C1_ER_IRQHandler
I2C2_EV_IRQHandler
I2C2_ER_IRQHandler
SPI1_IRQHandler
SPI2_IRQHandler
USART1_IRQHandler
USART2_IRQHandler
USART3_IRQHandler
EXTI15_10_IRQHandler
RTCAlarm_IRQHandler
USBWakeUp_IRQHandler
B .
ENDP
ALIGN
;*******************************************************************************
; User Stack and Heap initialization
;*******************************************************************************
IF :DEF:__MICROLIB
EXPORT __initial_sp
EXPORT __heap_base
EXPORT __heap_limit
ELSE
IMPORT __use_two_region_memory
EXPORT __user_initial_stackheap
__user_initial_stackheap
LDR R0, = Heap_Mem
LDR R1, =(Stack_Mem + Stack_Size)
LDR R2, = (Heap_Mem + Heap_Size)
LDR R3, = Stack_Mem
BX LR
ALIGN
ENDIF
END
;******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE*****
|
903257958/stm32_oop_driver
| 12,079
|
stm32f103ve_drivers/stm32f103ve_uart/firmware/cmsis/device/startup_stm32f10x_ld.s
|
;******************** (C) COPYRIGHT 2011 STMicroelectronics ********************
;* File Name : startup_stm32f10x_ld.s
;* Author : MCD Application Team
;* Version : V3.5.0
;* Date : 11-March-2011
;* Description : STM32F10x Low Density Devices vector table for MDK-ARM
;* toolchain.
;* This module performs:
;* - Set the initial SP
;* - Set the initial PC == Reset_Handler
;* - Set the vector table entries with the exceptions ISR address
;* - Configure the clock system
;* - Branches to __main in the C library (which eventually
;* calls main()).
;* After Reset the CortexM3 processor is in Thread mode,
;* priority is Privileged, and the Stack is set to Main.
;* <<< Use Configuration Wizard in Context Menu >>>
;*******************************************************************************
; THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
; WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
; AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
; INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
; CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
; INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
;*******************************************************************************
; Amount of memory (in bytes) allocated for Stack
; Tailor this value to your application needs
; <h> Stack Configuration
; <o> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
; </h>
Stack_Size EQU 0x00000400
AREA STACK, NOINIT, READWRITE, ALIGN=3
Stack_Mem SPACE Stack_Size
__initial_sp
; <h> Heap Configuration
; <o> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
; </h>
Heap_Size EQU 0x00000200
AREA HEAP, NOINIT, READWRITE, ALIGN=3
__heap_base
Heap_Mem SPACE Heap_Size
__heap_limit
PRESERVE8
THUMB
; Vector Table Mapped to Address 0 at Reset
AREA RESET, DATA, READONLY
EXPORT __Vectors
EXPORT __Vectors_End
EXPORT __Vectors_Size
__Vectors DCD __initial_sp ; Top of Stack
DCD Reset_Handler ; Reset Handler
DCD NMI_Handler ; NMI Handler
DCD HardFault_Handler ; Hard Fault Handler
DCD MemManage_Handler ; MPU Fault Handler
DCD BusFault_Handler ; Bus Fault Handler
DCD UsageFault_Handler ; Usage Fault Handler
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD SVC_Handler ; SVCall Handler
DCD DebugMon_Handler ; Debug Monitor Handler
DCD 0 ; Reserved
DCD PendSV_Handler ; PendSV Handler
DCD SysTick_Handler ; SysTick Handler
; External Interrupts
DCD WWDG_IRQHandler ; Window Watchdog
DCD PVD_IRQHandler ; PVD through EXTI Line detect
DCD TAMPER_IRQHandler ; Tamper
DCD RTC_IRQHandler ; RTC
DCD FLASH_IRQHandler ; Flash
DCD RCC_IRQHandler ; RCC
DCD EXTI0_IRQHandler ; EXTI Line 0
DCD EXTI1_IRQHandler ; EXTI Line 1
DCD EXTI2_IRQHandler ; EXTI Line 2
DCD EXTI3_IRQHandler ; EXTI Line 3
DCD EXTI4_IRQHandler ; EXTI Line 4
DCD DMA1_Channel1_IRQHandler ; DMA1 Channel 1
DCD DMA1_Channel2_IRQHandler ; DMA1 Channel 2
DCD DMA1_Channel3_IRQHandler ; DMA1 Channel 3
DCD DMA1_Channel4_IRQHandler ; DMA1 Channel 4
DCD DMA1_Channel5_IRQHandler ; DMA1 Channel 5
DCD DMA1_Channel6_IRQHandler ; DMA1 Channel 6
DCD DMA1_Channel7_IRQHandler ; DMA1 Channel 7
DCD ADC1_2_IRQHandler ; ADC1_2
DCD USB_HP_CAN1_TX_IRQHandler ; USB High Priority or CAN1 TX
DCD USB_LP_CAN1_RX0_IRQHandler ; USB Low Priority or CAN1 RX0
DCD CAN1_RX1_IRQHandler ; CAN1 RX1
DCD CAN1_SCE_IRQHandler ; CAN1 SCE
DCD EXTI9_5_IRQHandler ; EXTI Line 9..5
DCD TIM1_BRK_IRQHandler ; TIM1 Break
DCD TIM1_UP_IRQHandler ; TIM1 Update
DCD TIM1_TRG_COM_IRQHandler ; TIM1 Trigger and Commutation
DCD TIM1_CC_IRQHandler ; TIM1 Capture Compare
DCD TIM2_IRQHandler ; TIM2
DCD TIM3_IRQHandler ; TIM3
DCD 0 ; Reserved
DCD I2C1_EV_IRQHandler ; I2C1 Event
DCD I2C1_ER_IRQHandler ; I2C1 Error
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD SPI1_IRQHandler ; SPI1
DCD 0 ; Reserved
DCD USART1_IRQHandler ; USART1
DCD USART2_IRQHandler ; USART2
DCD 0 ; Reserved
DCD EXTI15_10_IRQHandler ; EXTI Line 15..10
DCD RTCAlarm_IRQHandler ; RTC Alarm through EXTI Line
DCD USBWakeUp_IRQHandler ; USB Wakeup from suspend
__Vectors_End
__Vectors_Size EQU __Vectors_End - __Vectors
AREA |.text|, CODE, READONLY
; Reset handler routine
Reset_Handler PROC
EXPORT Reset_Handler [WEAK]
IMPORT __main
IMPORT SystemInit
LDR R0, =SystemInit
BLX R0
LDR R0, =__main
BX R0
ENDP
; Dummy Exception Handlers (infinite loops which can be modified)
NMI_Handler PROC
EXPORT NMI_Handler [WEAK]
B .
ENDP
HardFault_Handler\
PROC
EXPORT HardFault_Handler [WEAK]
B .
ENDP
MemManage_Handler\
PROC
EXPORT MemManage_Handler [WEAK]
B .
ENDP
BusFault_Handler\
PROC
EXPORT BusFault_Handler [WEAK]
B .
ENDP
UsageFault_Handler\
PROC
EXPORT UsageFault_Handler [WEAK]
B .
ENDP
SVC_Handler PROC
EXPORT SVC_Handler [WEAK]
B .
ENDP
DebugMon_Handler\
PROC
EXPORT DebugMon_Handler [WEAK]
B .
ENDP
PendSV_Handler PROC
EXPORT PendSV_Handler [WEAK]
B .
ENDP
SysTick_Handler PROC
EXPORT SysTick_Handler [WEAK]
B .
ENDP
Default_Handler PROC
EXPORT WWDG_IRQHandler [WEAK]
EXPORT PVD_IRQHandler [WEAK]
EXPORT TAMPER_IRQHandler [WEAK]
EXPORT RTC_IRQHandler [WEAK]
EXPORT FLASH_IRQHandler [WEAK]
EXPORT RCC_IRQHandler [WEAK]
EXPORT EXTI0_IRQHandler [WEAK]
EXPORT EXTI1_IRQHandler [WEAK]
EXPORT EXTI2_IRQHandler [WEAK]
EXPORT EXTI3_IRQHandler [WEAK]
EXPORT EXTI4_IRQHandler [WEAK]
EXPORT DMA1_Channel1_IRQHandler [WEAK]
EXPORT DMA1_Channel2_IRQHandler [WEAK]
EXPORT DMA1_Channel3_IRQHandler [WEAK]
EXPORT DMA1_Channel4_IRQHandler [WEAK]
EXPORT DMA1_Channel5_IRQHandler [WEAK]
EXPORT DMA1_Channel6_IRQHandler [WEAK]
EXPORT DMA1_Channel7_IRQHandler [WEAK]
EXPORT ADC1_2_IRQHandler [WEAK]
EXPORT USB_HP_CAN1_TX_IRQHandler [WEAK]
EXPORT USB_LP_CAN1_RX0_IRQHandler [WEAK]
EXPORT CAN1_RX1_IRQHandler [WEAK]
EXPORT CAN1_SCE_IRQHandler [WEAK]
EXPORT EXTI9_5_IRQHandler [WEAK]
EXPORT TIM1_BRK_IRQHandler [WEAK]
EXPORT TIM1_UP_IRQHandler [WEAK]
EXPORT TIM1_TRG_COM_IRQHandler [WEAK]
EXPORT TIM1_CC_IRQHandler [WEAK]
EXPORT TIM2_IRQHandler [WEAK]
EXPORT TIM3_IRQHandler [WEAK]
EXPORT I2C1_EV_IRQHandler [WEAK]
EXPORT I2C1_ER_IRQHandler [WEAK]
EXPORT SPI1_IRQHandler [WEAK]
EXPORT USART1_IRQHandler [WEAK]
EXPORT USART2_IRQHandler [WEAK]
EXPORT EXTI15_10_IRQHandler [WEAK]
EXPORT RTCAlarm_IRQHandler [WEAK]
EXPORT USBWakeUp_IRQHandler [WEAK]
WWDG_IRQHandler
PVD_IRQHandler
TAMPER_IRQHandler
RTC_IRQHandler
FLASH_IRQHandler
RCC_IRQHandler
EXTI0_IRQHandler
EXTI1_IRQHandler
EXTI2_IRQHandler
EXTI3_IRQHandler
EXTI4_IRQHandler
DMA1_Channel1_IRQHandler
DMA1_Channel2_IRQHandler
DMA1_Channel3_IRQHandler
DMA1_Channel4_IRQHandler
DMA1_Channel5_IRQHandler
DMA1_Channel6_IRQHandler
DMA1_Channel7_IRQHandler
ADC1_2_IRQHandler
USB_HP_CAN1_TX_IRQHandler
USB_LP_CAN1_RX0_IRQHandler
CAN1_RX1_IRQHandler
CAN1_SCE_IRQHandler
EXTI9_5_IRQHandler
TIM1_BRK_IRQHandler
TIM1_UP_IRQHandler
TIM1_TRG_COM_IRQHandler
TIM1_CC_IRQHandler
TIM2_IRQHandler
TIM3_IRQHandler
I2C1_EV_IRQHandler
I2C1_ER_IRQHandler
SPI1_IRQHandler
USART1_IRQHandler
USART2_IRQHandler
EXTI15_10_IRQHandler
RTCAlarm_IRQHandler
USBWakeUp_IRQHandler
B .
ENDP
ALIGN
;*******************************************************************************
; User Stack and Heap initialization
;*******************************************************************************
IF :DEF:__MICROLIB
EXPORT __initial_sp
EXPORT __heap_base
EXPORT __heap_limit
ELSE
IMPORT __use_two_region_memory
EXPORT __user_initial_stackheap
__user_initial_stackheap
LDR R0, = Heap_Mem
LDR R1, =(Stack_Mem + Stack_Size)
LDR R2, = (Heap_Mem + Heap_Size)
LDR R3, = Stack_Mem
BX LR
ALIGN
ENDIF
END
;******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE*****
|
903257958/stm32_oop_driver
| 13,758
|
stm32f103ve_drivers/stm32f103ve_uart/firmware/cmsis/device/startup_stm32f10x_md_vl.s
|
;******************** (C) COPYRIGHT 2011 STMicroelectronics ********************
;* File Name : startup_stm32f10x_md_vl.s
;* Author : MCD Application Team
;* Version : V3.5.0
;* Date : 11-March-2011
;* Description : STM32F10x Medium Density Value Line Devices vector table
;* for MDK-ARM toolchain.
;* This module performs:
;* - Set the initial SP
;* - Set the initial PC == Reset_Handler
;* - Set the vector table entries with the exceptions ISR address
;* - Configure the clock system
;* - Branches to __main in the C library (which eventually
;* calls main()).
;* After Reset the CortexM3 processor is in Thread mode,
;* priority is Privileged, and the Stack is set to Main.
;* <<< Use Configuration Wizard in Context Menu >>>
;*******************************************************************************
; THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
; WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
; AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
; INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
; CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
; INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
;*******************************************************************************
; Amount of memory (in bytes) allocated for Stack
; Tailor this value to your application needs
; <h> Stack Configuration
; <o> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
; </h>
Stack_Size EQU 0x00000400
AREA STACK, NOINIT, READWRITE, ALIGN=3
Stack_Mem SPACE Stack_Size
__initial_sp
; <h> Heap Configuration
; <o> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
; </h>
Heap_Size EQU 0x00000200
AREA HEAP, NOINIT, READWRITE, ALIGN=3
__heap_base
Heap_Mem SPACE Heap_Size
__heap_limit
PRESERVE8
THUMB
; Vector Table Mapped to Address 0 at Reset
AREA RESET, DATA, READONLY
EXPORT __Vectors
EXPORT __Vectors_End
EXPORT __Vectors_Size
__Vectors DCD __initial_sp ; Top of Stack
DCD Reset_Handler ; Reset Handler
DCD NMI_Handler ; NMI Handler
DCD HardFault_Handler ; Hard Fault Handler
DCD MemManage_Handler ; MPU Fault Handler
DCD BusFault_Handler ; Bus Fault Handler
DCD UsageFault_Handler ; Usage Fault Handler
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD SVC_Handler ; SVCall Handler
DCD DebugMon_Handler ; Debug Monitor Handler
DCD 0 ; Reserved
DCD PendSV_Handler ; PendSV Handler
DCD SysTick_Handler ; SysTick Handler
; External Interrupts
DCD WWDG_IRQHandler ; Window Watchdog
DCD PVD_IRQHandler ; PVD through EXTI Line detect
DCD TAMPER_IRQHandler ; Tamper
DCD RTC_IRQHandler ; RTC
DCD FLASH_IRQHandler ; Flash
DCD RCC_IRQHandler ; RCC
DCD EXTI0_IRQHandler ; EXTI Line 0
DCD EXTI1_IRQHandler ; EXTI Line 1
DCD EXTI2_IRQHandler ; EXTI Line 2
DCD EXTI3_IRQHandler ; EXTI Line 3
DCD EXTI4_IRQHandler ; EXTI Line 4
DCD DMA1_Channel1_IRQHandler ; DMA1 Channel 1
DCD DMA1_Channel2_IRQHandler ; DMA1 Channel 2
DCD DMA1_Channel3_IRQHandler ; DMA1 Channel 3
DCD DMA1_Channel4_IRQHandler ; DMA1 Channel 4
DCD DMA1_Channel5_IRQHandler ; DMA1 Channel 5
DCD DMA1_Channel6_IRQHandler ; DMA1 Channel 6
DCD DMA1_Channel7_IRQHandler ; DMA1 Channel 7
DCD ADC1_IRQHandler ; ADC1
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD EXTI9_5_IRQHandler ; EXTI Line 9..5
DCD TIM1_BRK_TIM15_IRQHandler ; TIM1 Break and TIM15
DCD TIM1_UP_TIM16_IRQHandler ; TIM1 Update and TIM16
DCD TIM1_TRG_COM_TIM17_IRQHandler ; TIM1 Trigger and Commutation and TIM17
DCD TIM1_CC_IRQHandler ; TIM1 Capture Compare
DCD TIM2_IRQHandler ; TIM2
DCD TIM3_IRQHandler ; TIM3
DCD TIM4_IRQHandler ; TIM4
DCD I2C1_EV_IRQHandler ; I2C1 Event
DCD I2C1_ER_IRQHandler ; I2C1 Error
DCD I2C2_EV_IRQHandler ; I2C2 Event
DCD I2C2_ER_IRQHandler ; I2C2 Error
DCD SPI1_IRQHandler ; SPI1
DCD SPI2_IRQHandler ; SPI2
DCD USART1_IRQHandler ; USART1
DCD USART2_IRQHandler ; USART2
DCD USART3_IRQHandler ; USART3
DCD EXTI15_10_IRQHandler ; EXTI Line 15..10
DCD RTCAlarm_IRQHandler ; RTC Alarm through EXTI Line
DCD CEC_IRQHandler ; HDMI-CEC
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD TIM6_DAC_IRQHandler ; TIM6 and DAC underrun
DCD TIM7_IRQHandler ; TIM7
__Vectors_End
__Vectors_Size EQU __Vectors_End - __Vectors
AREA |.text|, CODE, READONLY
; Reset handler
Reset_Handler PROC
EXPORT Reset_Handler [WEAK]
IMPORT __main
IMPORT SystemInit
LDR R0, =SystemInit
BLX R0
LDR R0, =__main
BX R0
ENDP
; Dummy Exception Handlers (infinite loops which can be modified)
NMI_Handler PROC
EXPORT NMI_Handler [WEAK]
B .
ENDP
HardFault_Handler\
PROC
EXPORT HardFault_Handler [WEAK]
B .
ENDP
MemManage_Handler\
PROC
EXPORT MemManage_Handler [WEAK]
B .
ENDP
BusFault_Handler\
PROC
EXPORT BusFault_Handler [WEAK]
B .
ENDP
UsageFault_Handler\
PROC
EXPORT UsageFault_Handler [WEAK]
B .
ENDP
SVC_Handler PROC
EXPORT SVC_Handler [WEAK]
B .
ENDP
DebugMon_Handler\
PROC
EXPORT DebugMon_Handler [WEAK]
B .
ENDP
PendSV_Handler PROC
EXPORT PendSV_Handler [WEAK]
B .
ENDP
SysTick_Handler PROC
EXPORT SysTick_Handler [WEAK]
B .
ENDP
Default_Handler PROC
EXPORT WWDG_IRQHandler [WEAK]
EXPORT PVD_IRQHandler [WEAK]
EXPORT TAMPER_IRQHandler [WEAK]
EXPORT RTC_IRQHandler [WEAK]
EXPORT FLASH_IRQHandler [WEAK]
EXPORT RCC_IRQHandler [WEAK]
EXPORT EXTI0_IRQHandler [WEAK]
EXPORT EXTI1_IRQHandler [WEAK]
EXPORT EXTI2_IRQHandler [WEAK]
EXPORT EXTI3_IRQHandler [WEAK]
EXPORT EXTI4_IRQHandler [WEAK]
EXPORT DMA1_Channel1_IRQHandler [WEAK]
EXPORT DMA1_Channel2_IRQHandler [WEAK]
EXPORT DMA1_Channel3_IRQHandler [WEAK]
EXPORT DMA1_Channel4_IRQHandler [WEAK]
EXPORT DMA1_Channel5_IRQHandler [WEAK]
EXPORT DMA1_Channel6_IRQHandler [WEAK]
EXPORT DMA1_Channel7_IRQHandler [WEAK]
EXPORT ADC1_IRQHandler [WEAK]
EXPORT EXTI9_5_IRQHandler [WEAK]
EXPORT TIM1_BRK_TIM15_IRQHandler [WEAK]
EXPORT TIM1_UP_TIM16_IRQHandler [WEAK]
EXPORT TIM1_TRG_COM_TIM17_IRQHandler [WEAK]
EXPORT TIM1_CC_IRQHandler [WEAK]
EXPORT TIM2_IRQHandler [WEAK]
EXPORT TIM3_IRQHandler [WEAK]
EXPORT TIM4_IRQHandler [WEAK]
EXPORT I2C1_EV_IRQHandler [WEAK]
EXPORT I2C1_ER_IRQHandler [WEAK]
EXPORT I2C2_EV_IRQHandler [WEAK]
EXPORT I2C2_ER_IRQHandler [WEAK]
EXPORT SPI1_IRQHandler [WEAK]
EXPORT SPI2_IRQHandler [WEAK]
EXPORT USART1_IRQHandler [WEAK]
EXPORT USART2_IRQHandler [WEAK]
EXPORT USART3_IRQHandler [WEAK]
EXPORT EXTI15_10_IRQHandler [WEAK]
EXPORT RTCAlarm_IRQHandler [WEAK]
EXPORT CEC_IRQHandler [WEAK]
EXPORT TIM6_DAC_IRQHandler [WEAK]
EXPORT TIM7_IRQHandler [WEAK]
WWDG_IRQHandler
PVD_IRQHandler
TAMPER_IRQHandler
RTC_IRQHandler
FLASH_IRQHandler
RCC_IRQHandler
EXTI0_IRQHandler
EXTI1_IRQHandler
EXTI2_IRQHandler
EXTI3_IRQHandler
EXTI4_IRQHandler
DMA1_Channel1_IRQHandler
DMA1_Channel2_IRQHandler
DMA1_Channel3_IRQHandler
DMA1_Channel4_IRQHandler
DMA1_Channel5_IRQHandler
DMA1_Channel6_IRQHandler
DMA1_Channel7_IRQHandler
ADC1_IRQHandler
EXTI9_5_IRQHandler
TIM1_BRK_TIM15_IRQHandler
TIM1_UP_TIM16_IRQHandler
TIM1_TRG_COM_TIM17_IRQHandler
TIM1_CC_IRQHandler
TIM2_IRQHandler
TIM3_IRQHandler
TIM4_IRQHandler
I2C1_EV_IRQHandler
I2C1_ER_IRQHandler
I2C2_EV_IRQHandler
I2C2_ER_IRQHandler
SPI1_IRQHandler
SPI2_IRQHandler
USART1_IRQHandler
USART2_IRQHandler
USART3_IRQHandler
EXTI15_10_IRQHandler
RTCAlarm_IRQHandler
CEC_IRQHandler
TIM6_DAC_IRQHandler
TIM7_IRQHandler
B .
ENDP
ALIGN
;*******************************************************************************
; User Stack and Heap initialization
;*******************************************************************************
IF :DEF:__MICROLIB
EXPORT __initial_sp
EXPORT __heap_base
EXPORT __heap_limit
ELSE
IMPORT __use_two_region_memory
EXPORT __user_initial_stackheap
__user_initial_stackheap
LDR R0, = Heap_Mem
LDR R1, =(Stack_Mem + Stack_Size)
LDR R2, = (Heap_Mem + Heap_Size)
LDR R3, = Stack_Mem
BX LR
ALIGN
ENDIF
END
;******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE*****
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.