128 Sound and Music

Started by Stephane Richard, May 15, 2007, 12:14 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Stephane Richard

Hi again to all :-).

Ok, here's the deal, I can get pretty good with sound and music in BASIC 7.0 (even BASIC 2.0  as on the 64 or 64 mode on the 128).  I know though, if I wanted to make a good synthesizer program I need to learn the ASM side of things as I don't believe BASIC can respond fast enough to certain things.  Any of you happen to be fluent in one or more of the following and would happen to have time to teach me one or all of:

1. Sound definition (envelope, waveform types, filters, frequency offsets, ring modulation and the likes) in assembler?
2. doing mixed programming, such as music routines in assembler, calling them in from basic.
3. text screen programming in assembler (only if it makes for faster screen display, hence if it's worth it say compared to PRINT or CHAR).

From what I've read here and in some commodore reference, in assembler, you're better off "poking" from $D400 and up to create sounds.  This would make sound creation and synthesis very similar to the commodore 64.  Is this a right assumption?

Finally, if this has already been done by one of you, a sample program that does all this would be great :-). hehe save me some time :-).

Oh i'd like the video text routines to be fore the 80 column screen.  no graphics, just text (well petscii text ;-) )

Thanks all. :-)

P.S.: Remember i'm on winvice ;p-) so if sending samples code and such, some D64, D71 or D81 disk image files would be quite useful ;-)
When God created light, so too was born, the first Shadow!

MystikShadows

hydrophilic

That's asking alot!

If you are not using BASIC commands for sound, (i.e., assembly) then programming is exactly the same as the C64 except that some C128's (I think all the Ds) have the HMOS-II 8580 instead of the original NMOS 6581 chip so they don't do digi's the same way (you gotta use assembly for digi's).

For text, it wouldn't be much faster than PRINT unless it is a fairly long 'sentence' and it is constant and it is needs to printed to the same spot every time.  A good candidate might be a template.  I mean a screen that has all the constants but no variables.  In VICE fill the entire 40 column screen the way you want the press Esc X to switch to 80 columns.  Then hit F8 for Monitor and type
T 400 7E7 1800
to copy the VIC screen to $1800, then you can SYS 4864 to redraw the entire VIC screen with this code.1300 LDY #0
.1302 LDA $1800,Y
STA $400,Y
LDA $1900,Y
STA $500,Y
LDA $1A00,Y
STA $600,Y
LDA $1AE8,Y
STA $6E8,Y
INY
BNE $1302
RTS

For the 80-column screen, draw out the entire screen the way you want then press Esc,X to go to the 40-column screen.  Then you would need some code to copy the VDC screen memory.  Oh, no VICE on this PC so I can't say for sure but it should be like: (call w/SYS 5120).1400 LDA #0
STA $FF00
LDX #18
STX $D600 ;destination high ($1000)
LDA #$10
STA $D601
INX
STX $D600
LDA #0
STA $D601
LDX #32
STX $D600 ;source start $0000
STA $D601
INX
STX $D600
STA $D601
LDX #24
STX $D600
LDA $D601 ;block move/copy
ORA #$80 ;copy
STA $D601
LDA #255 ;almost one full page of memory
LDY #8 ;8 pages of memory
LDX #30 ;copy register
STX $D600
loop BIT $D600
BPL loop
STA $D601
DEY
BNE loop
RTS

Then in the program to recall the screen use this (call w/SYS 5376)
.1500 LDA #0
STA $FF00
LDX #18
STX $D600 ;destination high ($0000)
STA $D601
INX
STX $D600
STA $D601
LDX #33
STX $D600 ;source start $1000
STA $D601
DEX
STX $D600
LDA #$10
STA $D601
LDX #24
STX $D600
LDA $D601 ;block move/copy
ORA #$80 ;copy
STA $D601
LDA #255 ;almost one full page of memory
LDY #8 ;8 pages of memory
LDX #30 ;copy register
STX $D600
loop BIT $D600
BPL loop
STA $D601
DEY
BNE loop
RTS

In both examples, this is for character data only, no color/attributes.