English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Asm / Hardware

 
 
Thread Tools
Old 19 April 2024, 12:40   #1
KONEY
OctaMED Music Composer
 
KONEY's Avatar
 
Join Date: Jan 2009
Location: Venice - Italy
Age: 49
Posts: 667
Question Hardcode bitplane pointers in copperlist?

So far I've only seen bitmap pointers poked into copperlist by the CPU, but is there a way to hardcode them directly from source code? Is there a syntax for this?

Thanks!
KONEY is offline  
Old 19 April 2024, 12:58   #2
Skyhawk
Registered User
 
Join Date: Feb 2022
Location: Sao Paulo
Posts: 2
Read this: http://amigadev.elowar.com/read/ADCD.../node0011.html
Skyhawk is offline  
Old 19 April 2024, 12:59   #3
DJ Mike
Registered User
 
Join Date: Nov 2005
Location: United Kingdom
Age: 40
Posts: 100
Are you banging the hardware directly or using OS calls?

Copperlist has to reside in chip memory, so at some point the CPU has to move it there, whether that's your program building (poking) it into memory at runtime, or it being loaded along with your code. It might be helpful to know what you're trying to achieve?
DJ Mike is offline  
Old 19 April 2024, 13:06   #4
a/b
Registered User
 
Join Date: Jun 2016
Location: europe
Posts: 1,039
Yeah, if you are using absolute addresses (AllocAbs() or ORG/LOAD). Otherwise (AllocMem() or relative sections) you don't know where the bitmap will be in memory during compile time, and since the segment loader cannot handle splitting a 32-bit address into 2 parts you have to do it manually with the CPU in run-time (which is what you want to avoid).
For example:
Code:
ABS_BITMAP EQU $70000

; version1
  SECTION Code,CODE
  move.l 4.w,a6
  move.l #(320/8)*256,d0
  lea ABS_BITMAP,a1
  jsr _LVOAllocAbs(a6)  ; +handle error

; version2
; absolute section, will not be added to executable as a hunk (ok for OS-killer demos/games and similar)!!
  ORG ABS_BITMAP
  LOAD ABS_BITMAP
  DS.B (320/8)*256

; now you can hardcode it in copperlist
  SECTION DataChip,CHIP
Copper:
  DC.W $00e0,ABS_BITMAP>>16,$00e2,ABS_BITMAP&$ffff
...
a/b is online now  
Old 19 April 2024, 14:01   #5
KONEY
OctaMED Music Composer
 
KONEY's Avatar
 
Join Date: Jan 2009
Location: Venice - Italy
Age: 49
Posts: 667
Thanks a/b! I think version 2 is what I was looking for!

In short, what I need to do is use ORG + LOAD in place of a label then on the copper use it to deal with low and hi words, as per example.

May I ask why the second word is padded with ones? (&$ffff)? Or is it ANDed?

Also, do you know any documentation of these assembler tricks?
KONEY is offline  
Old 19 April 2024, 14:51   #6
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,500
Quote:
Originally Posted by KONEY View Post
I think version 2 is what I was looking for!
Depends on the rest of your project. Is it all absolute code?

Quote:
In short, what I need to do is use ORG + LOAD
org
should suffice. AFAIK
load
is only required for AsmOne-family assemblers to load the assembled code to that address in memory - at the time of assembly! May be useful for testing on real machines, but I would avoid that source code.

Quote:
in place of a label
You still need a label. But the label will be absolute after ORG.

Quote:
May I ask why the second word is padded with ones? (&$ffff)?
You want to make sure that only the least significant 16 bits of the address are stored. Some assemblers would otherwise warn, because the value doesn't fit into a word (
dc.w
).
phx is offline  
Old 19 April 2024, 15:48   #7
a/b
Registered User
 
Join Date: Jun 2016
Location: europe
Posts: 1,039
Phx got most of it covered, so just a few extra notes...

Yeah, you could add a label after ORG/LOAD, it's what I typically do when I have multiple data sets at some abs address (so each data gets a label).
In principle, you don't even need ORG/LOAD and DS.B. EQU at the start to define a symbol (so you don't have to hardcode it all over the place) is all you need, but you'd have to keep a mental note what it at that particular address, how much space does it take, etc.
It's ugly enough as is and without it it's worse, and basically don't recommend doing it unless you are killing the OS and the only way to exit is a reset.

&$ffff removes the upper word, reason explained above.
a/b is online now  
Old 19 April 2024, 17:44   #8
KONEY
OctaMED Music Composer
 
KONEY's Avatar
 
Join Date: Jan 2009
Location: Venice - Italy
Age: 49
Posts: 667
UHhhm ok... now I'm getting a bit confused

PHP Code:
ABS_BITMAP EQU $70000 
is all I need but how do I figure out the value $70000? Isn't the value figured out during build?
PHP Code:
DS.(320/8)*256 
reserves enough bytes to hold a bitplane, why shouldn't I need it? In fact, I was going to change it into an incbin of a file, in my plans...
KONEY is offline  
Old 19 April 2024, 17:52   #9
KONEY
OctaMED Music Composer
 
KONEY's Avatar
 
Join Date: Jan 2009
Location: Venice - Italy
Age: 49
Posts: 667
Quote:
Originally Posted by phx View Post
Depends on the rest of your project. Is it all absolute code?
if with absolute you mean that I know the addresses then no, I don't think so.

So to speak, this is a tipical code I would produce: https://github.com/KONEY/rusteater_a...STEATER_MAIN.s

