Piano thing

Made something in Assembly? Show it off, and tell us how it works...
Absolute beginners welcome... we want to see what you've done!
Forum rules
There is a special rule on this forum...
This forum is intended to offer equal amounts encouragement and constructive feedback...
Therefore, if you say 2 negative things about someones work, you must think of 2 or more equally positive things...

Eg: "Great first effort, the idea is absolutely fascinating... However I noticed a few bugs, and maybe the graphics could be improved..."

If you can't think of anything good to say, then don't say anything!

If we don't encourage newbie programmers they won't have the confidence and motivation to stick at it and become great programmers! *speaking from experience*
Post Reply
Sect0r
Posts: 4
Joined: Tue Sep 01, 2020 2:06 pm

Piano thing

Post by Sect0r » Tue Sep 29, 2020 4:18 pm

forgot to post this
but i updated my program from last time!
it can play different notes now, and each note is assigned a key !

Code: Select all

; 10 SYS (49152)
 
*=$0801
 
        BYTE    $0E, $08, $0A, $00, $9E, $20, $28,  $34, $39, $31, $35, $32, $29, $00, $00, $00
;----------------------------------------------------------------------------------------------
 
*=$C000
 
DEFM LSA ;Load and set register A
        LDA #$/1
        STA $/2
        ENDM
DEFM SN ;Set note
        LDA #$/1 
        STA $D400 ;low byte
        LDA #$/2 
        STA $D401 ;high byte
        ENDM
DEFM CKJ ;Check key and jump to label
        CMP #/1
        BEQ /2
        ENDM


INIT:

;          Val MemAddress
       LSA 44, D400    ;frequency voice1 low byte
       LSA 1D, D401    ;frequency voice1 high byte
       LSA 0F, D418    ;volume

       ;ADSR
       LSA 11, D405    ;attack
       LSA F0, D406    ;sustain

       ;play note
       LSA 11, D404    ;control register / turn on
       LSA 10, D404    ;control register / turn off
       JMP LOOP

LOOP
       LDA 203
;          Key Note Key  Note
       CKJ 12, PC      ;Z - C
       CKJ 13, PCS     ;S - C#
       CKJ 23, PD      ;X - D
       CKJ 18, PDS     ;D - D#
       CKJ 20, PE      ;C - E
       CKJ 31, PF      ;V - F
       CKJ 28, PFS     ;G - F#
       CKJ 26, PG      ;B - G
       CKJ 29, PGS     ;H - G# 
       CKJ 39, PA      ;N - A  
       CKJ 34, PAS     ;J - A# 
       CKJ 36, PB      ;M - B  
       CKJ 64, NOF     ;NaN - NaN
       JMP LOOP 

NON
       LSA 11, D404 ;gate on
       JMP LOOP
NOF
       LSA 10, D404 ;gate off
       JMP LOOP

;------------------------------------

PC
       SN 08, 93
       JMP NON
PCS
       SN 09, 15
       JMP NON
PD
       SN 09, 9F
       JMP NON
PDS
       SN 0A, 32
       JMP NON
PE
       SN 0A, CD
       JMP NON

;JumpExtentions
PF
       JMP PF1
PFS
       JMP PFS1
PG
       JMP PG1
PGS
       JMP PGS1
PA 
       JMP PA1
PAS 
       JMP PAS1
PB 
       JMP PB1
;-------------

PF1
       SN 0B, 72
       JMP NON
PFS1
       SN 0C, 20
       JMP NON

PG1
       SN 0C, D8
       JMP NON
PGS1
       SN 0D, 9C
       JMP NON
PA1
       SN 0E, 6B
       JMP NON
PAS1
       SN 0F, 46
       JMP NON
PB1
       SN 10, 2F
       JMP NON
       
Though i'm having troubles figuring out the correct values for the hi and low bytes..

User avatar
akuyou
Posts: 563
Joined: Mon Apr 22, 2019 3:19 am
Contact:

Re: Piano thing

Post by akuyou » Mon Oct 05, 2020 3:41 am

Nice work... took me a while to convert it for VASM - the syntax is a little different to what I'm used to.

It certainly has the feel of a piano, and it's a really neat little program.

with VASM you can specify a pair to a macro in one word like this:

Code: Select all

loadpair z_bc,$0800		;Bytes

Code: Select all

	macro LoadPair,zr,val
		lda #<\val
		sta \zr
		lda #>\val
		sta \zr+1
	endm
the > and < split the $0800 into two parts $08 and $00 ... I'm sure there's something similar for you're assembler, maybe that could be something that helps you with your 16 bit note values?
Chibi Akuma(s) Comedy-Horror 8-bit Bullet Hell shooter! // 「チビ悪魔」可笑しいゴシックSTG ! // Work in Progress: ChibiAliens

Interested in CPU's :Z80,6502,68000,6809,ARM,8086,RISC-V
Learning: 65816,ARM,8086,6809

Post Reply

Return to “Show and Tell”