Space99 - Music and Sound Effect Forum

Want to talks about games you like, would like to see developed on the Oric, it's here.
User avatar
Chema
Game master
Posts: 2512
Joined: Tue Jan 17, 2006 10:55 am
Location: Gijón, SPAIN
Contact:

Post by Chema » Tue Nov 06, 2007 11:41 am

Twilighte wrote:Hi Chema, damn i modified the message above whilst you were replying to it. So reread please.
Ok. Perfect! You went even one (or several) step ahead of what I was saying :)
As for the "Pool" tunes, i think we should seriously consider placing both effects and music in the same memory area and available during the game. It would still use just 5k but would make available all patterns for "pool" and "Hifi" tunes and Title tune.
Testing it shouldn't be a problem for me, and i am resigned in the idea the whole 5K will eventually reside somewhere above C000.
Perfect too. You have 6655 bytes from $e600, unless any change in the world map creates the need of another 256k page (which I hope is not the case).
Sonix used 00-0B of page Zero but once i decompile the code i will make it dynamic. Nevertheless it will still require around 12 bytes of zero page.
The highest address used in Zero page is $40, so you have over 190 bytes left. You can optimize whatever you want to use all it up. Else I will have a look and see what bits can be put there to gain some cycles...
Can you send me the original code i gave for the IRQ routine. Then i can implement the music and sfx into it.
Sure:

Code: Select all

; key read and timer irq 
#define        via_portb                $0300 
#define        via_t1cl                $0304 
#define        via_t1ch                $0305 
#define        via_t1ll                $0306 
#define        via_t1lh                $0307 
#define        via_t2ll                $0308 
#define        via_t2ch                $0309 
#define        via_sr                  $030A 
#define        via_acr                 $030b 
#define        via_pcr                 $030c 
#define        via_ifr                 $030D 
#define        via_ier                 $030E 
#define        via_porta               $030f 


.zero
TimerCounter        .byt 40        ;Slows key read to 25Hz 
KeyCode             .dsb 1        ;The keycode 
.text 

_init_irq_routine 
        ;Since we are starting from when the standard irq has already been 
        ;setup, we need not worry about ensuring one irq event and/or right 
        ;timer period, only redirecting irq vector to our own irq handler. 
        sei
        lda #<irq_routine 
        ;sta $0245        ;When we disable rom, we should change this to $fffe 
        sta $fffe
        lda #>irq_routine 
        ;sta $0246        ;When we disable rom, we should change this to $ffff 
        sta $ffff
        cli 
        rts 

;The IRQ routine will run (Like Oric) at 100Hz. 
irq_routine 

        ;Preserve registers 
        sta a_reserve+1        ;Preserving registers like this saves us 11 cycles - 
        stx x_reserve+1        ;over using the traditional pha, txa, pha, etc. 
        sty y_reserve+1        ;Even using absolute self mod code like this!! 

        ;Protect against Decimal mode 
        cld 

        ;Clear IRQ event 
        lda via_t1cl 

        ;Process Sound Effects 
;        jsr proc_sfx 

        ;Process Music 
;        jsr proc_music 

        ;Process timer event 
        dec TimerCounter 
.( 
        lda TimerCounter 
        and #4        ;Essentially, every 4th irq, call key read 
        bne skip1 
        ;Process keyboard 
        jsr proc_keyboard 

skip1        ;Process controller (Joysticks) 
.) 
;        jsr proc_controller 


        ;Send Sound Bank 
;        jsr send_ay 

        ;Restore Registers 
a_reserve 
        lda #00 
x_reserve 
        ldx #00 
y_reserve 
        ldy #00 

        ;End of IRQ 
        rti 
I now have alot of work to do to get this sound sorted.
btw, i always use DosBox now, just so much better than VPC.
[/quote]

I also have DosBox, but I can't remember what the problem was... It is a bit slower but can't remember why I switched to VirutalPC... maybe only testing :)

Anyway I launch Euphoric directly from XP 99% of the time. Just when it starts hanging or ignoring the keyboard (space and other keys start minimizing Euphoric) or when I want to hear music I use other options.

Cheers.

User avatar
Twilighte
Game master
Posts: 819
Joined: Sat Jan 07, 2006 12:07 am
Location: Luton, UK
Contact:

Post by Twilighte » Tue Nov 06, 2007 7:51 pm

Almost all code received, except i already had that code, but still missing the keyboard routines. I need to know what keys are available during the game and at the title section. The lower the key count the faster the routine will be you see. :P