Basically what I'm trying to do is get rid of these lines:
PHP Code:
    LEA    BGNOISE0,A0
    LEA    COPPER
\.BplPtrs,A1
    BSR
.W    PokePtrs 
and pre-populate the copperlist with the hi and lo words from the address which will be at label BGNOISE:
KONEY is offline  
Old 19 April 2024, 18:09   #10
jotd
This cat is no more
 
jotd's Avatar
 
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,196
it's a lot of constraints for which result? just set them at initialization time and that's it. Else you have to know exactly the value.
jotd is offline  
Old 19 April 2024, 18:10   #11
a/b
Registered User
 
Join Date: Jun 2016
Location: europe
Posts: 1,039
If your bitmap is in a relocatable section (e.g. SECTION xyz,DATA_C) you cannot take a shortcut. You have to set the bitmap pointers in copperlist manually with CPU because you don't know at what address will bitmap be when your program is executed, and you are trying to split that address in two halves (not supported).
You can do that only when the bitmap address is known at compile/assemble time (and that requires absolute address).
There is a similar thread (different problem, but the same reason why not) which should explain the program loader's limitations in regard to address manupulation in more detail: https://eab.abime.net/showthread.php?t=117217
a/b is online now  
Old 19 April 2024, 18:24   #12
KONEY
OctaMED Music Composer
 
KONEY's Avatar
 
Join Date: Jan 2009
Location: Venice - Italy
Age: 49
Posts: 667
I see, thanks.
KONEY is offline  
Old 19 April 2024, 18:30   #13
KONEY
OctaMED Music Composer
 
KONEY's Avatar
 
Join Date: Jan 2009
Location: Venice - Italy
Age: 49
Posts: 667
Result in my mind is to split the screen in 32 waits and point 32 different EHB planes in each one of them. And all this would be generated by an ARexx script running from PPaint, adding palettes and includes etc. Therefore getting rid of some code would have been quite helpful, at least while testing if all could work the way I plan

Quote:
Originally Posted by jotd View Post
it's a lot of constraints for which result? just set them at initialization time and that's it. Else you have to know exactly the value.
KONEY is offline  
Old 19 April 2024, 18:31   #14
Photon
Moderator
 
Photon's Avatar
 
Join Date: Nov 2004
Location: Eksjö / Sweden
Posts: 5,604
List of pros and cons:
A generic PokePtrs routines is easy to write and can be used for sprite, audio, etc pointers as well. That is, if you set them with the Copper. If you set your pointers in your mainloop sync or in the VBI, you can just... set them

However you do it, this is the dynamic way.

As for absolute addressing, it was the fastest way to assemble and run on a dedicated dev A500. It can still be used for this, or if the result is intended to be run from trackdisk, in which case it might be very difficult to LoadSeg() with full compatibility plus have enough memory left if you don't turn the OS off/overwrite Exec.

It's useful if you reuse memory a lot (e.g. a multi-part, trackloaded demo or game) and want to actually reuse it under your control, as opposed to pretending "buy more RAM" is always true and adding sometimes ridiculous memory demands onto your program (or hog a clump and roll your own allocation a la C).

IOW, use it wisely and it saves you time (and some boring cross-SECTION references handling), OTOH, if it will not be track-loaded, let the OS handle memory. The latter is good practice, if you use absolute addressing, just know what you're doing.

And finally, if the Copper list and screen buffer are in the same (Chip) SECTION, you can have the Assembler poke it for you at assembly time, as a/b shows. If you get errors, just put parentheses around and limit each calculation to 16-bit (&$ffff).
Photon is offline  
Old 19 April 2024, 19:06   #15
KONEY
OctaMED Music Composer
 
KONEY's Avatar
 
Join Date: Jan 2009
Location: Venice - Italy
Age: 49
Posts: 667
Quote:
Originally Posted by Photon View Post
List of pros and cons:
And finally, if the Copper list and screen buffer are in the same (Chip) SECTION, you can have the Assembler poke it for you at assembly time, as a/b shows. If you get errors, just put parentheses around and limit each calculation to 16-bit (&$ffff).

Thanks Photon! Copperlist and buffer are in same SECTION so I'm trying this suggestion. But any combination of parentheses and limits leads to an "illegal relocation" error, at least with Vasm. Am I missing something?



Tried all these:

Code:
    SECTION    ChipData,DATA_C


COPPER:


    DC.W $E0,(COPPER)&$ffff
    DC.W $E0,(COPPER&$ffff)

    DC.W $E0,(COPPER>>16&$ffff)
    DC.W $E0,(COPPER>>16)&$ffff
    DC.W $E0,COPPER&$ffff
    DC.W $E0,COPPER>>16
    DC.W $E0,COPPER>>16&$ffff
KONEY is offline  
Old 19 April 2024, 21:03   #16
jotd
This cat is no more
 
jotd's Avatar
 
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,196
as said earlier, amiga executable format can't handle half-relocations like this

.elf format can do this (because powerpc needs that to load half-instructions) but hunk exe format can't.
jotd 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
Changing Bitplane Pointers Mid-Scanline Rob68K Coders. Asm / Hardware 9 11 April 2024 02:13
Can you use 1 bitplane anims to modify 6th bitplane only ImmortalA1000 Coders. Blitz Basic 0 18 December 2021 11:55
Copperlist crash? TCH Coders. C/C++ 23 22 February 2021 20:52
When is the modulo added to the bitplane pointers? DanScott Coders. Asm / Hardware 3 07 March 2016 18:24
Modifying a copperlist CmdrVimes Coders. General 5 06 September 2010 12:08

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 04:13.

Top

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