Jump to content
IGNORED

Lynx audio


jp48

Recommended Posts

Hi all,

 

Trying to write CC65-program to Lynx, using only Mikey audio, writing directly to sound registers using POKE

(have done same for several consoles, without problems, or at least problems I couldn't solve myself :). Anyway

when trying to do same for Lynx, nothing (except interesting graphics in Handy), using POKE to write 0xFD20 to

0xFD27, apparently something is needed to initialize Mikey/Lynx/audio, I've only used CLI(), should I initialize

tgi too. And/or anything else ?

 

 

Thanks for advance !

 

 

-jp

Link to comment
Share on other sites

Hi all,

 

Trying to write CC65-program to Lynx, using only Mikey audio, writing directly to sound registers using POKE

(have done same for several consoles, without problems, or at least problems I couldn't solve myself :). Anyway

when trying to do same for Lynx, nothing (except interesting graphics in Handy), using POKE to write 0xFD20 to

0xFD27, apparently something is needed to initialize Mikey/Lynx/audio, I've only used CLI(), should I initialize

tgi too. And/or anything else ?

 

 

Thanks for advance !

 

 

-jp

 

no, there is no more to initialize

here are a example how to get out some noise...

 

uchar MStereo at 0xfd50;

 

#define Channel0 (char *)0xfd20

#define Channel1 (char *)0xfd28

#define Channel2 (char *)0xfd30

#define Channel3 (char *)0xfd38

 

void SoundInit()

{

MStereo = 0x42;

}

 

void SoundSetup(channel, volume, shift, lowshift, backup, flags)

uchar *channel;

uchar volume;

uchar shift;

uchar lowshift;

uchar backup;

uchar flags;

{

channel[0] = volume;

channel[1] = shift;

channel[3] = lowshift;

channel[4] = backup;

channel[5] = flags;

}

 

SoundSetup(Channel3,0x00,0x00,0x05,0xbb,0x19);

 

I use it with the newcc65 from the BLL Kit and it runs

 

Regards

Matthias

Link to comment
Share on other sites

 

no, there is no more to initialize

here are a example how to get out some noise...

 

uchar MStereo at 0xfd50;

 

#define Channel0 (char *)0xfd20

#define Channel1 (char *)0xfd28

#define Channel2 (char *)0xfd30

#define Channel3 (char *)0xfd38

 

void SoundInit()

{

MStereo = 0x42;

}

 

void SoundSetup(channel, volume, shift, lowshift, backup, flags)

uchar *channel;

uchar volume;

uchar shift;

uchar lowshift;

uchar backup;

uchar flags;

{

channel[0] = volume;

channel[1] = shift;

channel[3] = lowshift;

channel[4] = backup;

channel[5] = flags;

}

 

SoundSetup(Channel3,0x00,0x00,0x05,0xbb,0x19);

 

I use it with the newcc65 from the BLL Kit and it runs

 

Regards

Matthias

 

Thanks very much Matthias, yes, I only poked to 0xfd50 as "init" and it works ! Only thing I can't find (or perhaps the mechanism is different) is vblank routine for timing. nes.h contains waitvblank(), anything similar to Lynx.

 

Has anyone used mednafen as Lynx emulator, I can't get it work (except with NES, nothing else), lynxboot.img is copied and has correct MD5 sum, anyway doesn't recognize Lynx .o files. Any of them, not only mine :).

 

Thanks !

 

-jp

Link to comment
Share on other sites

 

no, there is no more to initialize

here are a example how to get out some noise...

 

uchar MStereo at 0xfd50;

 

#define Channel0 (char *)0xfd20

#define Channel1 (char *)0xfd28

#define Channel2 (char *)0xfd30

#define Channel3 (char *)0xfd38

 

void SoundInit()

{

MStereo = 0x42;

}

 

void SoundSetup(channel, volume, shift, lowshift, backup, flags)

uchar *channel;

uchar volume;

uchar shift;

uchar lowshift;

uchar backup;

uchar flags;

{

channel[0] = volume;

channel[1] = shift;

channel[3] = lowshift;

channel[4] = backup;

channel[5] = flags;

}

 

SoundSetup(Channel3,0x00,0x00,0x05,0xbb,0x19);

 

I use it with the newcc65 from the BLL Kit and it runs

 

Regards

Matthias

 

Thanks very much Matthias, yes, I only poked to 0xfd50 as "init" and it works ! Only thing I can't find (or perhaps the mechanism is different) is vblank routine for timing. nes.h contains waitvblank(), anything similar to Lynx.

 

Has anyone used mednafen as Lynx emulator, I can't get it work (except with NES, nothing else), lynxboot.img is copied and has correct MD5 sum, anyway doesn't recognize Lynx .o files. Any of them, not only mine :).

 

