Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash in games with sound effects #6

Open
jlcebrian opened this issue Oct 3, 2023 · 0 comments
Open

Crash in games with sound effects #6

jlcebrian opened this issue Oct 3, 2023 · 0 comments

Comments

@jlcebrian
Copy link

DAT files with sound effects doesn't seem to be properly supported. This introduces a number of issues, including a crash when a game tries to play a sound using the SFX condact. The way sound works in DAAD is via the PICTURE command, which loads the sound data in the picture buffer, to be played later with SFX n 255.

The fastest way to reproduce the crash is playing the Amiga version of Espacial, which plays a sound as soon as you interact with the menu using the space bar.

  File "C:\Users\Admin\Desktop\naps 23.10 portable win32\naps\condactos_daad.py", line 206, in c1_PICTURE
    if gui.hay_grafico (picno):
  File "C:\Users\Admin\Desktop\naps 23.10 portable win32\naps\gui_pygame.py", line 683, in hay_grafico
    if not graficos_bitmap.recursos[numero] or 'imagen' not in graficos_bitmap.recursos[numero]:
IndexError: list index out of range

Sounds are identified in the DAT file because bit 4 of the entry flags is set (bit 0 is the floating flag, bit 1 is the cache flag, bit 2 switches the CGA red/blue palette, bit 3 I have no idea).

In addition, sounds have the same 6 byte header as images, except the height word has the highest bit set (just like the width word is set to mark compressed images). Width and height are set to 0 otherwise.

The sound data itself is a raw signed 8 bit sample. The playback frequency is determined by the X value in the DAT header, which accepts values from 0 to 5 for frequencies of 5, 7, 9.5, 15, 20 and 30Hz respectively. SFX n 255 just plays the sample and blocks until the playback ends (the first parameter, n, is ignored).

SFX, when parameter 2 is not 255, sets a system variable to the value of parameter 1. In this variable, bit 0 marks if there should be a click sound when a key is pressed, and bit 1 enables keyboard repeat. I've not supported this in ADP and as far as I know there is no game using this feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant