Jump to content
  • 0
Gernreich

Monkey See, Monkey Do

Question

I've been looking around for an hour+ but I can't seem to find what I need.  Also I am a Monkey See, Monkey Do kind of person.  Could someone translate this one line into assembly? Please?

VPOKE $0001,$F9C1,$04

If I can get that in assembly I will have a great jumping off point for a program I want to write in assembly 🙂

Thanks!

Share this post


Link to post
Share on other sites

18 answers to this question

Recommended Posts

  • 0

A straight translation into 6502 assembly would be:

lda #$00
sta $9F25 ; Set ADDSEL to 0
lda #$C1
sta $9F20 ; Set ADDR0_L to $C1
lda #$F9
sta $9F21 ; Set ADDR0_M to $F9
lda #$01
sta $9F22 ; Set ADDR0_H to $01
lda #$04
sta $9F23 ; Write $04 to VRAM addr $1F9C1

  • Like 1

Share this post


Link to post
Share on other sites
  • 0

$1F9C1 is Frequency word (15:8) in the VERA's PSG. Assuming $1F9C0 is $00, this is setting the PSG's frequency to 381.47Hz, somewhere between F#4 and G4. I would assume the intention is to produce G4, so you would want to set $1F9C0 to $1C.

  • Like 1

Share this post


Link to post
Share on other sites
  • 0
4 hours ago, StephenHorn said:

A straight translation into 6502 assembly would be:

lda #$00
sta $9F25 ; Set ADDSEL to 0
lda #$C1
sta $9F20 ; Set ADDR0_L to $C1
lda #$F9
sta $9F21 ; Set ADDR0_M to $F9
lda #$01
sta $9F22 ; Set ADDR0_H to $01
lda #$04
sta $9F23 ; Write $04 to VRAM addr $1F9C1

Also, don't forget the "LDA #0 / STA addr" combo can be replaced with "STZ addr" on the 65C02.

  • Like 1

Share this post


Link to post
Share on other sites
  • 0

Thank you all very much!  Steven thank you for the translation! The frequency is off because it is set to match a note on a great highland bagpipe practice chanter. I want to convert my basic program that plays a pipe tune, adjustable so as to be practiced with, over to assembly.  When I have done so I hope to share it 🙂.  StinkerB06 thank you as well for the shorted version of loading zero into the address 🙂 

 

The four lines I am jumping off with are:

VPOKE $0001,$F9C2,$FF
VPOKE $0001,$F9C3,$3F
VPOKE $0001,$F9C0,$4A
VPOKE $0001,$F9C1,$04

Given the translation of one of the lines I believe I can translate the rest 🙂

 

 

Edited by Gernreich
  • Like 1

Share this post


Link to post
Share on other sites
  • 0

<light bulb>!!!

 

BASIC

10 POKE$9F20,0
20 POKE$9F21,0
30 POKE$9F22,0
40 POKE$9F23,1

This is identical to doing VPOKE0,0,1.

6502

stz $9F20
stz $9F21
stz $9F22
lda #1
sta $9F23
  • Like 1

Share this post


Link to post
Share on other sites
  • 0

Mostly correct. The one caveat is to make sure you stz $9F25 to make sure you are setting the VRAM address of ADDR0_x, instead of ADDR1_x.

ADDR0_x is accessed through $9F23.
ADDR1_x is accessed through $9F24.

  • Like 1

Share this post


Link to post
Share on other sites
  • 0

OK here is what I have for playing one note 🙂

$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
###https://github.com/commanderx16/x16-emulator/wiki/(VERA-0.9)-Register-$9F25###
###https://www.commanderx16.com/forum/index.php?/topic/438-need-help-with-basicasm-access-to-vera-sound/###

###VERA I/O control register###
###When ADDRSEL is set to 0, any reads or writes to $9F20-$9F22 will refer to the VRAM address used by $9F23 (DATA0).###
lda #$00
sta $9F25

###Contains the middlin-significant byte of VRAM we want to access###
lda #$F9
sta $9F21

###Contains the most-significant bit of VRAM we want to access and sets the memory access increment for VERA data ports###
lda #$01
sta $9F22

#############################################################
###low frequency byte###
###Contains the least-significant byte of VRAM we want to access###
lda #$C0
sta $9F20

###Data port 0###
lda #$4A
sta $9F23
#############################################################

#############################################################
###high frequency byte###
###Contains the least-significant byte of VRAM we want to access###
lda #$C1
sta $9F20

###Data port 0###
lda #$04
sta $9F23
#############################################################

#############################################################
###L-R_volume###
###Contains the least-significant byte of VRAM we want to access###
lda #$C2
sta $9F20