As for progress, today i received a nice Sofa and box shelves so took the day as holiday. It also gave me the opportunity to dive directly into decompiling the compiled Sonix tune, then just a few moments ago i recompiled it and ran it under euphoric and it works fine, although seems still fixed to a specific address range, so i need to figure that out before i can implement SFX data and code.

User avatar
Chema
Game master
Posts: 2512
Joined: Tue Jan 17, 2006 10:55 am
Location: Gijón, SPAIN
Contact:

Post by Chema » Tue Nov 06, 2007 8:00 pm

Twilighte wrote:Almost all code received, except i already had that code, but still missing the keyboard routines. I need to know what keys are available during the game and at the title section. The lower the key count the faster the routine will be you see. :P

As for progress, today i received a nice Sofa and box shelves so took the day as holiday. It also gave me the opportunity to dive directly into decompiling the compiled Sonix tune, then just a few moments ago i recompiled it and ran it under euphoric and it works fine, although seems still fixed to a specific address range, so i need to figure that out before i can implement SFX data and code.
Oops... it was just below :) here you are:

Code: Select all

proc_keyboard 
        ;Setup ay to point to column register 
        ;Note that the write to the column register cannot simply be permanent 
        ;(Which would reduce amount of code) because some orics freeze(crash). 
        lda #$0E        ;AY Column register 
        sta via_porta 
        lda #$FF 
        sta via_pcr 
        ldy #$dd 
        sty via_pcr 

        ;Scan for 9 Keys (0-8) 
        ldx #08 
.( 
loop1        lda KeyRow,x 
        sta via_portb 
        lda KeyColumn,x 
        sta via_porta 
        lda #$fd 
        sta via_pcr 
        sty via_pcr 
        ;Whilst not needed on Euphoric, this time delay is required for 
        ;some Real Orics otherwise no key will be returned! 
        ;We should use this time for something else if given an oppertunity 
        nop 
        nop 
        nop 
        nop 
        lda via_portb 
        and #08 
        bne skip1 
        dex 
        bpl loop1 
        lda #00 
        sta KeyCode 
        rts 
skip1   inx 
.) 
        stx KeyCode 
        rts 


;Row and column tables for Z,X,M,B,T,-,=,CTRL and ESC 
KeyRow 
 .byt 2,0,2,2,1,3,7,2,1 
KeyColumn 
 .byt $df,$bf,$fe,$fb,$fd,$f7,$7f,$ef,$df
In fact just after loading the program this routine is used, so those are the only keys that are scanned at all times.

In fact some testers have suggested the possibility of changing those keys into something more... usable?

I think that should be rather easy, if the number of keys remain the same, as it should be just changing the KeyRow and KeyColumn tables... am I right?

Maybe that could open the possibility of having something configurable or at least more options than just the "standard".

So you decompiled the routine? Great work! Maybe now it is just a matter of changing addresses to labels? However I am sure that it is quite a complicated task indeed!

Cheers.

User avatar
Twilighte
Game master
Posts: 819
Joined: Sat Jan 07, 2006 12:07 am
Location: Luton, UK
Contact:

Post by Twilighte » Tue Nov 06, 2007 9:06 pm

Cool, thanks for that Chema, and you are perfectly right about changing the column/row data to change the keys, but onto that later.
For now i have figured out and corrected the relocation problem, i have also reduced the size even more by compiling Samples and Ornaments (Not real samples, just Sonix's name for volume sequences) and now instead of 2967 bytes, the music + code is 2826 bytes.

OK, time to implement the sfx.

User avatar
Chema
Game master
Posts: 2512
Joined: Tue Jan 17, 2006 10:55 am
Location: Gijón, SPAIN
Contact:

Post by Chema » Tue Nov 06, 2007 9:46 pm

Twilighte wrote:Cool, thanks for that Chema, and you are perfectly right about changing the column/row data to change the keys, but onto that later.
For now i have figured out and corrected the relocation problem, i have also reduced the size even more by compiling Samples and Ornaments (Not real samples, just Sonix's name for volume sequences) and now instead of 2967 bytes, the music + code is 2826 bytes.

OK, time to implement the sfx.
Great! Your working pace is incredible!

Maybe you should notice, now that you are onto sfx, that we might not use all of those on the AT disk. There are two sets for footsteps, for instance, and IIRC at least one I did not know what to use for :)

I am not sure if there where two alarm sounds... maybe we can make it with just one...

Just ideas in case we can save some space, or make room for *new* sfx :)

Regards,

User avatar
Twilighte
Game master
Posts: 819
Joined: Sat Jan 07, 2006 12:07 am
Location: Luton, UK
Contact:

Post by Twilighte » Tue Nov 06, 2007 10:50 pm

