18 February 2021, 23:17 | #1 |
Newbie Amiga programmer
Join Date: Jun 2012
Location: Front of my A500+
Age: 38
Posts: 372
|
Copperlist crash?
I have a small Copperlist here:
Code:
UWORD copperlist[22] = { 0x4401, 0xfffe, 0x0188, 0x0000, 0x018a, 0x0010, 0x018c, 0x0020, 0x018e, 0x0030, 0x4801, 0xfffe, 0x0188, 0x0040, 0x018a, 0x0050, 0x018c, 0x0060, 0x018e, 0x0070, 0xffff, 0xfffe }; Code:
*((ULONG *)0xdff080) = (ULONG)(&copperlist); Code:
*((UWORD *)0xdff080) = ((ULONG)(&copperlist)) >> 15; *((UWORD *)0xdff082) = ((ULONG)(&copperlist)) & 0x7fff; Any ideas are appreciated. |
18 February 2021, 23:29 | #2 |
Registered User
Join Date: Jul 2015
Location: The Netherlands
Posts: 3,438
|
The first question would be whether or not the OS is still running at this point. If it's up, changing the Copperlist pointer will probably not work (though it normally doesn't crash the system). The second question is whether or not the Copperlist is actually situated in Chip RAM or not as I can't tell from the source code you've provided. The third one is whether or not you're showing GFX that actually use colours 4-7.
The last question I'd have right now is how you're updating the bitplane pointers. With the CPU? These need to be updated every frame and your Copperlist doesn't seem to do this. |
18 February 2021, 23:38 | #3 |
This cat is no more
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,386
|
it probably doesn't crash, but display is completely broken so you can't do anything besides rebooting
|
18 February 2021, 23:48 | #4 | ||||
Newbie Amiga programmer
Join Date: Jun 2012
Location: Front of my A500+
Age: 38
Posts: 372
|
Quote:
Quote:
Quote:
Quote:
OpenScreen()and wrote the data to screen->RastPort.BitMap->Planes.You mean, it killed the sprites and the WB screen too? Last edited by TCH; 18 February 2021 at 23:50. Reason: posted above me |
||||
19 February 2021, 00:01 | #5 | |||
Registered User
Join Date: Jul 2015
Location: The Netherlands
Posts: 3,438
|
Quote:
Quote:
Quote:
It occurs to me that the black screen may also be caused by other display registers not being set up correctly when you use your own Copperlist. I'd guess the OS doesn't reset stuff like the BPLCON registers, but I can't be sure. Again, mixing the OS and directly accessing the hardware is a pretty good cause for issues and problems. |
|||
19 February 2021, 00:07 | #6 |
Newbie Amiga programmer
Join Date: Jun 2012
Location: Front of my A500+
Age: 38
Posts: 372
|
I had no idea that i can do Copperlists in a system-friendly way, thanks for pointing out. I have to check out how to do that. Back to the manuals...
|
19 February 2021, 08:29 | #7 |
Zone Friend
Join Date: Mar 2004
Location: Middle Earth
Age: 40
Posts: 2,130
|
http://aminet.net/search?query=rkmcompanionIs an official demo by Commodore for Kick 1.3 how to create a custom copper list in C.
There is also one for OS 2 in the later RKM companions that are also on aminet. If you look for Fred Fish disk 58 there is a Marauder II (Copy program) style example copper list program called Rainbow with source by John Hodges. Hope that helps |
19 February 2021, 09:34 | #8 |
Registered User
Join Date: Dec 2019
Location: Newcastle
Posts: 67
|
Drop your reference, copperlist is already a pointer. So you are writing a pointer to your pointer into the custom chip
|
19 February 2021, 11:26 | #9 |
Newbie Amiga programmer
Join Date: Jun 2012
Location: Front of my A500+
Age: 38
Posts: 372
|
@redblade:
Thanks for the tip, i found it in uCopperExample.c. @DMWCashy: Damn, you are right. What an amateur mistake. To my excuse, it was late night. Thanks for pointing out. (Of course still crashes, because what roondar said, but nevertheless, it was an unnecessary referencing.) |
19 February 2021, 13:36 | #10 |
Newbie Amiga programmer
Join Date: Jun 2012
Location: Front of my A500+
Age: 38
Posts: 372
|
|
19 February 2021, 13:50 | #11 |
Newbie Amiga programmer
Join Date: Jun 2012
Location: Front of my A500+
Age: 38
Posts: 372
|
In
uCopperExample.cthere is the part where the Copperlist is generated: Code:
#define NUMCOLORS 32 ... CINIT(uCopList, NUMCOLORS); /* Initialize the Copper list buffer. */ for (i=0; i<NUMCOLORS; i++) /* Load in each color. */ { CWAIT(uCopList, (i*NUMLINES_EACH), 0); CMOVE(uCopList, custom.color[0], colors[i]); } CEND(uCopList); /* End the Copper list */ CINIT()says, that Code:
cl = CINIT( ucl , n ) ... n - number of instructions buffer must be able to hold uCopperExample.cthe allocation only allocate 32 entries ( NUMCOLORS, the number of colour changes), while it will have 64 instructions (one WAITand one MOVEinstruction per colour change), plus the terminating command, so it should be 65, right? Is it a bug in the example program and it was just sheer luck that it did not crashed after putting 65 instructions into a 32 instruction sized buffer, or did i interpreted the manual wrongly? |
19 February 2021, 14:06 | #12 |
Registered User
Join Date: Jul 2015
Location: The Netherlands
Posts: 3,438
|
TBH, that feels like pure luck to me. Amiga OS does not have memory protection, so if your code writes outside of it's allocated bounds no errors are thrown. Well, unless you happen to overwrite something critical. Then the system tends to just crash
|
19 February 2021, 14:20 | #13 | |
Registered User
Join Date: Dec 2019
Location: Newcastle
Posts: 67
|
Quote:
Any C/C++ coder that says they do not make such errors are just liars, when you are hammering away it is easy to do this, C is so versatile that it makes compile time validation weak. Last edited by DMWCashy; 19 February 2021 at 14:31. |
|
19 February 2021, 14:55 | #14 | |
Newbie Amiga programmer
Join Date: Jun 2012
Location: Front of my A500+
Age: 38
Posts: 372
|
Quote:
uCopperExample.c. BTW, the program works on KickStart 2.0+ and AGA machines too. Do creating a Copperlist in a system-friendly way has different mechanisms above KS2.0?Ain't the truth... But that comes from it's flexibility, so it's something for something. Any powerful tool can be dangerous. Sometimes even in adept hands. |
|
19 February 2021, 15:57 | #15 |
Registered User
Join Date: Aug 2018
Location: Untergrund/Germany
Posts: 410
|
Depending on compiler and optimizer options your code may still break, as your hardware register writes are not declared as volatile:
*((UWORD *)0xdff080) -> *((volatile UWORD *)0xdff080) |
19 February 2021, 16:52 | #16 |
Newbie Amiga programmer
Join Date: Jun 2012
Location: Front of my A500+
Age: 38
Posts: 372
|
That is good to know, thank you.
|
19 February 2021, 20:19 | #17 | |
Registered User
Join Date: Jan 2019
Location: Germany
Posts: 3,331
|
Quote:
|
|
19 February 2021, 20:48 | #18 |
Newbie Amiga programmer
Join Date: Jun 2012
Location: Front of my A500+
Age: 38
Posts: 372
|
Then why does it need to be initialized with the theoretical number of Copper instructions?
|
19 February 2021, 23:13 | #19 | |
Zone Friend
Join Date: Mar 2004
Location: Middle Earth
Age: 40
Posts: 2,130
|
Quote:
Also the later RKM examples for OS 2+ modify the UCopperList to open up on a custom screen, code is 90% identical tho. Glad the battery didn't destroy your 500+ |
|
20 February 2021, 01:22 | #20 |
Registered User
Join Date: Jul 2015
Location: The Netherlands
Posts: 3,438
|
Huh, I didn't even realize the graphics library Copper structure worked like that. That's actually quite nice. There's lots of nice things like that in the OS. Not bad for a system from 30 years ago
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Copperlist explanation | Clydos | Coders. General | 37 | 06 July 2023 20:56 |
Advice on copperlist for borders | MrD | Coders. General | 3 | 03 March 2012 07:25 |
Modifying a copperlist | CmdrVimes | Coders. General | 5 | 06 September 2010 12:08 |
Setting up a copperlist | oRBIT | Coders. General | 5 | 08 April 2010 14:18 |
Error in copperlist? | Nyarlathotep | support.WinUAE | 7 | 12 August 2003 23:44 |
|
|