30 September 2019, 21:53 | #1 |
It's coming back!
Join Date: Jul 2018
Location: comp.sys.amiga
Posts: 762
|
Startup code, taking over the system
So, I've decided the startup code I've been using is not the best. Is there an accepted standard piece of code that everyone is using to take over and return the system?
For context, this is what I'm currently using: Code:
void TakeSystem(void) { KPrintF("In TakeSystem.\n"); AndTen(); ActiView = GfxBase->ActiView; // store current view OwnBlitter(); WaitBlit(); Disable(); systemADKCON = custom->adkconr; systemINTENA = custom->intenar; systemDMACON = custom->dmaconr; custom->intena = INTF_INTEN | INTF_ALL; // disable all interrupts custom->intreq = INTF_INTEN | INTF_ALL; // clear any interrupts that were pending WaitVbl(); WaitVbl(); custom->dmacon = DMAF_SPRITE; LoadView(NULL); WaitTOF(); WaitTOF(); WaitVbl(); WaitVbl(); // save system interrupt handers for (int i = 0; i < 6; i++) systemInterruptHandlers[i] = VBR[25 + i]; WaitVbl(); custom->intena = INTF_INTEN | INTF_ALL; // disable all interrupts custom->intreq = INTF_INTEN | INTF_ALL; // clear any interrupts that were pending } |
03 October 2019, 11:57 | #2 |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,500
|
Looks good so far, although I don't know why you disable interrupts twice.
Additionally you may want to reset FMODE and BPLCONx to standard values, in case you have to disable AGA/ECS. |
03 October 2019, 12:08 | #3 | |
It's coming back!
Join Date: Jul 2018
Location: comp.sys.amiga
Posts: 762
|
Quote:
I'll add the code to reset FMODE and BPLCONx. |
|
03 October 2019, 12:15 | #4 |
WinUAE developer
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,522
|
Don't disable interrupts before calling waittof() or loadview(). It most likely causes a hang if system has active RTG board that use hardware vertical blank interrupts.
|
03 October 2019, 13:36 | #5 |
It's coming back!
Join Date: Jul 2018
Location: comp.sys.amiga
Posts: 762
|
Do I even need to call LoadView(NULL) if the first thing I'm going to do is disable interrupts and load my own copperlist?
Last edited by deimos; 03 October 2019 at 13:42. |
03 October 2019, 14:53 | #6 |
Defendit numerus
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,476
|
|
03 October 2019, 16:25 | #7 |
WinUAE developer
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,522
|
Yeah, without LoadView(NULL) RTG mode stays active, unless you have separate monitor connected to Amiga's built-in video out. And even if you have separate monitor, native refresh rate may not be standard PAL or NTSC without LoadView(NULL).
Something like this should be safe: Forbid() (so that no other task can change graphics modes etc before interrupts get disabled) loadview/waittof stuff OwnBlitter() WaitBlitter() Disable interrupts the rest Enable interrupts DisownBlitter() loadview back to original Permit() |
03 October 2019, 18:02 | #8 | |
Defendit numerus
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,476
|
Quote:
What are the possible contraindications to use this?: Forbid() loadview / waittof stuff Disable interrupts myWaitBlitter() Yes, it's a simple call that certainly doesn't hurt, it's just curiosity EDIT: hmm, perhaps the answer is simple, another process that has a blitter-chain that absolutely cannot be interrupted, under penalty of data corruption the partial results are always valid, unless we refer to pre-set and shared registers between operations Last edited by ross; 03 October 2019 at 19:16. |
|
03 October 2019, 19:22 | #9 |
Registered User
Join Date: Oct 2008
Location: EU
Posts: 163
|
The CD32 Developer Notes (pdf at kaiiv.de) have hints on what to use when and why e.g. Q4 page 91 "Which of the following ... can we safely take over and hit directly?"
|
03 October 2019, 20:40 | #10 |
ex. demoscener "Bigmama"
Join Date: Jun 2012
Location: Fyn / Denmark
Posts: 1,624
|
|
04 October 2019, 14:04 | #11 |
Registered User
Join Date: Feb 2007
Location: Melbourne, Australia
Age: 41
Posts: 3,773
|
|
04 October 2019, 22:25 | #12 |
Moderator
Join Date: Nov 2004
Location: Eksjö / Sweden
Posts: 5,611
|
Here's mine - it's divided into a wrapper and a startup. The wrapper is what turns off and on the OS and the startup starts a template screen once you've take over that you can flesh out and customize as you want - I used to have it as one file, but the reason for the separation into two files is this customization.
So you only need translate the wrapper. It returns to RTG on exit. It has a few hardcoded offsets to not immediately require dependencies. -222 is LoadView(), -408 is OldOpenLib(), and offset 297 in Exec is to check for 68000, to detect VBR safely. Last edited by Photon; 31 January 2020 at 20:10. |
05 October 2019, 09:13 | #13 | |
It's coming back!
Join Date: Jul 2018
Location: comp.sys.amiga
Posts: 762
|
Quote:
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
non-system startup code time/clock problem | modrobert | Coders. Asm / Hardware | 89 | 14 December 2018 15:37 |
AROS startup code | patrik | Coders. Nextgen | 5 | 30 April 2017 21:13 |
startup/system takeover | sidewinder | Coders. General | 15 | 28 February 2016 16:33 |
Startup Code (from Icon ) - Forbid function | Asman | Coders. System | 2 | 04 January 2014 10:45 |
Taking over the system... | lpopman | Coders. General | 5 | 03 December 2004 01:52 |
|
|