Yes, the footsteps are in the list but not the random pitch effect (which Dbug suggested) which i will add to the code once i have the sfx working.
We already have 3 alarm sounds i think.

I will rewrite the complete IRQ routine so that when i finish this project you'll get the following routines embedded in the code..

1) Sound Initialisation routine
2) Sound Call handler(For calling music and sfx from your code)
3) Music handler
4) SFX Handler
5) Keyboard reader
6) Random value generator (For footsteps)

:)
Damn, this is very annoying, since i got this mobile broadband everything works extremely well apart from the Mobile broadband monitor which shunts (as in clicks) the harddrive every second for no apparent reason. Not sure how to fix the problem but it certainly can't be doing the harddrive any good.

User avatar
Chema
Game master
Posts: 2512
Joined: Tue Jan 17, 2006 10:55 am
Location: Gijón, SPAIN
Contact:

Post by Chema » Wed Nov 07, 2007 9:49 am

Twilighte wrote: 6) Random value generator (For footsteps)
WHITE does have an internal random number generator if #OWNRAND is defined (which is the case in Space:1999 as ROM is disabled)

In fact this routine was suggested (and posted, so I just copied it :) ) by Dbug:

Code: Select all

; GETRAND
;
; Generate a somewhat random repeating sequence.  I use
; a typical linear congruential algorithm
;      I(n+1) = (I(n)*a + c) mod m
; with m=65536, a=5, and c=13841 ($3611).  c was chosen
; to be a prime number near (1/2 - 1/6 sqrt(3))*m.
;
; Note that in general the higher bits are "more random"
; than the lower bits, so for instance in this program
; since only small integers (0..15, 0..39, etc.) are desired,
; they should be taken from the high byte RANDOM+1, which
; is returned in A.
;
random
.word  $3611
temp
.byt $00
getrand
         lda random+1     
         sta temp        
         lda random       
         asl              
         rol temp        
         asl              
         rol temp        

         clc              
         adc random       
         pha              
         lda temp        
         adc random+1     
         sta random+1     
         pla              
         adc #$11         
         sta random       
         lda random+1     
         adc #$36         
         sta random+1     
         rts              
Maybe you can add this to your code and see if it works, so we don't have duplicated routines. You can just issue jsr getrand and get the result (8-bit) in reg A. If you need 16 bits, it is stored in the label random. In fact reg A contains the higher byte of that word, as you can see in the code.

Regards,

User avatar
Twilighte
Game master
Posts: 819
Joined: Sat Jan 07, 2006 12:07 am
Location: Luton, UK
Contact:

Post by Twilighte » Wed Nov 07, 2007 2:39 pm

I dislike random routines like this, primarily because they are based on adding and shifting known numbers together. I have a number of counters and registers in the irq routine which could potentially be used to produce a far more "random" result.
For example using a combination of the current pitch of channel A, the note tempo counter and the time consumed scanning the keyboard a much better random result could be formulated.

User avatar
Chema
Game master
Posts: 2512
Joined: Tue Jan 17, 2006 10:55 am
Location: Gijón, SPAIN
Contact:

Post by Chema » Wed Nov 07, 2007 4:33 pm

I understand your point of view. Just use your own routine then. I was just stating that I had it already, so we could save some bytes. Anyway it won't be much of a loss.

In addition I suppose that pseudo-random patterns would be much more noticeable in the sfx than in enemy movement :)

User avatar
Twilighte
Game master
Posts: 819
Joined: Sat Jan 07, 2006 12:07 am
Location: Luton, UK
Contact:

Post by Twilighte » Sun Nov 11, 2007 1:34 pm

I can use that routine, it isn't a problem, and i quite understand it would be pointless to duplicate random routines just because of any principles i may have.

I have successfully compiled the module which will play the sfx and Music but have yet to test it (Currently compiling in 3982 Bytes).
It can be compiled anywhere in memory and for testing purposes only will be compiled to $500.

On reading earlier messages i believe we established that you (chema) would load the accumulator with a value and call a generic call routine to start and stop music and sound effects.
I have coded this scheme.

Code: Select all

;>>>> Call here
;Load Accumulator with the following Bits before calling PlayAudio
;Bit 0-1 Forms value 0-3
;        0 Assign Music to Track specified in Data
;	 1 Assign Effect specified in Data to Channel A
;        2 Assign Effect specified in Data to Channel B
;        3 Assign Effect specified in Data to Channel C
;Bit 2-6 Forms value 0-31
;        0-31 Data
;Bit 7-7 Forms value 0-1
;	 0 Stop Effect on specified Channel or Track
;	 1 Start Effect on specified Channel or Track
Additional Notes..
>Stopping Music will stop the current track.
>Only one track (Sonix tune) can be played at any time
>Channels for the music are fixed

