Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > reading flags
2011-04-12 15:44
ready.

Registered: Feb 2003
Posts: 441
reading flags

Hello,
I am packing some parts together to be loaded using DreamLoad and I want to dedicate n clock cylces per frame for loading. To do this, at a certain of the demo code point I start a signle shot CIA timer to generate a NMI after some delay (during which the loader loads). I jump to the loader code, which later on is interrupted by the previously set NMI. I change a bit the stack and stack pointer for jumping back and forth between demo and loader and it seems to work....


....but after some frames it crashes. I suspect that the problem is that when the code enters the loader the flags are changed and I should save not only A, X, Y, SP but flags also.

Is there a way to read/write the flags all in one, like TSX and TXS for the stack pointer?
 
... 4 posts hidden. Click here to view all posts....
 
2011-04-14 11:38
HCL

Registered: Feb 2003
Posts: 716
Sounds cool!! The loader at least, don't know about the demo yet :).
2011-04-14 12:12
ready.

Registered: Feb 2003
Posts: 441
I don't want to say anything about the demo, yet.
But I am having this problem of linking the parts together, most of which were done not by me. I had only runnable individual compressed files of each part. So, I had to modify the code from VICE monitor, adding the needed code to support the loader.

So I thought I could jump to the loader at some point inside the demo, while the effect is running and have a single shot NMI to force the program to leave the loader code and go back to the demo effect code.

The problem is that standard DreamLoad is meant to be run in background as the main program and be interrupted by an irq. I needed instead to run the demo effect in "background" (not really since all effects use IRQs) and dedicate a pre-set amount of rastertime to DreamLoad, not too much otherwise the effect slows down/crashes, not too little otherwise loading takes too long.

Any suggestion about how I could do this differently?
2011-04-15 10:21
HCL

Registered: Feb 2003
Posts: 716
I always do it the other way around, run the demo effects inside the irq:s and do the loading outside. This way loading gets all the time not used by irq (or nmi). But then, you seem to not be in charge of all the code, so perhaps that's not an option. Depends on alot of things..
2011-04-15 14:21
WVL

Registered: Mar 2002
Posts: 886
HCL's way is the normal way to do it, but I use a little bit different way again..

In the real background, I do the loading. The effects run in my IRQ's.

But sometimes I have to do stuff that I cannot do inside an IRQ, like decompressing some datas (or copying a shitload of $d800 colors! :). What I do then, is to make an 'inbetween' background by firing a 'background IRQ' in which decompressing takes place. The normal effect-IRQ's can then still interrupt the 'background' IRQ.

So the system kinda looks like this:
loop:
 background stuff here
 load some stuffs..
 goto loop or wait here until part ends

irq:
 this gets fired depending on the raster
 if (needforbackgroundirq)
   goto backgroundirq
 else
 rti

 (note : basically I dont end the normal effect IRQ, but I keep it running to do the more important background stuffs! I only make it so that the next effect IRQ can still interrupt it)

backgroundirq
  save a,x,y,p
  cli ;make sure effect irqs can still interrupt
  do background stuff that's more important than the real background stuff
  load a,x,y,p
  rti ;go back to background loop
2011-04-16 10:10
JackAsser

Registered: Jun 2002
Posts: 1989
For Mekanics I used a simple theading method when I got bored to rewrite the code to be IRQ-reentrant. Instead the part is a simple linear loop but instead of polling $d012 for framesync I implemented a yield() call which gave up the CPU for another thread until next frame. The "other" thread was the loader.

So with this mechanism you get co-operative threading between two threads and the IRQ is the scheduler.

But normally we do it like HCL said.
2011-04-16 16:30
Oswald

Registered: Apr 2002
Posts: 5022
wvl, I dont see where do you do the "effect" :) there's background stuff I and background stuff II. it looks the same as HCL's method, but with different name for stuff :)

(edit: btw why did the horizontal scrollbar appear in chrome for this page?)
2011-04-16 19:06
WVL

Registered: Mar 2002
Posts: 886
Oswald : effect happens in the IRQ ofcourse :)

And you get the horizontal scrollbar because of my too-long sentence between code tags (which I can't edit anymore..)..
2011-04-16 20:25
Pantaloon

Registered: Aug 2003
Posts: 124
i do it as the rest of you guys, one main interrupt that drives the effect, the code executing outside the irq i normally do loading in, and if i need it i issue more irq's from the main irq and doing a cli to get higher priority then the normal loop.

sometimes you want loading to be of higher priority then effect updates so you just switch place between the two.
2011-04-16 20:50
Oswald

Registered: Apr 2002
Posts: 5022
Panta, and how do you make sure that the loader returns from time to time before finishing a whole file?
2011-04-17 16:59
ready.

Registered: Feb 2003
Posts: 441
Oswald, your last question was exactly my original problem. I hope my previous posts clearify this.
Previous - 1 | 2 - Next
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
YTM/Elysium
Mike
The Human Co../Maste..
csabanw
Icecube/Light
hedning/G★P
Clayboy
Guests online: 177
Top Demos
1 Next Level  (9.8)
2 Mojo  (9.7)
3 Coma Light 13  (9.7)
4 Edge of Disgrace  (9.6)
5 Comaland 100%  (9.6)
6 No Bounds  (9.6)
7 Uncensored  (9.6)
8 Wonderland XIV  (9.6)
9 Memento Mori  (9.6)
10 Bromance  (9.5)
Top onefile Demos
1 It's More Fun to Com..  (9.7)
2 Party Elk 2  (9.7)
3 Cubic Dream  (9.6)
4 Copper Booze  (9.5)
5 TRSAC, Gabber & Pebe..  (9.5)
6 Rainbow Connection  (9.5)
7 Wafer Demo  (9.5)
8 Dawnfall V1.1  (9.5)
9 Quadrants  (9.5)
10 Daah, Those Acid Pil..  (9.5)
Top Groups
1 Nostalgia  (9.3)
2 Oxyron  (9.3)
3 Booze Design  (9.3)
4 Censor Design  (9.3)
5 Crest  (9.3)
Top Organizers
1 Burglar  (9.9)
2 Sixx  (9.8)
3 hedning  (9.7)
4 Irata  (9.7)
5 MWS  (9.6)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.044 sec.