BGM player in assembly

By Danjovic

Expert (80)

Danjovic's picture

07-06-2018, 02:17

This function, written in assembly, is intended to be used in games or demos.
It provides a single channel sound track sync'ed with vertical retrace that can be generated from a RTTL (nokia ringtone language) string by a python script

Project page on Hackaday.io (link)

Login or register to post comments

By Grauw

Ascended (8457)

Grauw's picture

07-06-2018, 09:33

Nice!

The GPL license makes it of limited use for a library though, due to the copyleft. I'd recommend BSD for libraries, I see GPL more as something for standalone software (though there too I still prefer BSD).

By Metalion

Paladin (1009)

Metalion's picture

07-06-2018, 13:20

HALT cannot be used to sync to HBLANK.
It will be triggered by every interrupt occuring in the system, not only HBLANK.

By Grauw

Ascended (8457)

Grauw's picture

07-06-2018, 15:37

Easiest way to vsync is to poll JIFFY if it changes:

    ld hl,JIFFY
    ld a,(hl)
Loop:
    cp (hl)
    jr z,Loop

By Wolverine_nl

Paragon (1037)

Wolverine_nl's picture

07-06-2018, 16:41

Grauw wrote:

Easiest way to vsync is to poll JIFFY if it changes:

    ld hl,JIFFY
    ld a,(hl)
Loop:
    cp (hl)
    jr z,Loop

Is Loop label the main loop of the game/animation/etc.? If yes, would the updates come before the compare hl?

By Grauw

Ascended (8457)

Grauw's picture

07-06-2018, 16:45

No just a simple busy wait loop there, waiting for JIFFY to change, in place of the halt (JIFFY increases every vblank int).

By Danjovic

Expert (80)

Danjovic's picture

07-06-2018, 16:49

Grauw wrote:

Nice!

The GPL license makes it of limited use for a library though, due to the copyleft. I'd recommend BSD for libraries, I see GPL more as something for standalone software (though there too I still prefer BSD).

Oh, I have never thought about that. Thanks for the tip, I'll consider the change for the BSD or another less restrictive license.

By Wolverine_nl

Paragon (1037)

Wolverine_nl's picture

07-06-2018, 16:48

ok, so this would be itself within a bigger loop like the rest of the updates? If it is suppose to control a stable vsync.
I am asking, because i am also busy with animation (bgm in a later stadium) and trying to have a more stable framecount.

By Grauw

Ascended (8457)

Grauw's picture

07-06-2018, 23:28

It’s just an easy way to wait for the ISR triggered by the vsync signal (which occurs when the VDP reaches the bottom of active display) in a main loop, so without any fancy hooks. If your code takes longer than one frame, then you get a frame skip.

By DarkSchneider

Paladin (870)

DarkSchneider's picture

08-06-2018, 10:11

Metalion wrote:

HALT cannot be used to sync to HBLANK.
It will be triggered by every interrupt occuring in the system, not only HBLANK.

Right. Could put HALT and then check JIFFY on each un-HALT.

Also remember JIFFY increases if the system ISR is called, the default behavior.

Grauw wrote:

If your code takes longer than one frame, then you get a frame skip.

You get a slowdown really. For frame skipping you have to implement async drawing.