The music tracks provided are as follows and the index number should be passed as the Data ..

Code: Select all

0)Title Tune (Start Event 0) (ABC)
1)Reggae Track               (AB)
2)Repeating Drum Pattern     (A)
3)Pool Music                 (AB)
4)Hifi Music                 (AB)
So to play effect 5 on channel B, you should load the accumulator with 150 decimal (or %1 00101 10 binary) and jsr PlayAudio.
To Play the Hifi Music load with 144 and to Stop the music (any) load with 0. :)

Got Ptoing (Sven Ruthner) here this weekend so won't manage to test till later in week.
Last edited by Twilighte on Sun Nov 11, 2007 1:48 pm, edited 3 times in total.

User avatar
Dbug
Site Admin
Posts: 3051
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Post by Dbug » Sun Nov 11, 2007 1:37 pm

About random routines, a point to consider is that in many context the routine should not be random at all. The fact that given the same seed you get the same serie of values is a very important property, because it means you can reproduce the events when you want to debug, or you can use that to generate data from a very small set of data.

It's what games like Elite are using :)

User avatar
Twilighte
Game master
Posts: 819
Joined: Sat Jan 07, 2006 12:07 am
Location: Luton, UK
Contact:

Post by Twilighte » Sun Nov 11, 2007 1:52 pm

Yes, i can see this now Dbug. For example the random routine that Chema uses is intended for dictating the behaviour of robots in the game, this can make things easier to test because you'll know the robots paths everytime, but then when the game is released, it may not be so advantageous?
Also, the random element for footsteps is not so vital, or rather it does not have to be so "accurate".

User avatar
Chema
Game master
Posts: 2512
Joined: Tue Jan 17, 2006 10:55 am
Location: Gijón, SPAIN
Contact:

Post by Chema » Tue Nov 13, 2007 3:20 pm

Greetings all..

I am currently out of town, so don't have much time to comment on this further. However I could even modify WHITE so it can use an external random routine, if yours fits better or have any advantage in speed or size.

Will look forward to hear your sfx :) and start integrating music and sounds in the game !

On the other hand, Dbug can also continue whith the intro (don't you have to code something to present at cant-remember-the-name party :) ? ).

BTW I just now remember there are still at least one bug to hunt :(

Cheers.

User avatar
Dbug
Site Admin
Posts: 3051
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Post by Dbug » Tue Nov 13, 2007 9:32 pm

Kindergarden.

I'm currently backuping all my Oric/source code stuff, and will try to setup my Linux based OSDK.

I was not updating you on the news, but I've been working on a new version of PictConv, with a built in sprite cutter. I did that to easily create fonts and bitmaps I can use later as "sprites", like for the end credits, or displaying animations in the intro :)

User avatar
Chema
Game master
Posts: 2512
Joined: Tue Jan 17, 2006 10:55 am
Location: Gijón, SPAIN
Contact:

Post by Chema » Wed Nov 14, 2007 5:29 pm

Dbug wrote:Kindergarden.
That was it. Sorry but I was writting the post very quickly and had nearly no time to get back tot he forum and check the post...
I'm currently backuping all my Oric/source code stuff, and will try to setup my Linux based OSDK.

I was not updating you on the news, but I've been working on a new version of PictConv, with a built in sprite cutter. I did that to easily create fonts and bitmaps I can use later as "sprites", like for the end credits, or displaying animations in the intro :)
Both seem very interesting. If the new Oric emulator becomes a reality and can be used under Windows, then we could develop and play on both systems easily :)

Twilighte, I see no problem on the interface to play sfx and tracks. It seems very easy to use. As the channels in tracks are fixed, I suppose that it is necesary to try to keep "vital" effects on channel C, or they could ruin the track. Am I right? What would happen if in pool (while the corresponding track is being played) footsteps or commlink messages sound on either channel A or B?

I have to think about what effects to put in each channel, or if we are to use allways channel C for sfx, which is another possibility, and B for those sounds in the background like alarms (when under alarm better not to have ambient music) or computer beeps... any ideas?

Just one thing more. Is there any easy way to detect when an effect has finished, or do I need to do a waiting loop with the time the effect lasts?

I am thinking about lifts, for instance. Lift starts moving so I start the effect and stop it as soon as the room loads. Then I start the second part of the sfx --- which ends with a 'ping' and
after it has finished the room is shown (for instance).

BTW, have just corrected the overlapping characters bug. I think it works perfectly but visually I am not satisfied, as when both characters take the same position, they are not rendered correctly.

Regards.

Post Reply