Discussion:
CASSETTE-SCOPE
(too old to reply)
Jorge
2017-09-26 09:00:01 UTC
Permalink
Raw Message
;APPLE II CASSETTE-SCOPE
;2017-09 ***@JORGECHAMORRO.COM

;KEYS:
;(T)RIGGER ON / OFF
;(SPACE) RUN / STOP
;(O)NE SHOT ON /OFF
;Any other key quits

;paste from here:

SAMPLES = $7F
TRIGER = $2FF
S_SAVE = $2FE
X_CORD = $2FD
FLIP = $2FC
ONESHOT = $2FB

HGR_BASE = $E6

X0 = 76
Y0 = 72
Y1 = 88
BLACK = 0
WHITE = 3
STACK = $100
KEYBD = $C000
PAGE1 = $C054
PAGE2 = $C055

* = $6000

BOOT JSR $F3D8
JSR GRATICULA
JSR $F3E2
JSR GRATICULA
LDA #0
STA TRIGER
STA FLIP
STA ONESHOT
LDA #$20
STA HGR_BASE

ENTRY TSX
STX S_SAVE
ENTRY2 LDX #SAMPLES
TXS

LDA TRIGER
BEQ NO_EDGE

FIND_EDGE LDX #SAMPLES
EDGE1 DEX
BEQ NONE
LDA $C060
BMI EDGE1
PHA
LDX #SAMPLES
EDGE2 DEX
BEQ NONE
LDA $C060
BPL EDGE2
BMI GO

NONE LDX ONESHOT
BEQ NONE2
JMP ENTRY2

NONE2 PHA
TSX
BPL NONE2
JMP REST_S

NO_EDGE LDA $C040

LDA $C060
PHA
LDA $C060
GO PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA
LDA $C060
PHA

REST_S LDA $C040
LDX S_SAVE
TXS

PAINT LDA #X0
STA X_CORD
LDA #SAMPLES
STA S_SAVE

LOOP_PAINT LDX S_SAVE
LDA STACK,X
BMI HI

LO LDX #BLACK
JSR $F6F0
LDX X_CORD
LDY #0
LDA #Y0
JSR $F457
LDX #WHITE
JSR $F6F0
LDX X_CORD
LDY #0
LDA #Y1
JSR $F457
JMP NXTSMP

HI LDX #WHITE
JSR $F6F0
LDX X_CORD
LDY #0
LDA #Y0
JSR $F457
LDX #BLACK
JSR $F6F0
LDX X_CORD
LDY #0
LDA #Y1
JSR $F457

NXTSMP INC X_CORD
DEC S_SAVE
BPL LOOP_PAINT

LDA FLIP
BNE HGR2
LDA PAGE1
LDA #1
STA FLIP
LDA #$40
STA HGR_BASE
JMP END

HGR2 LDA PAGE2
LDA #0
STA FLIP
LDA #$20
STA HGR_BASE

END LDA ONESHOT
BEQ GETKEY
OSHOTW LDA KEYBD
BPL OSHOTW
BMI KEY1

GETKEY LDA KEYBD
BMI KEY1
JMP ENTRY

KEY1 STA $C010
CMP #160
BNE KEY2
LDA ONESHOT
BEQ PAUSE
JMP ENTRY
PAUSE LDA KEYBD
BPL PAUSE
STA $C010
JMP ENTRY

KEY2 CMP #212
BNE KEY3
LDA TRIGER
BNE KEY22
INC TRIGER
JMP ENTRY
KEY22 LDA #0
STA TRIGER
JMP ENTRY

KEY3 CMP #207
BNE KEY4
LDA ONESHOT
BNE KEY32
INC ONESHOT
JMP ENTRY
KEY32 LDA #0
STA ONESHOT
JMP ENTRY

KEY4 NOP

QUIT STA $C010
LDA PAGE1
RTS

GRATICULA RTS


;to here

To assemble go to :

http://e-tradition.net/bytes/6502/assembler.html

And paste it there without the comments.

It's here as well:

https://gist.github.com/xk/91c1f80ead5d84e8ede057eea1b81e75

Or you can instead paste this at the monitor prompt:

6000:20 D8 F3 20 37 63 20 E2
:F3 20 37 63 A9 00 8D FF
:02 8D FC 02 8D FB 02 A9
:20 8D E6 00 BA 8E FE 02
:A2 7F 9A AD FF 02 F0 26
:A2 7F CA F0 12 AD 60 C0
:30 F8 48 A2 7F CA F0 07
:AD 60 C0 10 F8 30 19 AE
:FB 02 F0 03 4C 20 60 48
:BA 10 FC 4C 51 62 AD 40
:C0 AD 60 C0 48 AD 60 C0
:48 AD 60 C0 48 AD 60 C0
:48 AD 60 C0 48 AD 60 C0
:48 AD 60 C0 48 AD 60 C0
:48 AD 60 C0 48 AD 60 C0
:48 AD 60 C0 48 AD 60 C0
:48 AD 60 C0 48 AD 60 C0
:48 AD 60 C0 48 AD 60 C0
:48 AD 60 C0 48 AD 60 C0
:48 AD 60 C0 48 AD 60 C0
:48 AD 60 C0 48 AD 60 C0
:48 AD 60 C0 48 AD 60 C0
:48 AD 60 C0 48 AD 60 C0
:48 AD 60 C0 48 AD 60 C0
:48 AD 60 C0 48 AD 60 C0
:48 AD 60 C0 48 AD 60 C0
:48 AD 60 C0 48 AD 60 C0
:48 AD 60 C0 48 AD 60 C0
:48 AD 60 C0 48 AD 60 C0
:48 AD 60 C0 48 AD 60 C0
:48 AD 60 C0 48 AD 60 C0
:48 AD 60 C0 48 AD 60 C0
:48 AD 60 C0 48 AD 60 C0
:48 AD 60 C0 48 AD 60 C0
:48 AD 60 C0 48 AD 60 C0
:48 AD 60 C0 48 AD 60 C0
:48 AD 60 C0 48 AD 60 C0
:48 AD 60 C0 48 AD 60 C0
:48 AD 60 C0 48 AD 60 C0
:48 AD 60 C0 48 AD 60 C0
:48 AD 60 C0 48 AD 60 C0
:48 AD 60 C0 48 AD 60 C0
:48 AD 60 C0 48 AD 60 C0
:48 AD 60 C0 48 AD 60 C0
:48 AD 60 C0 48 AD 60 C0
:48 AD 60 C0 48 AD 60 C0
:48 AD 60 C0 48 AD 60 C0
:48 AD 60 C0 48 AD 60 C0
:48 AD 60 C0 48 AD 60 C0
:48 AD 60 C0 48 AD 60 C0
:48 AD 60 C0 48 AD 60 C0
:48 AD 60 C0 48 AD 60 C0
:48 AD 60 C0 48 AD 60 C0
:48 AD 60 C0 48 AD 60 C0
:48 AD 60 C0 48 AD 60 C0
:48 AD 60 C0 48 AD 60 C0
:48 AD 60 C0 48 AD 60 C0
:48 AD 60 C0 48 AD 60 C0
:48 AD 60 C0 48 AD 60 C0
:48 AD 60 C0 48 AD 60 C0
:48 AD 60 C0 48 AD 60 C0
:48 AD 60 C0 48 AD 60 C0
:48 AD 60 C0 48 AD 60 C0
:48 AD 60 C0 48 AD 60 C0
:48 AD 60 C0 48 AD 60 C0
:48 AD 60 C0 48 AD 60 C0
:48 AD 60 C0 48 AD 60 C0
:48 AD 60 C0 48 AD 60 C0
:48 AD 60 C0 48 AD 60 C0
:48 AD 60 C0 48 AD 60 C0
:48 AD 60 C0 48 AD 60 C0
:48 AD 60 C0 48 AD 60 C0
:48 AD 60 C0 48 AD 60 C0
:48 AD 60 C0 48 AD 60 C0
:48 AD 40 C0 AE FE 02 9A
:A9 4C 8D FD 02 A9 7F 8D
:FE 02 AE FE 02 BD 00 01
:30 21 A2 00 20 F0 F6 AE
:FD 02 A0 00 A9 48 20 57
:F4 A2 03 20 F0 F6 AE FD
:02 A0 00 A9 58 20 57 F4
:4C A9 62 A2 03 20 F0 F6
:AE FD 02 A0 00 A9 48 20
:57 F4 A2 00 20 F0 F6 AE
:FD 02 A0 00 A9 58 20 57
:F4 EE FD 02 CE FE 02 10
:B1 AD FC 02 D0 10 AD 54
:C0 A9 01 8D FC 02 A9 40
:8D E6 00 4C D3 62 AD 55
:C0 A9 00 8D FC 02 A9 20
:8D E6 00 AD FB 02 F0 07
:AD 00 C0 10 FB 30 08 AD
:00 C0 30 03 4C 1C 60 8D
:10 C0 C9 A0 D0 13 AD FB
:02 F0 03 4C 1C 60 AD 00
:C0 10 FB 8D 10 C0 4C 1C
:60 C9 D4 D0 13 AD FF 02
:D0 06 EE FF 02 4C 1C 60
:A9 00 8D FF 02 4C 1C 60
:C9 CF D0 13 AD FB 02 D0
:06 EE FB 02 4C 1C 60 A9
:00 8D FB 02 4C 1C 60 EA
:8D 10 C0 AD 54 C0 60 60

Then type 6000G. To save BSAVE CASSETE-SCOPE.ML,A$6000,L$400. To toggle trigger T, to toggle one-shot O, to RUN/STOP the space bar, any other key will quit.

Then feed a square wave and see how the high pulses are always longer than the low pulses ~ regardless of the volume.

In a capture frame there are 128 samples one every 7 cycles, that's ~875 µs per screen (128*7*(1/1,024e6)/1e-6), so the square wave has to be 1/875e-6 -> 1143 Hz or moar for a full cycle to fit in a screen.
--
Jorge.
Tom Porter
2017-09-26 14:36:16 UTC
Permalink
Raw Message
I'm big into 1bit Apple II audio... I gotta try this! Thanks a lot Jorge!
Loading...