English Amiga Board


Go Back   English Amiga Board > Coders > Coders. General

 
 
Thread Tools
Old 22 February 2011, 10:22   #1
Dokugogagoji
 
Posts: n/a
Mimic XCopy KillSys function

Hey guys, I'm new...and too young for having lived fully the Amiga scene, sadly.

Since you are more expert than me in Amiga low level programming and I want to start to make my own demoscenes for my Miggy 600, I'm training myself to use very well the custom chips directly with asm. But I am all but good :P

Ended this remark, the question I want to ask regarding this:
[ Show youtube player ]

It frees "System area" to gain more free ram. (I do know there are some pre-built binaries that do these on Aminet but I would not use them).

Now, it is not shown very well but it disables the multitasking so:
Code:
 move.l 4.w,a6 ; EXEC address on a6
 jsr -$78(a6) ; disable multasking
Then, the numbers of colors goes down so I suppose it lowers the number of bitplanes to at least 3, moving the according number on 14,13,12 bits of $dff100/BLCON .
Am I (probably) wrong?
Is there any other routines it seems to do?
...or simply is there a simple kickstart function that do it already?

Important note: Please don't post asm portion of code for my sake. I don't want to be a (asm) script kiddie and so I want to be able to understand fully for myself without "copying already done pieces of code"...at least I could do it when I have already understood it, but not before so I'll never learn:P So some tips about what I should do to mimic that function, and not how.

Thanks for help!
 
Old 22 February 2011, 16:05   #2
Leffmann
 
Join Date: Jul 2008
Location: Sweden
Posts: 2,269
1. Call Forbid to prevent other programs from doing any funny stuff while we're pausing the system
2. Call OwnBlitter and then WaitBlit to make sure we can use the blitter without screwing up any program that was currently using it
3. Call LoadView with an argument of 0 to get a standard display output
4. Call WaitTOF (some say you must call WaitTOF twice but I dunno about that)
5. Save the contents of the INTENAR, INTREQR and DMACONR hardware registers
6. Disable all interrupts and DMA by writing $7FFF to INTENA and INTREQ, and $7FF to DMACON

You now have full control of the system and can safely program all the graphics hardware.

To return back to AmigaDOS or Workbench:

1. Disable all interrupts and DMA again
2. Call RemakeDisplay
3. Read the gb_copinit value from the graphics.library base structure and write it to COP1LC and then write any value to COPJMP1
4. Get the previously saved contents of INTENAR, INTREQR and DMACONR registers and set bit 15 to 1 in each of these values and write them back to INTENA, INTREQ and DMACON
5. Call WaitTOF for changes to take effect
6. Call DisownBlitter
7. Call Permit

There's more to this if you need things like file access during your demo, interrupt and CPU control etc. but I think this will suffice to get started.

EDIT: corrected Disable/Enable to Forbid/Permit

Last edited by Leffmann; 22 February 2011 at 18:27.
Leffmann is offline  
Old 22 February 2011, 18:17   #3
mr.vince
Cheesy crust
 
mr.vince's Avatar
 
Join Date: Nov 2008
Location: Hawk's Creek
Age: 48
Posts: 1,383
This is how X-Copy does it. Just pasted the main KILLSYS part here, it branches to other things, and comments are in German. That's how the source is...

Code:
 IFEQ SOLO
;    *** KILLSYSTEM (KillSys)
;    ***----------------------
KILLSYSTEM:
    move.l    4,a0        
    move.l    62(a0),maxchip
    
    lea    w_ksys,A0
    bsr    x_OpenWindow
    move.l    D0,-(SP)    ; Windowpointer speichern
    lea    w_ksys,A0
    bsr    x_CheckGadgets
    move.w    D0,D6    ; Rueckgabewert speichern
    bsr    ReleaseLMB
    RestoreWindow (SP)+
    cmp.w    #1,D6
    bne    return    ; es ist nicht OK angeklickt worden
    
    bsr    DrivesOFF
    bsr    CheckFastMem
    movem.l    default,d1-d7/a1-a2; alle wichtigen Werte an SOLO uebergeben    
    movem.l    d1-d7/a1-a2,defstore
    move.w    #$7fff,D0
    move.w    D0,$DFF096
    move.w    D0,$DFF09C
    move.w    D0,$DFF09A

    move.l    #SOLOSTART-8,A1    ; Destination ($3F8)
;    lea    end_of_menue,a0
;    lea    end_of_solo,a2
;.copy    move.b    (a0)+,(a1)+
;    cmp.l    a0,a2
;    bne.s    .copy

    lea    tmpstackend,a7
    lea    solodata,a0    ; Source
    lea    SOLOSTART-8,a1    ; destination
    bsr    PPDecrunch

;     bsr    CheckSerial
    movem.l    defstore,d1-d7/a1-a2
;    move.l    #$FC0002,D7    ; Ruecksprungadresse (fällt aus!)
    jmp    SOLOSTART-8

defstore:    DS.L 18
tmpstack:    DS.B 128
tmpstackend:

    INCLUDE    "depack.s"



 ENDC

 IFEQ SOLO
mr.vince is offline  
Old 22 February 2011, 20:16   #4
StingRay
move.l #$c0ff33,throat
 
StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
Quote:
Originally Posted by Dokugogagoji View Post
It frees "System area" to gain more free ram.
Notice that you can't quit back to AmigaOS once you used X-Copy's "KillSys". This is because X-Copy will most probably use all available Chip-RAM (512k, $0-$80000) for its buffers during copying and they don't have to be saved/restored as it would be the case when you want to return to the OS.

