Kong [1.0.3]

This one will be great as always. I like these games :wink:

2 Likes

Thanks for the feedback. I really like making the Game and Watch games - the game concept is already done, the graphics are in someone else’s capable hands and all I have to worry about is the code! I wonder what other G+W I can do next?

2 Likes

You can continue on the Kong familly with DK Jr. It’s a good little game too :wink:
Else yo ucand do Oil Panic maybe ?

I had DK Jnr as a kid. I have no idea where that unit went but I want it back (sisters if you are reading this, I suspect you) …

2 Likes

My personal favourite was Donkey Kong 2.

1 Like

The brown case ? Yes, it was a great game too i have pass some hour on it.

Yup, the brown case, first ‘electronic’ game my mom ever bought me back in the day.

1 Like

I never saw one of those but it looks good. Maybe the next game??

In 1983 (which was when the DK2 was released, apparently) was when I got my Commodore VIC 20 - I think I left G+W behind for the raw power of a 6502 + 5K of RAM!

Well, the original Donkey Kong arcade machine used an Intel MCS-48 8035 microcontroller for sound, and the disassembled sound code is available (some hidden / unused music and sounds were even found in there) I could possibly translate the pattern data into ArduboyTones frequency and duration pairs :smile:

A few of the sounds were actually made outside of the microcontroller by discrete logic circuits though - you can hear those here.

There is also some Atari 800 source code available, and some commentary by one of its programmers:

http://www.dadhacker.com/blog/?p=987
http://www.dadhacker.com/blog/?p=1047

Well, that was a pleasant rabbit burrow to go down… :laughing:

3 Likes

Really, that would be cool!

1 Like

Actually, just had a quick look at the ASM - its awkward to convert but not impossible. However this appears to be two channel.

The bits 0 - 3 give the note and 16 combinations - would you assume A = 0, A#, B, C, C#, D, D#, E, F, F#, G, G# = 12?

I like this bit:

; junk
4CC:  FF FF FF FF
4D0:  FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
4E0:  FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
4F0:  FF FF FF FF FF FF FF FF

You could use ArduboyPlaytune for two channel sound - would be worth checking how much of the patterns actually want / need two channels though… might be best to write a small tool for automating the translation, and then it could be adjusted by listening to the result compared to the music from the arcade machine to work out how the bits for note / duration / octave map across?

Just dissecting one:

; Pages 3 and 4: pattern data
; ---------------------------
; Format:
;   * If the value is $00, end the pattern.
;   * Else, if bit 7 is clear, the byte is the duration for all following notes until another duration code is read.
;   * Else, for channel A:
;     * Bits 0-3 set the note (A, A#, B, C ...)
;     * Bits 4-5 set the octave (higher values choose lower octaves)
;     * Bit 6 indicates the next byte is a note to play on channel B.
;
; Channel B notes follow the same format, except bits 6-7 are ignored.
;
; This format means it is impossible to play a note on channel B without also playing one on channel A,
; and the channels cannot have separate durations.

; Pattern $00, empty

; Pattern $0a, DK climbing ladders
348: 60 CA 82 20 CC 84 40 D0 86 CA 82 08 DA 89 D9 89
358: DA 89 D9 89 DA 89 D9 89 DA 89 D9 89 08 DA 89 D9
368: 89 DA 89 D9 89 DA 89 D9 89 DA 89 D9 89 7F DA 8A
378: 00

Quick analysis:

Assuming A = 1 and G# = 12.

0x60 - Set duration to 96
0xCA - Play a F#,  channel B
0x82 - Play an A#, channel A 
0x20 - Set duration to 36
0xCC - Play G#, channel B
0x84 - Play C, channel A
0x40 - Set duration to 72
0xD0 - ???

0xD0 is 1101 0000
So it is not a duration but instead a note.
The note is the lowest four bits 0000 so invalid,

If I assume A = 0 and G# = 11 …

Then 0xCC (1100 1100) fails as it is a note, played on channel B but it is note 12.

Am I doing something wrong?

Could be that 0 or 12 is the value for NOTE_REST?

Could also approach this from the other direction and re-write ArduboyPlaytune to accept these patterns directly without converting them…

@filmote and @Vampirics your the best.

But stop teasing :sweat_smile:, the waiting is getting to much handle :rofl:

Seriously arduboy is g̶e̶t̶t̶i̶n̶g̶, a real serious gaming console!

1 Like

Of course … but which one is it?

Anyhow, the tunes rely heavily on both channels so ArduboyTones is out.

We are getting so close!

4 Likes

Would love a version of plane&tank, or maybe popeye or cement factory?

Took the pattern for the looping background music of the first level:

Pattern $01, barrels BGM

301: 2A 80 1C 84 0E 88 8A 88 00

Broke it out into bits / values:

0b00101010 = Duration, 42
0b10000000 = Channel A, Note 0 (A)
0b00011100 = Duration, 28
0b10000100 = Channel A, Note 4 (C#)
0b00001110 = Duration, 14
0b10001000 = Channel A, Note 8 (F)
0b10001010 = Channel A, Note 10 (G)
0b10001000 = Channel A, Note 8 (F)

Translated that to an ArduboyPlaytune score:

const byte score[] PROGMEM =
{
  0x90,57, 0x01,0xA4, 0x80, // Note A2,  Duration 420
  0x90,61, 0x01,0x18, 0x80, // Note C#3, Duration 280
  0x90,65, 0,140, 0x80,     // Note F3,  Duration 140
  0x90,67, 0,140, 0x80,     // Note G3,  Duration 140
  0x90,65, 0,140, 0x80,     // Note F3,  Duration 140
  0xE0
};

And here it is!

This is the sketch:

#include <Arduboy2.h>
#include <ArduboyPlaytune.h>

const byte score[] PROGMEM =
{
  0x90,57, 0x01,0xA4, 0x80, // Note A2,  Duration 420
  0x90,61, 0x01,0x18, 0x80, // Note C#3, Duration 280
  0x90,65, 0,140, 0x80,     // Note F3,  Duration 140
  0x90,67, 0,140, 0x80,     // Note G3,  Duration 140
  0x90,65, 0,140, 0x80,     // Note F3,  Duration 140
  0xE0
};

Arduboy2 arduboy;
ArduboyPlaytune tunes(arduboy.audio.enabled);

void setup()
{
  arduboy.begin();

  tunes.initChannel(PIN_SPEAKER_1);
  tunes.initChannel(PIN_SPEAKER_2);
  tunes.playScore(score);
}

void loop()
{
}

…and the arcade machine for comparison:

2 Likes

So you have got A= 0, did you find any Note 12’s - and are they rests?

Sounds great though. I have never used ArduboyPlaytune so will need to investigate.

Didn’t get that far yet, no - may need to add short rests in between the notes though, the notes coming from the arcade machine are not continuous from one note into the next, they have a shorter ‘envelope’.

1 Like