Thanks !

 

-jp

 

Timing by Vsync

 

extern uchar VBLflag;

#asm

_VBLflag = $a0

#endasm

 

#define VSYNC {++VBLflag;while( VBLflag );}

 

 

VBL() interrupt

{

char i;

VBLflag = 0; // indicates that a VBL has ocurred

 

 

lastcounter++;

}

 

....

main()

{

...

InitIRQ();

InstallIRQ(2,VBL);

EnableIRQ(2);

CLI;

...

}

Regards

Matthias

Link to comment
Share on other sites

  • 1 month later...

 

Thanks very much Matthias, yes, I only poked to 0xfd50 as "init" and it works ! Only thing I can't find (or perhaps the mechanism is different) is vblank routine for timing. nes.h contains waitvblank(), anything similar to Lynx.

 

Has anyone used mednafen as Lynx emulator, I can't get it work (except with NES, nothing else), lynxboot.img is copied and has correct MD5 sum, anyway doesn't recognize Lynx .o files. Any of them, not only mine :).

 

Thanks !

 

-jp

 

mednafen does not recognize *.o files, you have to convert them to an rom image and then to a handy lnx format image.

Thats why I only use Makefiles for development nowadays, it doesnt matter if i only create a .o or the complete image. everthign goes in one step.

 

OR you add the support to mednafen :-)

Link to comment
Share on other sites

mednafen does not recognize *.o files, you have to convert them to an rom image and then to a handy lnx format image.

Thats why I only use Makefiles for development nowadays, it doesnt matter if i only create a .o or the complete image. everthign goes in one step.

 

OR you add the support to mednafen :-)

 

That is the main reason why I added the .lnx target generation as the default target to the cc65.org tools.

 

The new cc65 tools set up the IRQ's automatically. You do not need to set up any vectors anymore.

 

Instead you have to declare your ASM routine to be an interrupt handler like this;

 

   .interruptor RealTimeHandler
   .export _lastcounter

_lastcounter .word 0

RealTimeHandler:
   lda INTSET
   and #VBL_INTERRUPT
   beq @1
   inc _lastcounter
   bne @1
   inc _lastcounter+1
@1: clc
   rts

 

The linker will take care of creating the vectors and setting up everything. This handler will then be called at every interrupt. It will then check if the interrupt was generated by VBL and if it was it increments _lastcounter.

 

To activate the interrupt you can initialize the tgi-driver (it is automatically setting up the VBL counter, interrupt handlers and vectors).

 

 tgi_install(&lynxtgi);
 tgi_init();
 CLI();

 

All interruptors will always be called during every interrupt as long as carry is cleared when the interruptor exits. If you set the carry flag before exit then the interrupt has been handled. In my interruptors (tgi-graphics and ComLynx) I always leave the carry as cleared so that you can add your own hooks for some extra processing. This is why you can have many interruptors that share the same interrupt. Like tgi-processing and incrementing _lastcounter. Both handlers will be called.

 

Or you can even set up an interruptor of your own for the music. It should be something similar to the VBL interrupts.

 

From the asminc file it appears that interrupts 0, 2 and 4 are taken.

 

; Interrupt bits in INTRST and INTSET
TIMER0_INTERRUPT = $01
TIMER1_INTERRUPT = $02
TIMER2_INTERRUPT = $04
TIMER3_INTERRUPT = $08
TIMER4_INTERRUPT = $10
TIMER5_INTERRUPT = $20
TIMER6_INTERRUPT = $40
TIMER7_INTERRUPT = $80

HBL_INTERRUPT = TIMER0_INTERRUPT
VBL_INTERRUPT = TIMER2_INTERRUPT
SERIAL_INTERRUPT = TIMER4_INTERRUPT

 lda     #$80            ; Enable VBL interrupts
 tsb     VTIMCTLA
 lda     #$7e            ; 75 Hz
 ldx     #$20
 sta     HTIMBKUP
 stx     PBKUP

 

--

Regards,

 

Karri

Edited by karri
Link to comment
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.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   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.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...