Good evening all,
I'm trying to figure out how audio works on the TRS 80 Model 1 from a software perspective.
I don't have a model 1, but I'd like to understand the theory behind generating tones via the cassette port so that I may apply the same method to machines that I do have:
TRS 80 Model 100
TRS 80 Model 4 (I can't afford the sound card right now, so I'd like to try to run sound through the cassette port instead)
NEC PC-8001 (stretch goal)
The end goal is duophonic sound through software, like what we hear in frogger:
I've been analyzing this program for reference:
The BASIC portions i mostly get, however the machine language code is stumping me. Before I started this, I didn't know any Z80 assembler at all. I converted the BASIC DATA statements in the program into a BIN file with a python script, and ran it through two separate disassemblers (to make sure they match up) and got this code from both of them:
After spending some time reading over some Z80 tutorials and guides, i annotated about half of this code with comments for what each line is doing to the best of my ability. However, I still feel like I'm missing something in my understanding.
Switching gears - my model 100 is the only machine I have fully available and functional at the moment, so I tried to see if i could get any sound out of the cassette port at all (i know BASIC is slow, but i was at least hoping for a low buzz to confirm it was possible before i start doing stuff in z88dk).
After some testing, I was able to get a little buzz out of... something (something near the cassette port and not the built in speaker?) when i run the following BASIC script.. however it sounds distressing and I feel like I'm damaging the machine when I do this:
I read through parts of the Model 100's technical reference manual, especially the parts regarding the cassette interface, and I am still somewhat lost.
Sorry if this post is kind of all over the place, but I'm not super experienced here and would like to learn more about how the sound generation works. If anyone could explain to me the process on the model 1 of just creating a single square wave, I'd be very grateful!
Thank you!
I'm trying to figure out how audio works on the TRS 80 Model 1 from a software perspective.
I don't have a model 1, but I'd like to understand the theory behind generating tones via the cassette port so that I may apply the same method to machines that I do have:
TRS 80 Model 100
TRS 80 Model 4 (I can't afford the sound card right now, so I'd like to try to run sound through the cassette port instead)
NEC PC-8001 (stretch goal)
The end goal is duophonic sound through software, like what we hear in frogger:
I've been analyzing this program for reference:
The BASIC portions i mostly get, however the machine language code is stumping me. Before I started this, I didn't know any Z80 assembler at all. I converted the BASIC DATA statements in the program into a BIN file with a python script, and ran it through two separate disassemblers (to make sure they match up) and got this code from both of them:
push af
push bc
push de
push hl
ld de,(7f8dh)
0ld a,(7f92h)
ld b,a
ld c,00h
push bc
ld a,02h
call 7fcbh
ld a,01h
call 7fcbh
pop bc
djnz 000eh
ld hl,(7f8ah)
ld bc,007fh
or a
sbc hl,bc
ld bc,(7f90h)
add hl,bc
ld (7f8ah),hl
dec de
ld a,d
or e
jr nz,0008h
pop hl
pop de
pop bc
pop af
ret
ld bc,(7f8ah)
out (0ffh),a
dec bc
ld a,b
or c
jr nz,003dh
ret
After spending some time reading over some Z80 tutorials and guides, i annotated about half of this code with comments for what each line is doing to the best of my ability. However, I still feel like I'm missing something in my understanding.
Switching gears - my model 100 is the only machine I have fully available and functional at the moment, so I tried to see if i could get any sound out of the cassette port at all (i know BASIC is slow, but i was at least hoping for a low buzz to confirm it was possible before i start doing stuff in z88dk).
After some testing, I was able to get a little buzz out of... something (something near the cassette port and not the built in speaker?) when i run the following BASIC script.. however it sounds distressing and I feel like I'm damaging the machine when I do this:
motoron
port = 226 ' 226-239 all make the same sound
for x = 1 to 40
out port, 40
out port,0
next x
motoroff
I read through parts of the Model 100's technical reference manual, especially the parts regarding the cassette interface, and I am still somewhat lost.
Sorry if this post is kind of all over the place, but I'm not super experienced here and would like to learn more about how the sound generation works. If anyone could explain to me the process on the model 1 of just creating a single square wave, I'd be very grateful!
Thank you!