Permettez-moi de me présenter, je suis un musicien qui fait la musique 1-bit avec le ZX Spectrum. Excusez mon français, j'utilise google translate
Récemment, j'ai trouvé mon vieil TI-82. Depuis ZX Spectrum et TI-82 sont des machines très similaires, il pourrait être possible de porter certaines routines de son avec des multiples canaux.
Malheureusement, je ne sais pas très bien l'Assembler. Alors, quelqu'un pourrait-il s'il vous plaît m'aider adapter la routine ci-dessous (pas écrit par moi, bien sûr)?
Je pense que les principaux problèmes sera:
-Data Out et Key Input sont différents, bien sûr.
-ZX Spectrum Z80 est plus lent (3,5 MHz), de sorte que la routine doit être ralentie.
-Bit 7 de la sortie sur ZX définit la couleur de la bordure d'ecran, devrait probablement être désactivé.
Toutes les idées comment cela peut être réalisé?
Code
;Huby beeper music engine by Shiru (shiru@mail.ru) 04'11
;Two channels of tone, no volume, global speed
;One drum, replaces note on the first channel
;The main feature of this engine is the size, just 100 bytes
;Feel free to do whatever you want with the code, it is PD
OP_INCL equ #2c
module huby
play
ld e,(hl) ;read speed word
inc hl
ld d,(hl)
inc hl
ld (readRow.speed),de ;store it
ld e,(hl) ;read patterns offset
inc hl
ld d,(hl) ;it will be always in DE, and HL is order list pointer now
readPos
inc hl
ld a,(hl) ;read first byte of order list
or a
ret z ;if it is zero, it is end of the song
inc hl
push hl ;store order list pointer
push de ;store patterns offset
ld l,(hl) ;read second byte of order list
ld bc,2*256 ;calculate addresses of two patterns
.read
ld h,c ;pattern number*8
add hl,hl
add hl,hl
add hl,hl
add hl,de ;add patterns offset
push hl ;store pattern address
ld l,a ;now second address
djnz .read
exx
pop hl ;restore pattern addressed in alternative set
pop de
ld b,8 ;play 8 rows
readRow
ld a,(hl) ;read first note
inc hl ;increase first pattern pointer
exa
ld a,(de) ;read second note
inc de ;increase second pattern pointer
exx
ld h,a
exa
ld l,a
cp OP_INCL ;if first note is #2c, it is drum sound
jr z,$+3
xor a
ld (soundLoop.slide),a
.speed=$+1
ld bc,0
di
soundLoop
xor a ;clear carry and set A to zero
dec e ;counter of first channel
jr nz,.l1
ld e,l ;reload if overflow
sub l ;and set carry if note is not zero (mute)
.slide=$
nop ;slide for drum
.l1
dec d ;counter of second channel
jr nz,.l2
ld d,h ;reload if overflow
sub h ;and set carry if note is not zero (mute)
.l2
sbc a,a ;if carry, A=255, otherwise A=0
and 16
out (#fe),a
in a,(#fe) ;read keyboard
cpl
and #1f
jr nz,.l3 ;if any key is pressed, exit loop
dec bc
ld a,b
or c
jr nz,soundLoop ;113/123t
.l3
ld hl,#2758 ;restore alternative HL to default value
exx
ei
jr nz,$+4 ;if any key was pressed, break loop
djnz readRow
pop de
pop hl
jr z,readPos ;if no key was pressed, continue
ret
Autorisation : Membre
Nb de messages : 850
Inscrit le : Sam 15 Oct 2011, 11:07
Posté le : Jeu 02 Aoû 2012, 21:17
I dont think it is that Mathieu ^^
(but if it's him ... )
Old TI-82 ? Hum.
This makes the difference, that, for the TI-82 STATS / stats.fr (french version we almost all have), we use a TI-83 assembly, which may not be the same as the TI-82 (non stats) one. So ... I don't know.
Let's see other's answers
---------------------- La la la ...
Avez-vous pensé à regarder le manuel avant de demander conseil ? Un manuel est fait avant tout pour être consulté : MANUEL
Vous avez un problème avec l'ordinateur avec votre calculatrice ? SOLUTION EN VIDEO
Autorisation : Membre
Nb de messages : 3738
Inscrit le : Lun 19 Oct 2009, 21:25
Posté le : Jeu 02 Aoû 2012, 21:48
ZX-Spectrum and Ti82/Ti82stat have indeed the same processor family.
However Ti82 is not designed to run assembly, contrary to ti82stat.
You may already know about it, but i want to explain it.
You must use a special program called shell to force your ti82 to run assembly programs.
The most recommended shell is Crash.
(But you must use a special version of Crash for 19.006 operating system of ti82.
Check your OS with mode+alpha+S without press enter)
Furthermore ti82 and ti82stat are quite different.
Ti82stat and ti82statfr are ti83 based systems.
(not mix up with ti83plus very different too)
Our forum is no longer a really good reference about ti82.
Today we are better treating ti82stat than ti82.
Furthermore few of us wrote in assembly, wether it is ti82/ti82stat.
I am not enough competent about assembly to help you alone, but i can search how your source works.
Please tell us which software you would use to compile this project to use it on your ZX.
That information can allow us to search more help about compiler instructions.
Have ZX an sound enclose peripheral or a sound external peripheral ?
You may find more help in Omnimaga : they are an english-speaking programming community.
I searched ti82 assembly sites but i did not find enough good stuff.
---------------------- ti82statfr: 2008, inscrit: 2009, ti84pocketfr: noël2011, ti30xbmultiview: iut 2012-2014
Perfectionniste, manque tact. Pas le temps de tout publier depuis 2011. Répond toujours aux questions. (rédigé juin 2014)
Autorisation : Membre
Nb de messages : 109
Inscrit le : Lun 25 Jui 2012, 15:51
Posté le : Jeu 02 Aoû 2012, 22:14
Sounds with a TI works with outputs from the mini-jack port ; and I saw several instr (module, endmodule, exa ...) which I don't know as Z80 instr, so I doubt that you can port your ZX code to a TI-82 without rewriting it entirely.
Autorisation : Membre
Nb de messages : 11
Inscrit le : Jeu 02 Aoû 2012, 16:20
Posté le : Jeu 02 Aoû 2012, 23:26
thank you all for your interest.
@matrefeytontias: the module/endmodule instructions can safely be ignored, they are only relevant for ZX assembly. On Crash there's no need to define the beginning/end of the code, as far as I understand. As for the OP_INCL, ignore it at the beginning and replace with $2c in the code. everything else should be either genuine Z80 instructions, or labels.
@linkakro: Yes, I have Crash installed. And luckily I have ROM 19.0, not 19.006.
This code is optimized for compilation with Sjasmplus - https://sourceforge.net/projects/sjasmplus/
However, ignoring the module/endmodule and OP_INCL pseudo-ops, it should work with nearly any Z80 assembler. It seems TASM is recommended for TI82 assembly.
Anyway, what I posted above is only the playback routine. If you want to try compiling it for ZX Spectrum, you will need some additional files, which can be found here: http://shiru.untergrund.net/files/zx/huby.zip (16kb) Documentation about compiling is included. Of course you will need a ZX Spectrum emulator too - try this one: https://fuse-emulator.sourceforge.net/
Sound on original ZX Spectrum works by sending a bitstream to the MIC (Data out) port (Port $FE). There is an internal beeper, too (similar to PC Speaker), but nobody uses it. The MIC port is a 3,5" mono jack one. There is a second one for input. So after all, a fairly similar principle like on TI. The difference seems to be however, that on TI the link port must be explicitly switched on and off, while on ZX there is a special transducer chip (ULA) which does that automatically depending on whether you send 0's or 1's through it. I don't really understand how it works on TI, though.
There's some sound related stuff at ticalc.org... tried implementing it, but just ended up crashing the calc instead
Thanks for pointing me to Omnimaga, I'll ask there, too. I didn't even know any English speaking TI forums existed, that's why I came here However they seem to be more focused on TI83 and later models...
@The K: yeah, TI-82 (non stats) is getting old, it seems. For me it's kind of retro, brings back high school memories and such still, TI-83 asm shouldn't be too far away from TI-82. ROM calls will be different, of course, but this routine uses only one anyway, for reading the keyboard. And port numbers will be different, I suppose.
Autorisation : Membre
Nb de messages : 3738
Inscrit le : Lun 19 Oct 2009, 21:25
Posté le : Sam 04 Aoû 2012, 1:27
Can someone explain me what mean " ld (soundLoop.slide),a " ?
I do not understand what mean two labels in a load instruction.
---------------------- ti82statfr: 2008, inscrit: 2009, ti84pocketfr: noël2011, ti30xbmultiview: iut 2012-2014
Perfectionniste, manque tact. Pas le temps de tout publier depuis 2011. Répond toujours aux questions. (rédigé juin 2014)
Autorisation : Membre
Nb de messages : 11
Inscrit le : Jeu 02 Aoû 2012, 16:20
Posté le : Sam 04 Aoû 2012, 12:20
not 100% sure what's going on there, but i think it's an equate for ld (pq),a, where pq = soundLoop, sub-label slide. definately not a typo, since the routine works fine on ZX.
exa is ex af,af', btw.
Citer
Theorically, you just have to adapt the port number and all things related to hardware, and it should work with your TI
Basically, yes. Sadly I don't know how, really. Especially the port numbers are a problem - on ZX you can do a direct "out ($fe),a", since only bit 4 gets sent anyway. On TI you must switch explicitly with $0c0 and $0fc, as far as I understand.
Autorisation : Membre
Nb de messages : 109
Inscrit le : Lun 25 Jui 2012, 15:51
Posté le : Sam 04 Aoû 2012, 12:36
On a TI, the keyboard is the port $01 and the link port is the port $00.
EXA doesn't exist on TIs.
I don't know if sound is working the same way with a ZX and a TI, but on a TI, you have to apply a transfer protocol to send the byte since the link port only can send 2 bits (on 2 subports : the first (high) is called "tip", and the second (middle) "ring").
Autorisation : Membre
Nb de messages : 3738
Inscrit le : Lun 19 Oct 2009, 21:25
Posté le : Sam 04 Aoû 2012, 14:02
You can create EXA mnemonic by a directive since ex af,af' should exist.
It's a z80 instruction, it's not a TI instruction as far i know.
Except if the processor is restrained, that i do not believe.
.addinstr exa "" 08 1 NOP 1 ; 08 is opcode of "ex af,af'"
I hope it's right, otherwise we can replace directly exa by "ex af,af'".
I searched documentation about sjasmplus but i found nothing helping me understanding labels.
Citer
not 100% sure what's going on there, but i think it's an equate for ld (pq),a, where pq = soundLoop, sub-label slide. definately not a typo, since the routine works fine on ZX.
I do not know this kind of "sub-labels".
The ld instruction seems to write numbers in the program himself since labels are replaced by program address.
But "SoundLoop" is not followed by datas contrary to ".speed".
So it must overwrite instructions of program.
Furthermore ".speed=$+01" seems to be a compiler directive assigning a value to the label.
I will try to copy programs to adapt this one to the jack port then i will test it with my earpiece.
---------------------- ti82statfr: 2008, inscrit: 2009, ti84pocketfr: noël2011, ti30xbmultiview: iut 2012-2014
Perfectionniste, manque tact. Pas le temps de tout publier depuis 2011. Répond toujours aux questions. (rédigé juin 2014)
Autorisation : Membre
Nb de messages : 11
Inscrit le : Jeu 02 Aoû 2012, 16:20
Posté le : Sam 04 Aoû 2012, 16:05
Replacing exa with ex af,af' should work fine.
In this case the sub-label thing is mainly for improving readability of the code. so ld (soundLoop.slide),a should technically be the same as ld (.slide),a. Normally the reason for those, and the prefixing with ".", is to limit the label's validity to a certain part (module) of the code; so if a programmer wants to include the routine in a game/demo, there's no need to worry about duplicate label names.
In any case it seems TASM doesn't like labels that are prefixed with a ".", so probably all those need to be renamed.
As far as the ".speed=$+01" thing goes, I'm not sure. I think it means "add 1 to the program counter". So my guess it that the TASM equivalent would be
Code
.byte $00
speed ..
Anyway I'll ask about this at ZX forums and come back with an answer later.
EDIT: Ok, so the guys at worldofspectrum.org suggested that
speed equ $+1
should work in TASM instead of .speed=$+1.
So, let me wrap up the changes to the code so far. I've also added some song data at the end.
;Huby beeper music engine by Shiru (shiru@mail.ru) 04'11
;Two channels of tone, no volume, global speed
;One drum, replaces note on the first channel
;The main feature of this engine is the size, just 100 bytes
;Feel free to do whatever you want with the code, it is PD
ld hl,musicData
call play
play
ld e,(hl) ;read speed word
inc hl
ld d,(hl)
inc hl
ld (speed),de ;store it
ld e,(hl) ;read patterns offset
inc hl
ld d,(hl) ;it will be always in DE, and HL is order list pointer now
readPos
inc hl
ld a,(hl) ;read first byte of order list
or a
ret z ;if it is zero, it is end of the song
inc hl
push hl ;store order list pointer
push de ;store patterns offset
ld l,(hl) ;read second byte of order list
ld bc,2*256 ;calculate addresses of two patterns
read
ld h,c ;pattern number*8
add hl,hl
add hl,hl
add hl,hl
add hl,de ;add patterns offset
push hl ;store pattern address
ld l,a ;now second address
djnz read
exx
pop hl ;restore pattern addressed in alternative set
pop de
ld b,8 ;play 8 rows
readRow
ld a,(hl) ;read first note
inc hl ;increase first pattern pointer
ex af,af'
ld a,(de) ;read second note
inc de ;increase second pattern pointer
exx
ld h,a
ex af,af'
ld l,a
cp $2c ;if first note is $2c, it is drum sound
jr z,$+3
xor a
ld (slide),a
speed equ $+1
ld bc,0
di
soundLoop
xor a ;clear carry and set A to zero
dec e ;counter of first channel
jr nz,l1
ld e,l ;reload if overflow
sub l ;and set carry if note is not zero (mute)
slide equ $
nop ;slide for drum
l1
dec d ;counter of second channel
jr nz,l2
ld d,h ;reload if overflow
sub h ;and set carry if note is not zero (mute)
l2
sbc a,a ;if carry, A=255, otherwise A=0
and 16 ;need a good way to ld a,$c0 / ld a,$fc here
out (0),a
in a,(1) ;read keyboard
cpl ;this must probably be adapted
and $1f
jr nz,l3 ;if any key is pressed, exit loop
dec bc
ld a,b
or c
jr nz,soundLoop ;113/123t
l3
ld hl,$2758 ;restore alternative HL to default value
exx
ei
jr nz,$+4 ;if any key was pressed, break loop
djnz readRow
pop de
pop hl
jr z,readPos ;if no key was pressed, continue
ret
musicData
dw $06f3
dw p-8
db $01,$02
db $01,$02
db $03,$02
db $04,$02
db $05,$02
db $06,$02
db $07,$02
db $01,$02
db $01,$02
db $03,$02
db $04,$02
db $05,$02
db $06,$02
db $07,$02
db $08,$09
db $01,$0a
db $03,$0b
db $04,$0c
db $05,$0d
db $06,$0d
db $07,$0e
db $01,$0a
db $01,$0f
db $03,$10
db $04,$11
db $05,$12
db $06,$13
db $07,$14
db $08,$09
db $01,$0a
db $03,$0b
db $04,$0c
db $05,$0d
db $06,$0d
db $07,$0e
db $01,$0a
db $01,$0f
db $03,$10
db $04,$15
db $05,$16
db $06,$17
db $07,$18
db $01,$02
db $01,$02
db $03,$02
db $04,$02
db $05,$02
db $06,$02
db $07,$02
db $01,$02
db $01,$02
db $03,$02
db $04,$02
db $05,$02
db $06,$02
db $07,$02
db $19,$1a
db $19,$1b
db $1c,$1d
db $1e,$1f
db $20,$21
db $22,$23
db $24,$25
db $19,$1a
db $19,$1a
db $1c,$1d
db $1e,$1f
db $20,$26
db $27,$28
db $02,$29
db $19,$1a
db $19,$1b
db $1c,$1d
db $1e,$1f
db $20,$21
db $22,$23
db $24,$25
db $19,$1a
db $19,$1a
db $1c,$1d
db $1e,$1f
db $20,$26
db $22,$2a
db $2b,$2c
db $2d,$2e
db $2f,$30
db $31,$32
db $33,$34
db $35,$36
db $37,$36
db $38,$39
db $2f,$30
db $2f,$3a
db $31,$3b
db $33,$3c
db $35,$3d
db $37,$3e
db $38,$3f
db $40,$41
db $19,$42
db $1c,$43
db $44,$45
db $46,$47
db $22,$47
db $48,$49
db $19,$42
db $19,$0a
db $1c,$4a
db $44,$4b
db $20,$4c
db $4d,$4e
db $07,$18
db $01,$02
db $01,$02
db $03,$02
db $04,$02
db $05,$02
db $06,$02
db $07,$02
db $19,$02
db $19,$02
db $1c,$02
db $1e,$02
db $20,$02
db $4f,$02
db $50,$02
db $01,$02
db $01,$02
db $03,$02
db $04,$02
db $05,$02
db $06,$02
db $07,$02
db $19,$02
db $19,$02
db $1c,$02
db $51,$02
db $02,$02
db $52,$02
db $50,$02
db $00
p
db $be,$be,$5f,$50,$3f,$00,$00,$00
db $00,$00,$00,$00,$00,$00,$00,$00
db $d6,$d6,$d6,$d6,$d6,$d6,$ca,$ca
db $ca,$ca,$ca,$ca,$be,$be,$5f,$50
db $3f,$00,$00,$00,$be,$be,$5f,$50
db $3f,$00,$00,$00,$d6,$d6,$d6,$d6
db $d6,$d6,$ca,$ca,$ca,$ca,$ca,$ca
db $be,$be,$5f,$50,$00,$00,$00,$00
db $5f,$5f,$5f,$5f,$3f,$3f,$00,$00
db $3f,$3f,$3f,$3f,$47,$47,$00,$00
db $47,$47,$47,$47,$50,$50,$54,$54
db $00,$00,$00,$00,$50,$50,$50,$50
db $54,$54,$00,$00,$50,$50,$50,$50
db $47,$47,$3f,$3f,$00,$00,$00,$00
db $47,$47,$47,$47,$50,$50,$00,$00
db $50,$50,$50,$50,$54,$54,$5f,$5f
db $5f,$00,$00,$00,$54,$54,$54,$54
db $50,$50,$00,$00,$50,$50,$50,$50
db $47,$47,$00,$00,$47,$47,$47,$47
db $3f,$3f,$00,$00,$3f,$00,$3f,$00
db $5f,$00,$00,$00,$54,$54,$50,$50
db $47,$47,$00,$00,$3f,$3f,$47,$47
db $50,$50,$00,$00,$3f,$3f,$3f,$47
db $47,$47,$50,$50,$50,$00,$00,$00
db $a9,$a9,$54,$47,$38,$00,$00,$00
db $fe,$fe,$a9,$8e,$71,$00,$00,$00
db $fe,$fe,$fe,$8e,$71,$00,$00,$00
db $be,$be,$be,$be,$be,$be,$b3,$b3
db $bd,$bd,$bd,$bd,$bd,$bd,$b2,$b2
db $b3,$b3,$b3,$b3,$a9,$a9,$54,$47
db $b2,$b2,$b2,$b2,$fe,$fe,$a9,$8e
db $38,$00,$00,$00,$a9,$a9,$54,$47
db $71,$00,$00,$00,$fe,$fe,$fe,$00
db $38,$00,$00,$00,$be,$be,$be,$be
db $00,$00,$00,$00,$71,$71,$71,$71
db $be,$be,$be,$7f,$7f,$7f,$7f,$7f
db $8e,$8e,$8e,$a9,$a9,$a9,$a9,$a9
db $71,$00,$00,$00,$fe,$fe,$00,$00
db $38,$00,$00,$00,$00,$00,$00,$00
db $00,$00,$00,$00,$fe,$d6,$a9,$7f
db $6b,$54,$47,$3f,$35,$2a,$23,$1c
db $00,$00,$00,$00,$7f,$7f,$7f,$7f
db $be,$be,$be,$b3,$b3,$b3,$b3,$b3
db $78,$78,$78,$71,$71,$71,$71,$71
db $a0,$a0,$50,$43,$00,$00,$00,$00
db $50,$50,$50,$50,$35,$35,$00,$00
db $a0,$a0,$50,$43,$35,$00,$00,$00
db $35,$35,$35,$35,$3c,$3c,$00,$00
db $b3,$b3,$b3,$b3,$b3,$b3,$a9,$a9
db $3c,$3c,$3c,$3c,$43,$43,$47,$47
db $a9,$a9,$a9,$a9,$a0,$a0,$50,$43
db $00,$00,$00,$00,$43,$43,$43,$43
db $35,$00,$00,$00,$a0,$a0,$50,$43
db $47,$47,$00,$00,$43,$43,$43,$43
db $35,$00,$00,$00,$b3,$b3,$b3,$b3
db $b3,$b3,$a9,$a9,$a9,$a9,$a9,$a9
db $3c,$3c,$35,$35,$00,$00,$00,$00
db $3c,$3c,$3c,$3c,$43,$43,$00,$00
db $43,$43,$43,$43,$47,$47,$50,$50
db $50,$00,$00,$00,$47,$47,$47,$47
db $43,$43,$00,$00,$43,$43,$43,$43
db $3c,$3c,$00,$00,$3c,$3c,$3c,$3c
db $35,$35,$00,$00,$35,$00,$35,$00
db $a9,$a9,$54,$47,$00,$00,$00,$00
db $54,$54,$54,$54,$38,$38,$00,$00
db $38,$38,$38,$38,$3f,$3f,$00,$00
db $3f,$3f,$3f,$3f,$47,$47,$4b,$4b
db $b3,$b3,$b3,$b3,$a9,$a9,$54,$4b
db $00,$00,$00,$00,$47,$47,$47,$47
db $38,$00,$00,$00,$a9,$a9,$54,$4b
db $4b,$4b,$00,$00,$47,$47,$47,$47
db $be,$be,$b3,$b3,$b3,$b3,$b3,$b3
db $3f,$3f,$38,$38,$00,$00,$00,$00
db $47,$47,$47,$47,$4b,$4b,$54,$54
db $54,$00,$00,$00,$4b,$4b,$47,$47
db $3f,$3f,$00,$00,$38,$38,$3f,$3f
db $38,$00,$00,$00,$d6,$d6,$d6,$d6
db $47,$47,$00,$00,$3f,$3f,$3f,$47
db $38,$00,$00,$00,$a9,$a9,$a9,$a9
db $a9,$a9,$b3,$b3,$b3,$b3,$b3,$b3
db $b3,$b3,$b3,$b3,$a9,$a9,$a9,$00
db $00,$00,$00,$00,$a9,$a9,$a9,$a9
Autorisation : Membre
Nb de messages : 3738
Inscrit le : Lun 19 Oct 2009, 21:25
Posté le : Sam 04 Aoû 2012, 23:01
But "equ" directive is not written in compiled program ?! Why placing an equ in the middle of a program ?
Have you a compilation listing of the zx code ?
I want to compare hexadecimal and source to be sure about the working of speed and slide labels.
If you have not got it i will have only to download sjasmplus.
---------------------- ti82statfr: 2008, inscrit: 2009, ti84pocketfr: noël2011, ti30xbmultiview: iut 2012-2014
Perfectionniste, manque tact. Pas le temps de tout publier depuis 2011. Répond toujours aux questions. (rédigé juin 2014)
Autorisation : Membre
Nb de messages : 11
Inscrit le : Jeu 02 Aoû 2012, 16:20
Posté le : Dim 05 Aoû 2012, 3:18
Don't ask me, it doesn't make much sense to me either. I still think my original explanation with .byte $00 is better...
Anyway I don't have a proper hex listing, but I used bin2asm on the compiled binary. should be close enough, but possibly the byte at the location in question has been overwritten already.
Autorisation : Membre
Nb de messages : 3738
Inscrit le : Lun 19 Oct 2009, 21:25
Posté le : Dim 05 Aoû 2012, 11:05
Citer
Don't ask me, it doesn't make much sense to me either. I still think my original explanation with .byte $00 is better...
Yes, it must be a ".byte", but i fear that datas be read by computer or machine as an instruction...
It could be a lack of knowledge since i am beginner.
Thank for the binary.
I searched remarkable bytes of instruction, such as xor a = $B7, but i found nothing.
The binary seems to not be structured as the source.
EDIT : now a know that $AF="xor a" but... there is a mistake in the zilog manual !
In the XOR section, there is OR chart.
(it's the fourth mistake i found)
---------------------- ti82statfr: 2008, inscrit: 2009, ti84pocketfr: noël2011, ti30xbmultiview: iut 2012-2014
Perfectionniste, manque tact. Pas le temps de tout publier depuis 2011. Répond toujours aux questions. (rédigé juin 2014)
Autorisation : Membre
Nb de messages : 11
Inscrit le : Jeu 02 Aoû 2012, 16:20
Posté le : Lun 08 Oct 2012, 1:02
salut folks, it's been a while... so finally I got the sound working, but sadly only in VTI, not on real hardware. plus the sound output is not very stable, but i'm guessing that's partly VTI's fault.
anyway, if anybody has any ideas as to why there's no sound on real hardware with this, let me know.
;Huby beeper music engine by Shiru (shiru@mail.ru) 04'11
;Two channels of tone, no volume, global speed
;One drum, replaces note on the first channel
;The main feature of this engine is the size, just 100 bytes
;Feel free to do whatever you want with the code, it is PD
ld hl,musicData
ld a,%00010000 ;+ set interrupts to
fastest mode
out (4),a
call play
play
ld e,(hl) ;read speed word
inc hl
ld d,(hl)
inc hl
ld (speed),de ;store it
ld e,(hl) ;read patterns offset
inc hl
ld d,(hl) ;it will be always in
DE, and HL is order list pointer now
readPos
inc hl
ld a,(hl) ;read first byte of
order list
or a
ret z ;if it is zero, it is
end of the song
inc hl
push hl ;store order list
pointer
push de ;store patterns offset
ld l,(hl) ;read second byte of
order list
ld bc,2*256 ;calculate addresses
of two patterns
read
ld h,c ;pattern number*8
add hl,hl
add hl,hl
add hl,hl
add hl,de ;add patterns offset
push hl ;store pattern address
ld l,a ;now second address
djnz read
exx
pop hl ;restore pattern
addressed in alternative set
pop de
ld b,8 ;play 8 rows
readRow
ld a,(hl) ;read first note
inc hl ;increase first
pattern pointer
ex af,af'
ld a,(de) ;read second note
inc de ;increase second
pattern pointer
exx
ld h,a
ex af,af'
ld l,a
cp $2c ;if first note is $2c,
it is drum sound
jr z,$+3
xor a
ld (slide),a
speed .EQU $+1
ld bc,0
di
soundLoop
xor a ;clear carry and set A
to zero
dec e ;counter of first
channel
jr nz,l1
ld e,l ;reload if overflow
sub l ;and set carry if note
is not zero (mute)
slide .EQU $
nop ;slide for drum
l1
dec d ;counter of second
channel
jr nz,l2
ld d,h ;reload if overflow
sub h ;and set carry if note
is not zero (mute)
l2
sbc a,a ;if carry, A=255,
otherwise A=0
xor %11111100 ;+ $ff -> $c0, $0 ->
$fc
and %00111100
add a,12
out (0),a
out (0),a
out (0),a
out (0),a ;+ 4x to compensate
higher cpu speed
ld a,%10111111 ;+ new keyhandler
out (1),a
in a,(1) ;read keyboard
cpl
bit 6,a
jr nz,l3 ;if any key is
pressed, exit loop
dec bc
ld a,b
or c
jr nz,soundLoop ;113/123t + not
anymore i think
l3
ld hl,$2758 ;restore alternative
HL to default value
exx
ei
jr nz,$+4 ;if any key was
pressed, break loop
djnz readRow
pop de
pop hl
jr z,readPos ;if no key was
pressed, continue
ld a,%00010110 ;+ set interrupts back
to normal
out (4),a
;ret
jp EXIT_2_TIOS ;use CrASH syscall to
return properly
musicData
dw $06f3
dw p-8
db $01,$02
db $01,$03
db $04,$05
db $06,$07
db $08,$09
db $0a,$0b
db $0c,$0d
db $0e,$0f
db $01,$02
db $01,$03
db $04,$05
db $06,$07
db $08,$09
db $0a,$0b
db $0c,$0d
db $0e,$0f
db $10,$02
db $11,$03
db $12,$05
db $13,$07
db $14,$09
db $15,$0b
db $16,$0d
db $17,$0f
db $18,$02
db $18,$03
db $19,$05
db $19,$07
db $1a,$09
db $1a,$0b
db $1b,$0d
db $1c,$0f
db $01,$02
db $01,$03
db $04,$05
db $06,$07
db $08,$09
db $0a,$0b
db $0c,$0d
db $0e,$0f
db $1d,$02
db $1d,$03
db $1e,$05
db $1e,$07
db $1f,$09
db $1f,$0b
db $20,$0d
db $21,$0f
db $10,$02
db $11,$03
db $12,$05
db $13,$07
db $14,$09
db $15,$0b
db $16,$0d
db $17,$0f
db $18,$02
db $18,$03
db $19,$05
db $19,$07
db $1a,$09
db $1a,$0b
db $1b,$0d
db $1c,$0f
db $00
p
db $2c,$3c,$b3,$3c,$b3,$3c,$b3,$3c
db $59,$59,$50,$50,$4b,$4b,$4b,$4b
db $4b,$4b,$4b,$4b,$59,$59,$59,$59
db $2c,$38,$b3,$38,$b3,$38,$b3,$38
db $43,$43,$43,$43,$43,$43,$43,$43
db $2c,$38,$b3,$38,$2c,$38,$2c,$38
db $43,$43,$43,$43,$4b,$4b,$50,$50
db $b3,$32,$b3,$32,$2c,$32,$b3,$32
db $4b,$4b,$50,$50,$59,$59,$59,$59
db $2c,$32,$b3,$32,$b3,$32,$b3,$32
db $59,$59,$59,$59,$4b,$4b,$4b,$4b
db $2c,$43,$b3,$43,$b3,$43,$b3,$43
db $50,$50,$50,$50,$50,$50,$50,$50
db $2c,$43,$b3,$43,$2c,$a0,$2c,$86
db $50,$50,$50,$50,$43,$43,$3c,$3c
db $2c,$3c,$e2,$3c,$e2,$3c,$2c,$3c
db $2c,$3c,$e2,$3c,$2c,$3c,$2c,$3c
db $2c,$38,$e2,$38,$e2,$38,$e2,$38
db $e2,$38,$2c,$38,$2c,$38,$e2,$38
db $2c,$32,$e2,$32,$2c,$32,$e2,$32
db $e2,$32,$e2,$32,$2c,$32,$e2,$32
db $2c,$43,$e2,$43,$e2,$43,$e2,$43
db $2c,$43,$2c,$43,$2c,$2c,$2c,$2c
db $f0,$3c,$f0,$3c,$f0,$3c,$f0,$3c
db $f0,$38,$f0,$38,$f0,$38,$f0,$38
db $f0,$32,$f0,$32,$f0,$32,$f0,$32
db $f0,$43,$f0,$43,$f0,$43,$f0,$43
db $f0,$43,$f0,$43,$f0,$a0,$f0,$86
db $78,$3c,$78,$3c,$78,$3c,$78,$3c
db $78,$38,$78,$38,$78,$38,$78,$38
db $78,$32,$78,$32,$78,$32,$78,$32
db $78,$43,$78,$43,$78,$43,$78,$43
db $78,$43,$78,$43,$78,$a0,$78,$86