21 May 2024, 23:06 | #1 |
Registered User
Join Date: Apr 2017
Location: Germany
Posts: 31
|
RTG screen with NDrawing, no Circlef
Hi.
Since the standard `Screen` command can't open an RTG screen I used `NScreen`. This opens a new RTG screen just fine. But I'd need to draw filled ellipses/circles in a window but there is no equivalent to Circlef, there is just NCircle. I was trying to use the OS function `AreaEllipse_` followed by `AreaEnd_` because NWindow allows to retrieve a rastport. But calling AreaEllipse_ immediate crashes the system. Is there some other way to draw filled ellipses and have the 'high-level' abstraction of Basic (otherwise I could use just C or AmigaE)? Cheers |
22 May 2024, 08:47 | #2 |
Registered User
Join Date: Jan 2002
Location: Germany
Posts: 7,050
|
In order to use the Area... functions of graphics. library you have to allocate a TmpRas with enough Chip memory and an AreaInfo with enough entries and link them to the RastPort. I have no idea how to do this in Basic.
|
22 May 2024, 09:50 | #3 |
Registered User
Join Date: Apr 2017
Location: Germany
Posts: 31
|
Yeah, I was thinking that this probably doesn't work out of the box.
But I'd rather not do this, even if maybe possible in BB. I'd much more like to use the original 2D drawing functions (Circlef, etc.) but I'm not sure how this could be possible on an RTG screen. |
22 May 2024, 10:41 | #4 |
Registered User
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,416
|
AmiBlitz 3 lets the standard Screen command open an RTG screen, but the CircleF command uses the Amiga chipset directly, so it still won't work.
I've never done it myself, but it is possible to allocate chip RAM and an AreaInfo struct in Blitz, pretty much as you would in C. Whether it's still worth using Basic depends on the rest of your code at that point. I've put together this working example of opening an RTG screen and using AreaEllipse based on the example code from the Autodocs. Note that I haven't calculated the sizes of the buffers at all, so you'd need to work that out based on your requirements. Code:
WBStartup areasize.w = 200 Dim areabuffer.w(areasize) ; Using this dummy array to allocate memory on a word boundary. Alternatively use allocmem with size+1 and adjust pointer if needed DEFTYPE .AreaInfo areainfo DEFTYPE .TmpRas tmpras InitArea_ &areainfo, &areabuffer(0), (areasize * 2) / 5 tmparea.l = AllocMem(areasize * 2, #MEMF_CHIP) ; Allocate the TmpRas area in chip RAM If tmparea = 0 NPrint "Unable to allocate RAM" End End If InitTmpRas_ tmpras, tmparea, areasize * 2 ; set up the TmpRas area *myscreen.Screen = Screen(0, 0, 44, 640, 512, 24, $8000|4, "Test", 1, 2) *myrp.RastPort = *myscreen\RastPort ; Get the rp address from the screen *myrp\AreaInfo = &areainfo *myrp\FgPen = 4 ; set the pen to use AreaEllipse_ *myrp, 100, 100, 50, 50 AreaEnd_ *myrp Repeat VWait Until Joyb(0) FreeMem tmparea, areasize * 2 End Last edited by Daedalus; 22 May 2024 at 15:27. Reason: Fixed minor error in code |
22 May 2024, 11:05 | #5 |
Registered User
Join Date: Apr 2017
Location: Germany
Posts: 31
|
Cool, thanks for that. I hadn't been able to do that myself. The syntax is still a bit alien to me.
I think at some point I had a working example with copying a bitmap, not sure if that was what you mentioned. But that seemed a bit slow. But I'm wondering, since you mentioned chip RAM. An RTG screen (windows, etc.) doesn't live in chip RAM, or? Why is it necessary to allocate memory in chip RAM? |
22 May 2024, 11:32 | #6 |
Registered User
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,416
|
Yeah, that's a fair point. The Autodocs specify that it should be in chip RAM. It might work on RTG screens if allocated in fast RAM, but I suspect it won't on an RTG-less system. A chip RAM buffer will work in either case (but might slow down the RTG draw operation), or you can detect whether the screen is RTG or not and allocate separately depending.
|
22 May 2024, 14:28 | #7 |
Registered User
Join Date: Dec 2017
Location: Poland
Age: 48
Posts: 284
|
..or ...
if you already started using all the commands ending with "_" then you will have to continue that way. Below I put together 4 screenshots (4 steps) what you need and when to make AreaDraw (and simmilar) work. (pic 2 and pic 3 - outlined with red lines) 1. upon starting your program you need to declare some things - pic 1 2. after opening your screen (ar using WB) - pic 2 3. when you made your own window you REALLY have to assign these to its structure - otherwise guru... pic 3 4. just a drawing procedure 5. there is not any picture for that (forgot to make) but you should use FreeMem_ on *tmpbuf upon exit. Hope it helps edit Ahh!! that was about RTG screen... sorry cannot help here but at least these pictures may halp you start with AreaDrow_, AreaEllipse_ the "system commands way" Last edited by peceha; 22 May 2024 at 14:38. |
22 May 2024, 15:27 | #8 |
Registered User
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,416
|
Many Blitz commands can be mixed with OS functions (ending in _ ), so long as they deal with rastport pointers, such as the NScreen, NCircle commands. That said, my example uses the OS functions just as this one does.
Also, unlike C, Blitz will initialise standard variables and structs to 0 so you don't have to. |
22 May 2024, 18:59 | #9 |
Registered User
Join Date: Dec 2017
Location: Poland
Age: 48
Posts: 284
|
Thanks Daedalus, good to know
|
23 May 2024, 00:11 | #10 |
Registered User
Join Date: Apr 2017
Location: Germany
Posts: 31
|
Cool, this worked.
|
23 May 2024, 16:36 | #11 |
Registered User
Join Date: Apr 2017
Location: Germany
Posts: 31
|
I've got a few questions to this code if I may:
- the vmode in the `Screen` definition is `$8000 | 4`. I found that $8000 is hires and 4 is interlaced. But there is no mention of RTG screen. Is this the way to open an RTG screen with `Screen`command? - the `*myscreen.Screen = ...` I assume is a variable (pointer) declaration and assignment in one. Could the same be written as: ``` DEFTYPE .Screen * myscreen *myscreen = Screen... ``` ? Cheers |
25 May 2024, 10:05 | #12 |
Registered User
Join Date: Apr 2017
Location: Germany
Posts: 31
|
I've realized that the TmpRas structure variable is actually not used at all.
So also the InitTmpRas call can be removed and things still work. |
25 May 2024, 21:14 | #13 |
Registered User
Join Date: Jan 2019
Location: Germany
Posts: 3,498
|
The screen type is actually a mode ID coming from the display info data base. These mode IDs are different on every installation since users use different graphics cards. Instead of requiring a specific mode ID, it is better to show an ASL screen mode requester and let the user pick a mode, or to open the screen in the same mode as the workbench, or a window on the workbench.
Concerning the TmpRas: Well, on native systems with native graphics, the TmpRas *is* actually used, so please provide one. For P96, the TmpRas is actually not used because it is in ChipRAM and thus it is only slow. However, that does not mean that you should not allocate one. If P96 is not installed, the TmpRas will be needed. |
29 May 2024, 21:15 | #14 | ||
Registered User
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,416
|
Quote:
You can specify RTG modes by setting the depth to 9 (for an 8-bit RTG mode), 16 or 24 (for 16 or 24-bit modes). Quote:
|
||
30 May 2024, 23:48 | #15 |
Registered User
Join Date: Apr 2017
Location: Germany
Posts: 31
|
Thanks for the information.
I still really can't make sense of the required memory size for AreaInfo and TmpRas. There is a 'maxvectors' multiplied by 5 in some of the RKRM examples. And for AreaEllipse there is a comment that it will required double the vectors (or something like this). So basically it's fully unclear how much memory should be allocated, or what size be passed to the functions. I just was to draw a filled ellipse. Cheers |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Overlay filter with RTG screen | Seiya | support.WinUAE | 2 | 31 January 2024 21:01 |
RTG screen size - no overscan | Angus | Retrogaming General Discussion | 9 | 01 November 2023 22:48 |
RTG and Native screen both visible | tomcat666 | support.WinUAE | 3 | 01 September 2021 10:30 |
RTG screen dragging? | zevs | support.WinUAE | 12 | 29 June 2020 01:24 |
AmigaOS 4.1FE RTG screen gets trashed | FlynnTheAvatar | support.WinUAE | 16 | 06 February 2018 20:20 |
|
|