English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Asm / Hardware

 
 
Thread Tools
Old 13 October 2022, 20:58   #1
remz
Registered User
 
Join Date: May 2022
Location: Canada
Posts: 149
Music and VBL while reading files

Hello coders,

I would be happy to get help on the following topic:
I'd like my game to be able to animate sprites (or other things) and continue to play music while accessing the file system.

At the moment, I am coding in C using ACE https://github.com/AmigaPorts/ACE
When my game needs to read a file from disk, it "enables the OS" by putting dmacon and intena and the 7 interrupt vectors back to normal, which then makes the Open(), Read(), etc., function properly, and once reading is done, it grabs the interrupt vectors, which means the OS is "disabled".

While it works OK, it doesn't allow animating or music to continue while the OS is reading files. (Currently if I try it, the music will simply stutter and repeat the same note until the OS is disabled once again, so the game' interrupts are re-activated).

Is there a clean, easy, os-friendly way of doing this?
Thank you very much, as always!
RemV
remz is offline  
Old 13 October 2022, 22:07   #2
a/b
Registered User
 
Join Date: Jun 2016
Location: europe
Posts: 1,089
Yeah, if you install your interrupt vectors, the ones you actually use and don't touch the rest, in an os-friendly way (exec's AddIntServer()) and don't mess with intena and dmacon too much. OS is using interrupts to multii-task so if that's a problem call Forbid() instead of poking intena (you can still load/save).

Last edited by a/b; 14 October 2022 at 13:02. Reason: edit: typos
a/b is offline  
Old 13 October 2022, 22:20   #3
hooverphonique
ex. demoscener "Bigmama"
 
Join Date: Jun 2012
Location: Fyn / Denmark
Posts: 1,659
I think others have had success with just enabling level 2 or 6 only (can't remember which) to load from HD without re-enabling the whole system.

@a/b: using dos will re-enable multitasking, so if you're relying on Forbid, it may not work as you expect (i.e. your Forbin is undone).
hooverphonique is offline  
Old 13 October 2022, 22:40   #4
a/b
Registered User
 
Join Date: Jun 2016
Location: europe
Posts: 1,089
Yeah, I'm aware that some functions break Forbit() as well as Disable(), I didn't mean it can be used as a one-and-done, just apply it when needed (e.g. after done loading).

I'd guess it also depends on OS version, what device are you loading from, etc. Safest way is to use OS, but yeah you might get away with less in some/most/all(?) cases.
a/b is offline  
Old 14 October 2022, 12:49   #5
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,570
I noticed that ACE uses my ptplayer for music, but I can only guarantee its function when you have taken over the system.
I know I'm repeating myself, but there are only two solutions:

1. Write your game 100% OS-friendly without hacking the hardware directly (this basically excludes my ptplayer, and probably also ACE), as a/b indicated in his first reply.
2. Take over the system, kill the OS, do never return to it until reboot. This is usually the best approach for games and demos, and gives you all options, but restricts you to floppy disk trackloaders, as you cannot write drivers for all existing mass storage devices.

Everything else feels hackish and you will always find a configuration which causes trouble.
phx is offline  
Old 14 October 2022, 12:56   #6
Thomas Richter
Registered User
 
Join Date: Jan 2019
Location: Germany
Posts: 3,451
Quote:
Originally Posted by remz View Post
Is there a clean, easy, os-friendly way of doing this?
RemV
The clean way of doing this to use the exec interrupt handler chain where you can install a "struct Interrupt" yourself which will be called, for example, on a VBI. This then cooperates nicely with the remaining Os. Do not fiddle in the 68K autovector table.
Thomas Richter is offline  
Old 14 October 2022, 15:02   #7
remz
Registered User
 
Join Date: May 2022
Location: Canada
Posts: 149
Thank you for your inputs:
After much fiddling, I was able to make it work with a mixed approach:
ACE overtakes the whole system 7 levels while in 'game mode', and when going back into 'OS mode' to allow file reading, it restores everything back to the OS.
The modification I've added is by registering my vertb int server using the struct Interrupt you mentioned:
struct Interrupt rvInt3Server;
... fill up the struct ...
AddIntServer(INTB_VERTB, &rvInt3Server);
I found this link with good explanation too: https://wiki.amigaos.net/wiki/Exec_Interrupts
So when the OS system is enabled, my int server continues to be triggered, making the music continue to play, and when the OS system is disabled (for precise interrupt and dma control during gameplay), then the normal int3 handler is taking care of updating the music.
The result works perfectly, from Ram, to HD, to floppy, on OS 1.2 up to 3.1, with any Amiga models I managed to try in WinUAE.
remz is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Reading files from current directory in assembly hukka Coders. System 40 21 May 2021 12:14
VBL interrupts (VBCC) LastManStanding Coders. C/C++ 14 14 October 2020 12:14
Reading files and other stuff. Sim085 Coders. C/C++ 9 03 May 2020 10:02
Reading / writing files and the keyboard jimmy2x2x Coders. Asm / Hardware 3 07 December 2014 19:58
Linking VBL interrups under the system Photon Coders. General 1 09 March 2006 16:51

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 06:31.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.13206 seconds with 13 queries