starting to write some music

This commit is contained in:
~d6 2024-07-31 23:13:27 -04:00
parent 068d1267d7
commit 2e155a9a2c
2 changed files with 81 additions and 18 deletions

Binary file not shown.

View File

@ -1,8 +1,6 @@
( kodiak.tal ) ( kodiak.tal )
( TODO ) ( TODO )
( * restart/quit game button )
( * automatically moving safe cards to foundation? )
( * make bear react to moving cards ) ( * make bear react to moving cards )
( * move cards back from foundation? ) ( * move cards back from foundation? )
( * music? ) ( * music? )
@ -14,6 +12,7 @@
|00 @System [ &vect $2 &expansion $2 &title $2 &metadata $2 &r $2 &g $2 &b $2 ] |00 @System [ &vect $2 &expansion $2 &title $2 &metadata $2 &r $2 &g $2 &b $2 ]
|10 @Console [ &vect $2 &r $1 &exec $2 &mode $1 &dead $1 &exit $1 &w $1 ] |10 @Console [ &vect $2 &r $1 &exec $2 &mode $1 &dead $1 &exit $1 &w $1 ]
|20 @Screen [ &vect $2 &w $2 &h $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &px $1 &sprite $1 ] |20 @Screen [ &vect $2 &w $2 &h $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &px $1 &sprite $1 ]
|30 @Audio0 [ &vect $2 &pos $2 &out $1 &dur $2 &pad $1 &adsr $2 &len $2 &addr $2 &vol $1 &pitch $1 ]
|80 @Controller [ &vect $2 &button $1 &key $1 &fn $1 ] |80 @Controller [ &vect $2 &button $1 &key $1 &fn $1 ]
|90 @Mouse [ &vect $2 &x $2 &y $2 &state $1 &pad $3 &scrollx $2 &scrolly $2 ] |90 @Mouse [ &vect $2 &x $2 &y $2 &state $1 &pad $3 &scrollx $2 &scrolly $2 ]
|a0 @File1 [ &vect $2 &ok $2 &stat $2 &del $1 &append $1 &name $2 &len $2 &r $2 &w $2 ] |a0 @File1 [ &vect $2 &ok $2 &stat $2 &del $1 &append $1 &name $2 &len $2 &r $2 &w $2 ]
@ -58,7 +57,8 @@
&y0 $2 ( starting y coord ) &y0 $2 ( starting y coord )
&x1 $2 ( ending x coord ) &x1 $2 ( ending x coord )
&y1 $2 ] ( ending y coord ) &y1 $2 ] ( ending y coord )
@audio $1 ( is audio enabled? ) @audio [ $1 ( is audio enabled? )
&pos $2 ] ( position in music )
|0100 |0100
@ -71,6 +71,22 @@
#0100 .Screen/w DEO2 #0100 .Screen/w DEO2
#00c0 .Screen/h DEO2 #00c0 .Screen/h DEO2
( set up vectors )
;on-mouse .Mouse/vect DEO2
;on-key .Controller/vect DEO2
;on-refresh .Screen/vect DEO2
;on-audio .Audio0/vect DEO2
( set up music )
#0000 .audio/pos STZ2 ( ; music position )
#0231 .Audio0/adsr DEO2 ( ; 6/15 second )
#00a0 .Audio0/dur DEO2
#0008 .Audio0/len DEO2 ( ; 2 bytes long )
;square .Audio0/addr DEO2 ( ; square wave )
#77 .Audio0/vol DEO ( ; about 50% volume )
( #00 .Audio0/pitch DEO ( start ) )
reset BRK reset BRK
@reset @reset
@ -88,14 +104,8 @@
shuffle-stock shuffle-stock
deal-tableau deal-tableau
( TODO: clear foreground ) ( TODO: clear foreground )
draw draw
;on-mouse .Mouse/vect DEO2
;on-key .Controller/vect DEO2
;on-refresh .Screen/vect DEO2
auto-move auto-move
JMP2r JMP2r
@ -228,12 +238,16 @@
#36 .Screen/auto DEO #36 .Screen/auto DEO
#8a .Screen/sprite DEO JMP2r #8a .Screen/sprite DEO JMP2r
@restart-button-addr ( -> addr* )
game-won ?&won ;restart-button JMP2r
&won ;new-game-button JMP2r
@audio-button-addr ( -> addr* ) @audio-button-addr ( -> addr* )
.audio LDZ ?&on ;audio-off-button JMP2r .audio LDZ ?&on ;audio-off-button JMP2r
&on ;audio-on-button JMP2r &on ;audio-on-button JMP2r
@draw-buttons ( -> ) @draw-buttons ( -> )
#0008 #00b4 ;restart-button draw-button #0008 #00b4 restart-button-addr draw-button
#0030 #00b4 ;quit-button draw-button #0030 #00b4 ;quit-button draw-button
#0058 #00b4 audio-button-addr draw-button #0058 #00b4 audio-button-addr draw-button
#0080 #00b4 ;about-button draw-button #0080 #00b4 ;about-button draw-button
@ -415,6 +429,22 @@
.move #0e initialize ( ; zero out move ) .move #0e initialize ( ; zero out move )
post-move !draw ( ; finish move and draw ) post-move !draw ( ; finish move and draw )
@stop-audio ( -> )
#00 .audio STZ #00 .Audio0/pitch DEO JMP2r
@start-audio ( -> )
#01 .audio STZ #0000 .audio/pos STZ2 !play-audio
@play-audio ( -> )
.audio/pos LDZ2 ( pos* )
;music OVR2 ADD2 LDA ( pos* pitch^ )
.Audio0/pitch DEO ( pos* )
INC2 #0007 AND2 ( )
.audio/pos STZ2 JMP2r ( )
@on-audio ( -> brk )
.audio LDZ ?{ BRK } play-audio BRK
@on-refresh ( -> brk ) @on-refresh ( -> brk )
.move/card LDZ #00 EQU ?{ update-move } .move/card LDZ #00 EQU ?{ update-move }
on-refresh-bear ( ; possibly refresh bear ) on-refresh-bear ( ; possibly refresh bear )
@ -423,11 +453,11 @@
@on-refresh-bear ( -> ) @on-refresh-bear ( -> )
.frame LDZ .frame LDZ
DUP #e8 NEQ ?{ ;sprites #0040 ADD2 !&update } DUP #e8 NEQ ?{ POP ;sprites #0040 ADD2 !&update }
DUP #f0 NEQ ?{ ;sprites #0080 ADD2 !&update } DUP #f0 NEQ ?{ POP ;sprites #0080 ADD2 !&update }
DUP #f8 NEQ ?{ ;sprites #0040 ADD2 !&update } DUP #f8 NEQ ?{ POP ;sprites #0040 ADD2 !&update }
DUP #00 NEQ ?{ ;sprites !&update } DUP #00 NEQ ?{ POP ;sprites !&update }
JMP2r POP JMP2r
&update .Screen/addr DEO2 ( ; s/addr<-addr ) &update .Screen/addr DEO2 ( ; s/addr<-addr )
#0098 .Screen/y DEO2 ( ; s/x<-0x98 ) #0098 .Screen/y DEO2 ( ; s/x<-0x98 )
#00e8 .Screen/x DEO2 ( ; s/y<-0xe8 ) #00e8 .Screen/x DEO2 ( ; s/y<-0xe8 )
@ -738,9 +768,19 @@
&audio POP2 toggle-audio #01 JMP2r &audio POP2 toggle-audio #01 JMP2r
&about POP2 #010e DEO #01 JMP2r &about POP2 #010e DEO #01 JMP2r
@game-won ( -> bool^ )
.foundation #04 OVR ADD SWP ( lim^ start^ )
&loop ( lim^ pos^ )
LDZk #0f AND #0d NEQ ?&no ( lim^ pos^ )
INC GTHk ?&loop ( lim^ pos+1^ )
POP2 #01 JMP2r ( 1^ )
&no POP2 #00 JMP2r ( 0^ )
@toggle-audio ( -> ) @toggle-audio ( -> )
#0001 .audio LDZ JMP SWP POP .audio STZ .audio LDZ ?&disable
draw-buttons ( !draw-curr-mouse ) JMP2r start-audio !&done
&disable stop-audio
&done !draw-buttons
@min ( x^ y^ -> min[x,y]^ ) @min ( x^ y^ -> min[x,y]^ )
LTHk JMP SWP POP JMP2r LTHk JMP SWP POP JMP2r
@ -797,7 +837,7 @@
SWP #0f AND SWP STZ JMP2r ( ; zp<-face ) SWP #0f AND SWP STZ JMP2r ( ; zp<-face )
@post-move ( -> ) @post-move ( -> )
auto-move JMP2r auto-move game-won ?draw-buttons JMP2r
@on-click-up ( -> ) @on-click-up ( -> )
.Mouse/state DEI #ff EOR ( not-state^ ) .Mouse/state DEI #ff EOR ( not-state^ )
@ -853,3 +893,26 @@
ff ff ff ff ff ff ff ff ff ce 55 4d 55 4e ff ff ff ff ff ff ff ff ff ff ff ce 55 4d 55 4e ff ff
ff ff ff ff ff ff ff ff ff d4 56 56 56 c6 ff ff ff ff ff ff ff ff ff ff ff d4 56 56 56 c6 ff ff
fe ff ff ff ff ff ff fe fe 7f ff ff ff ff ff fe fe ff ff ff ff ff ff fe fe 7f ff ff ff ff ff fe
@new-game-button
7f ff ff ff ff ff ff 7f 7f 99 ab a9 ab a9 ff 7f
ff ff ff ff ff ff ff ff ff 57 56 56 56 af ff ff
ff ff ff ff ff ff ff ff ff 37 ea a2 aa 2a ff ff
fe ff ff ff ff ff ff fe fe 59 ab a9 ab a9 ff fe
@square ff ff ff ff ff 00 00 00
( C C# D D# E F F# G G# A A# B )
( 01 02 03 04 05 06 07 08 09 0a 0b )
( 0c 0d 0e 0f 10 11 12 13 14 15 16 17 )
( 18 19 1a 1b 1c 1d 1e 1f 20 21 22 23 )
( 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f )
( 30 31 32 33 34 35 36 37 38 39 3a 3b )
( 3c 3d 3e 3f 40 41 42 43 44 45 46 47 )
( 48 49 4a 4b 4c 4d 4e 4f 50 51 52 53 )
( 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f )
( 60 61 62 63 64 65 66 67 68 69 6a 6b )
( 6c 6d 6e 6f 70 71 72 73 74 75 76 77 )
( 78 79 7a 7b 7c 7d 7e 7f )
@music 18 18 1a 1b 1f 24 1a 1b