08 September 2013, 13:32 | #1 |
Registered User
Join Date: Dec 2010
Location: Athens/Greece
Age: 53
Posts: 719
|
How to load data and keep your main loop running?
Hi,
I take it you can't just call Dos functions when you have disabled the system, right? So, what do you have to enable to have Dos working? (Do you go for a full system restore, load, retake the system? Or, just the stuff that Dos needs?) I guess, demos work with trackloaders. But I am not after that. Say I have 5 pictures in hard disk: foo1.raw, foo2.raw, foo3.raw, foo4.raw, foo5.raw How do I load one at a time (while not stopping my main loop, i.e. background loading) at runtime? Thx in advance and sorry for the noob questions. |
08 September 2013, 14:19 | #2 |
ex. demoscener "Bigmama"
Join Date: Jun 2012
Location: Fyn / Denmark
Posts: 1,630
|
Multitasking needs to be enabled to use dos.. In most cases, enabling INT2 should do the trick..
To do background loading, you need some extra multitasking.. dos only works when called from a process (i.e. a task is not enough), so you could do the background loading in your main process and have a high priority task for your main loop stuff.. This gets a bit complicated, so if you could allow your main to block while loading and do all your realtime processing in the vb interrupt, that is probably easier.. |
08 September 2013, 14:58 | #3 |
move.l #$c0ff33,throat
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
|
Check this thread, I have explained what you need to do to load files even though the system has been killed.
|
08 September 2013, 22:41 | #4 |
Registered User
Join Date: Dec 2010
Location: Athens/Greece
Age: 53
Posts: 719
|
Okie, I went with hooverphonique's suggestion and moved all my stuff inside the vbl interrupt. That part worked fine.
Now, I am supposed to press a key and the Loading routine gets called. And it does. But, it doesn't want to work. If I call the load routine before all the setting of INTENA, INTREQ & DMACON the routine works. After that...nothing. It doesn't even crash. My vbl interrupt keeps working and stuff happens as before. My main loop just isn't executing anymore. Can't exit anymore, needs reset. When I trace with fs-uae debugger on the first dos call (Open) I get a screen of "Exception 26, PC=00F813A6" Code:
* The disk controller can issue three kinds of interrupts: * DSKSYNC (level 5, INTREQ bit 12) -- input stream matches the * DSKSYNC register. * DSKBLK (level 1, INTREQ bit 1) -- disk DMA has completed. * INDEX (level 6, 8520 Flag pin) -- index sensor triggered. ;#%1111000000101010 ; +--Set ; +--Master ; +-- External interrupt (level 6) ; +--Disk sync register (DSKSYNC) matches disk ; +-- Vbl ; +-- Ports ; + Disk block move.w #$7fff,$dff09a ;disable all bits in INTENA move.w #%1111000000101010,$dff09a move.w #$7fff,$dff09c ;disable all bits in INTREQ move.w #$7fff,$dff09c ;disable all bits in INTREQ move.w #$7fff,$dff096 ;disable all bits in DMACON move.w #$87d0,$dff096 ;enable disk dma as well I even tried calling the old_$68_vector for cases that the keyboard interrupt routine doesn't serve. It runs for a few frames and then crashes. Code:
;check if keyboard has caused interrupt btst #INTB_PORTS,(intreqr+1,a0) beq .end btst #CIAICRB_SP,(ciaicr,a1) beq .end Code:
.calloldone movem.l (a7)+,d0-d1/a0-a1 jmp (old_keyboard_int) Thank you for the pointers so far, any more would be very much appreciated. |
09 September 2013, 08:07 | #5 |
WinUAE developer
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,534
|
Hint: Reading CIA interrupt register will automatically clear it.
|
09 September 2013, 09:15 | #6 |
Registered User
Join Date: Dec 2010
Location: Athens/Greece
Age: 53
Posts: 719
|
Thanks to Toni's hint I got somewhere.
I modified the load routine to something like: bsr restore_system_$68 loadroutine bsr regrab_keyboard And it sort of works! Yay! Two new problems: * when files are in hard disk, program runs as it should. After you exit, when you try to access the floppy disk it gurus 8000 0006. * when files are in floppy disk, program runs until I press the key that triggers the loading, then gurus 8000 0006 |
09 September 2013, 09:22 | #7 |
Registered User
Join Date: Dec 2010
Location: Athens/Greece
Age: 53
Posts: 719
|
Hmm, now that I think of it, the workarround defeats the whole purpose of the exercise. :-)
Senario. You play a sucky shootemup, you control your ship with the keyboard and background loading starts. Ooops, no keyboard handling anymore, bye bye. So the problem at hand is: Keep the handling of keyboard AND keep the dos working. Oh man, and I was so happy for a moment there... |
09 September 2013, 10:58 | #8 |
ex. demoscener "Bigmama"
Join Date: Jun 2012
Location: Fyn / Denmark
Posts: 1,630
|
you could maybe leave int2 enabled all the time and use input.device to read the keyboard?
(or alternatively keyboard.device).. |
09 September 2013, 11:12 | #9 |
Moderator
Join Date: Nov 2004
Location: Eksjö / Sweden
Posts: 5,628
|
In Uncle Tom Sonix I did it by putting the hardware-mode (demo) code in Vblank (or was it a copper int?) instead of the main loop, and enabling enough system interrupt bits in INTENA to load files with normal DOS calls "in the main loop".
|
09 September 2013, 12:03 | #10 |
Registered User
Join Date: Dec 2010
Location: Athens/Greece
Age: 53
Posts: 719
|
@hooverphonique I am afraid so ;-)
@Photon Did you have an active int2 handler as well though? Basically, what you described is what I tried to do. I've attached the code & pic. (68020+ code) Starfield happens at 320x256 in a 512x256 screen. I shifted the bitplane pointers so we look at the right part, cause there at the rightmost 192x256 is where I'll load the pic (that part doesn't get cleared by the blitter, so it fits). Left mouse button or escape quits. Right mouse button, show raster time. Now pressing '1' should load the pic. I've commented *out* the workarround, if you uncomment it also uncomment the line before the rts to regrab int2 (If I lose int2 handling, the pic loads but only from hdisk, gurus on floppy) Yeah, I know the pic needs color remapping :-) |
09 September 2013, 18:50 | #11 |
Registered User
Join Date: Dec 2010
Location: Athens/Greece
Age: 53
Posts: 719
|
GOT IT!
It was the initial setup of intena Code:
;#%1111000000101010 ; +--Set ; +--Master ; +-- External interrupt (level 6) ; +--Disk sync register (DSKSYNC) matches disk ; +-- Vbl ; +-- Ports ; + Disk block MyInts = %1100000000101000 So, I had to turn-off External-Interrupt-lvl6, DSKSYNC and DiskBlock (I also had to fiddle arround with the shutdown code but minor things) One question though, just curious, why I can't call Dos' Delay()? (i.e. what more does Delay need to be on for it to work?) |
09 September 2013, 18:55 | #12 |
move.l #$c0ff33,throat
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
|
Delay() might use the CIA timers/interrupts, try to enable level 6 interrupts and see if that helps.
|
09 September 2013, 20:13 | #13 |
Registered User
Join Date: Dec 2010
Location: Athens/Greece
Age: 53
Posts: 719
|
@StingRay It didn't help.
Ok, here is a working example for anyone that might stumble upon this. Assembles with vasm/asmone. You press '1' and a picture loads at the right part of the screen, while the starfield that runs on the left part of screen keeps going. Added input handler. Cursor up, increases star speed. Cursor down, decreases star speed. Cursor right, scrolls (very roughly, 16 pixels gaps) right Cursor left, scrolls left Left mouse button exits (also escape key) Right mouse button show raster time (plus decimal key value of last rawkey) Last edited by alkis; 09 September 2013 at 20:15. Reason: Wrong attachment |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Main Source BBS | paranoid | Amiga scene | 15 | 13 August 2014 16:30 |
Banshee - main character | mailman | Retrogaming General Discussion | 2 | 10 September 2009 19:24 |
Main 145W PSU | Anemos | Hardware pics | 4 | 17 May 2008 03:31 |
Civ2 mac main file | derringer | request.Other | 1 | 18 February 2008 21:55 |
Main Actor Broadcast | Pyromania | request.Apps | 1 | 17 September 2002 13:29 |
|
|