English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Language > Coders. Blitz Basic

 
 
Thread Tools
Old 21 May 2024, 23:06   #1
asrael
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
asrael is offline  
Old 22 May 2024, 08:47   #2
thomas
Registered User
 
thomas's Avatar
 
Join Date: Jan 2002
Location: Germany
Posts: 7,020
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.
thomas is online now  
Old 22 May 2024, 09:50   #3
asrael
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.
asrael is offline  
Old 22 May 2024, 10:41   #4
Daedalus
Registered User
 
Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,374
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
Edit: An alternative workaround that is clunky but might keep it more "basic" might be to create a bitmap in chip RAM, draw the ellipse there, cut a shape from the bitmap and blit it to the rastport. Blitz provides a system-friendly Blit command for windows, but not screens, so you would still need to use the OS for the blit, or else open a backdrop window on the screen and draw to it instead.

Last edited by Daedalus; 22 May 2024 at 15:27. Reason: Fixed minor error in code
Daedalus is offline  
Old 22 May 2024, 11:05   #5
asrael
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?
asrael is offline  
Old 22 May 2024, 11:32   #6
Daedalus
Registered User
 
Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,374
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.
Daedalus is offline  
Old 22 May 2024, 14:28   #7
peceha
Registered User
 
peceha's Avatar
 
Join Date: Dec 2017
Location: Poland
Age: 47
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.
peceha is offline  
Old 22 May 2024, 15:27   #8
Daedalus
Registered User
 
Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,374
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.
Daedalus is offline  
Old 22 May 2024, 18:59   #9
peceha
Registered User
 
peceha's Avatar
 
Join Date: Dec 2017
Location: Poland
Age: 47
Posts: 284
Thanks Daedalus, good to know
peceha is offline  
Old 23 May 2024, 00:11   #10
asrael
Registered User
 
Join Date: Apr 2017
Location: Germany
Posts: 31
Quote:
Originally Posted by Daedalus View Post
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.
Cool, this worked.
asrael is offline  
Old 23 May 2024, 16:36   #11
asrael
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
asrael is offline  
Old 25 May 2024, 10:05   #12
asrael
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.
asrael is offline  
Old 25 May 2024, 21:14   #13
Thomas Richter
Registered User
 
Join Date: Jan 2019
Location: Germany
Posts: 3,277
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.
Thomas Richter is offline  
Old 29 May 2024, 21:15   #14
Daedalus
Registered User
 
Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,374
Quote:
Originally Posted by asrael View Post
- 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?
Yep, those flags are correct. There are a few different ways to open a screen in Blitz, and the Screen command is just one of them. It was extended to support RTG in AmiBlitz 3 and it does this without requiring a screenmode ID. Instead, it will try to open an RTG screen when you request greater than 8 bitplanes, and it will use BestModeID or similar internally to get a screenmode that best matches your requirements.

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:
- 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...
```
Yep, that's correct Just be careful not to use the *myscreen variable before assigning it in the second method.
Daedalus is offline  
Old 30 May 2024, 23:48   #15
asrael
Registered User
 
Join Date: Apr 2017
Location: Germany
Posts: 31
Quote:
Originally Posted by Thomas Richter View Post
The screen type is actually...
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
asrael 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
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

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 14:18.

Top

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