###Data port 0###
lda #$FF
sta $9F23
#############################################################

#############################################################
###waveform and pulse width###
###Contains the least-significant byte of VRAM we want to access###
lda #$C3
sta $9F20

###Data port 0###
lda #$3F
sta $9F23
#############################################################
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

Edited by Gernreich

Share this post


Link to post
Share on other sites
  • 0

WOOT!!!!!

LDA #$00
STA $9F25
LDA #$01
STA $9F22
LDA #$F9
STA $9F21
LDA #$C2
STA $9F20
LDA #$FF
STA $9F23
LDA #$C3
STA $9F20
LDA #$3F
STA $9F23
LDA #$C0
STA $9F20
LDA #$4A
STA $9F23
LDA #$C1
STA $9F20
LDA #$04
STA $9F23

WORKED!!!!!

Share this post


Link to post
Share on other sites
  • 0
1 hour ago, Gernreich said:

WOOT!!!!!

LDA #$00
STA $9F25
LDA #$01
STA $9F22
LDA #$F9
STA $9F21
LDA #$C2
STA $9F20
LDA #$FF
STA $9F23
LDA #$C3
STA $9F20
LDA #$3F
STA $9F23
LDA #$C0
STA $9F20
LDA #$4A
STA $9F23
LDA #$C1
STA $9F20
LDA #$04
STA $9F23

WORKED!!!!!

Why are you re-setting $9F20 every byte written? You could just use the VERA's auto-increment feature.

Here, this code should work better:

STZ $9F25 ; ADDRSEL=0, DCSEL=0

LDA #$C0

STA $9F20 ; ADDR0=$xxxC0

LDA #$F9

STA $9F21 ; ADDR0=$xF9C0

LDA #$11

STA $9F22 ; ADDR0=$1F9C0, Increment=1

LDA #$4A

STA $9F23 ; Frequency=$xx4A

LDA #$04

STA $9F23 ; Frequency=$044A

LDA #$FF

STA $9F23 ; Volume=63, Left=1, Right=1

LDA #$3F

STA $9F23 ; Duty=50%, Waveform=Square

  • Like 1

Share this post


Link to post
Share on other sites
  • 0
23 minutes ago, Gernreich said:

Cheers StinkerB06 !!!  Do I need to reset to play another note?

Yep! After the code is executed, ADDR0 points to $1F9C4, which is the start of the 2nd channel. So you'll need to manually rewind it by 4:

rewindChannelNumber:

LDA $9F20 ; Retrieve ADDRx_L

BEQ rewindChannel16 ; Skip this if zero

SEC

SBC #4 ; Subtract 4

STA $9F20 ; We're done

RTS

rewindChannel16:

DEC $9F21 ; If past 16th channel, decrement ADDRx_M

LDA #$FC

STA $9F20 ; ADDRx=$1F9FC

RTS

Share this post


Link to post
Share on other sites
  • 0

Cheers again!  I'll need to look at this for a bit.  Is this the minimum code for me to reset and play a new frequency? (no other change is made).  How about rewind by four, increment, increment, rewind by two, increment, increment, rewind by two..........

Edited by Gernreich

Share this post


Link to post
Share on other sites
  • 0

Maybe something like this added to the end of your program:

 

LDA #$C0
STA $9F20 ; Set ADDR0_L to $C0
LDA #$4B
STA $9F23 ; Frequency=$xx4B
LDA #$A0
STA $9F23 ; Frequency=$A04B

LDA #$C0
STA $9F20 ; Set ADDR0_L to $C0
LDA #$4C
STA $9F23 ; Frequency=$xx4C
LDA #$A9
STA $9F23 ; Frequency=$A94C

.

.

.

If the above is correct there is still the matter of it playing the notes too fast 🙂

Edited by Gernreich

Share this post


Link to post
Share on other sites
  • 0
31 minutes ago, Gernreich said:

Cheers again!  I'll need to look at this for a bit.  Is this the minimum code for me to reset and play a new frequency? (no other change is made).  How about rewind by four, increment, increment, rewind by two, increment, increment, rewind by two..........

I have another version that does a dummy read:

rewindChannelNumber:

LDY $9F22 ; Save ADDRx_H and auto-indexing factor

LDA $9F25 ; Retrieve CTRL register

AND #$01 ; Mask all but the ADDRSEL bit

TAX ; Put in X index register

LDA #$38

STA $9F22 ; Decrement=4

LDA $9F23,X ; Do the dummy read and decrement (Can you give a clue why I used an index register?)

STY $9F22 ; Restore ADDRx_H and auto-indexing factor

RTS

This one probably is less efficient, but it only takes 1 label instead of 2.

Edited by StinkerB06

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

Please review our Terms of Use