Quote:
Originally Posted by Dokugogagoji View Post
Then, the numbers of colors goes down so I suppose it lowers the number of bitplanes to at least 3, moving the according number on 14,13,12 bits of $dff100/BLCON .
Am I (probably) wrong?
That's correct. Haven't checked how many bitplanes are used after KillSys but 3 seems to be a good guess. Also done to have more RAM for buffers (less bitplanes = less memory used).


Quote:
Originally Posted by Dokugogagoji View Post
...or simply is there a simple kickstart function that do it already?
Nope. Rule of thumb: If you bang the hardware, avoid OS calls as much as possible. There are routines in exec to disable multi-tasking/interrupts (Forbid, Disable) but most of the "system kill" you have to code yourself. See Leffmann's post above for how to do it.

Quote:
Originally Posted by Leffmann View Post
4. Call WaitTOF (some say you must call WaitTOF twice but I dunno about that)
Two WaitTOF's are needed so that interlaced displays will be properly reset (2 copperlists!)

Last edited by StingRay; 22 February 2011 at 20:22.
StingRay is offline  
Old 23 February 2011, 08:11   #5
pmc
gone
 
pmc's Avatar
 
Join Date: Apr 2007
Location: completely gone
Posts: 1,596
Quote:
Originally Posted by Dokugogagoji
Important note: Please don't post asm portion of code for my sake.
Quote:
Originally Posted by mr.vince
This is how X-Copy does it.
Ooooops.
pmc is offline  
Old 23 February 2011, 09:46   #6
mr.vince
Cheesy crust
 
mr.vince's Avatar
 
Join Date: Nov 2008
Location: Hawk's Creek
Age: 48
Posts: 1,383
Quote:
Originally Posted by pmc View Post
Ooooops.
I guess there is enough of external branching (with meaningful names) to avoid this being a pre-made script ready for usage.

I must admit I overlooked the last paragraph.
mr.vince is offline  
Old 23 February 2011, 10:14   #7
StingRay
move.l #$c0ff33,throat
 
StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
Quote:
Originally Posted by mr.vince View Post
I guess there is enough of external branching (with meaningful names) to avoid this being a pre-made script ready for usage.

I must admit I overlooked the last paragraph.
Except for these 4 lines:

Code:
    move.w    #$7fff,D0
    move.w    D0,$DFF096
    move.w    D0,$DFF09C
    move.w    D0,$DFF09A

the code is rather uninteresting for the thread opener anyway.
StingRay is offline  
Old 23 February 2011, 10:33   #8
pmc
gone
 
pmc's Avatar
 
Join Date: Apr 2007
Location: completely gone
Posts: 1,596
Quote:
Originally Posted by mr.vince
I must admit I overlooked the last paragraph.
Nah, no worries man. Sorry, I wasn't trying to be rude, just found it funny really. Plus, as Sting says, I'm sure that the code you posted doesn't give too much away.
pmc is offline  
Old 23 February 2011, 20:55   #9
Lonewolf10
AMOS Extensions Developer
 
Lonewolf10's Avatar
 
Join Date: Jun 2007
Location: near Cambridge, UK
Age: 44
Posts: 1,924
I tried to put a clean kill system routine at the start of my code (following Leffmanns guide) to fix a problem where the initial screen was occationally corrupted (DIWSTRT and a few other settings were wrong).

The problem I have now is that I have disabled the blitter, which is needed for a later screen. Can anyone suggest what I might be doing wrong?
I have listed what I did to disable interrupts previously (old), and what I have changed it to (new).

Code:
Disabling:

Old			New
****			****
$4000 -> INTENA		$7FFF -> INTREQR
$01A0 -> DMACON		$7FFF -> INTENA
			$07FF -> DMACON

Enabling:

Old			New
***			***
$8180 -> DMACON		$83A0 -> DMACON
			$C070 -> INTENA

Regards,
Lonewolf10
Lonewolf10 is offline  
Old 23 February 2011, 21:43   #10
StingRay
move.l #$c0ff33,throat
 
StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
Quote:
Originally Posted by Lonewolf10 View Post
The problem I have now is that I have disabled the blitter, which is needed for a later screen. Can anyone suggest what I might be doing wrong?
You need to enable blitter DMA which is bit 6 in DMACON.
$83a0 = sprite, copper, bitplane DMA enabled
$83a0 | 1<<6 = $83e0 -> sprite, copper, blitter, bitplane DMA enabled


Code:
 $7FFF -> INTREQR
I hope this is a typo, INTREQR is read only.
StingRay is offline  
Old 23 February 2011, 22:37   #11
Lonewolf10
AMOS Extensions Developer
 
Lonewolf10's Avatar
 
Join Date: Jun 2007
Location: near Cambridge, UK
Age: 44
Posts: 1,924
Quote:
Originally Posted by StingRay View Post
You need to enable blitter DMA which is bit 6 in DMACON.
$83a0 = sprite, copper, bitplane DMA enabled
$83a0 | 1<<6 = $83e0 -> sprite, copper, blitter, bitplane DMA enabled
Ahh, thanks. I knew I was missing something obvious


Quote:
Originally Posted by StingRay View Post
Code:
 $7FFF -> INTREQR
I hope this is a typo, INTREQR is read only.
Yes, it was a typo - should have been INTREQ


Regards,
Lonewolf10
Lonewolf10 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
Xcopy with dongle elpiloto request.Apps 8 09 December 2012 18:27
Seeking Xcopy Pro Washac request.Apps 3 13 February 2010 20:03
XCopy problem orange support.Apps 0 27 December 2009 22:07
Xcopy mtb support.Apps 5 03 December 2003 08:40
XCopy Ziaxx Retrogaming General Discussion 5 04 January 2003 00:12

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 17:29.

Top

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