English Amiga Board


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

 
 
Thread Tools
Old 04 February 2018, 18:52   #1
Tigerskunk
Inviyya Dude!
 
Tigerskunk's Avatar
 
Join Date: Sep 2016
Location: Amiga Island
Posts: 2,770
Easy way to handle MSB and LSB in SPRxCTL?

This is kind of driving me nuts at the moment.
Currently trying to shift around these bits, but I kind of don't get it right.

So, is there some tried and working way of setting the sprites VSTART, VSTOP MSBs and HSTART LSBs?
Tigerskunk is offline  
Old 04 February 2018, 19:18   #2
ross
Defendit numerus
 
ross's Avatar
 
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,468
Quote:
Originally Posted by Steril707 View Post
This is kind of driving me nuts at the moment.
Currently trying to shift around these bits, but I kind of don't get it right.

So, is there some tried and working way of setting the sprites VSTART, VSTOP MSBs and HSTART LSBs?
Code:
    lea spritelist,a0
    move.w  #x,d0
    move.w  #y,d1
    moveq   #h,d2
;    moveq   #-1,d3  ;attach
    
    move.w	d1,d6
    move.w	d1,d7
    ror.w	#8,d6
    add.w	d2,d7
    roxl.w	#8,d7
    addx.b	d6,d6
    move.w	d0,d5
    lsr.w	#1,d5
    addx.b	d6,d6
;    or.b	d3,d6
    move.b      d6,d7
    move.b      d5,d6
    move.w	d6,(a0)+
    move.w	d7,(a0)+
[EDIT1] I assumed you need an OCS solution, for AGA I use LUT.
[EDIT2] in my routines I need x,y and h to remain consistent, so the move to other registers,
you can rearrange the code if this property is not needed
[EDIT3] rol.w #8 -> ror.w #8

Last edited by ross; 05 February 2018 at 19:29. Reason: changed rol.w #8 to ror.w #8 because I need to ror&rol!
ross is offline  
Old 04 February 2018, 21:47   #3
a/b
Registered User
 
Join Date: Jun 2016
Location: europe
Posts: 1,039
I'm using two tables with precalculated sprite x/y (32 bits), so the code looks something like:
Code:
; a0=tablex, a1=tabley, d0=spritex, d1=spritey
 add.w d0,d0
 add.w d0,d0
 move.l (a0,d0.w),d0
 add.w d1,d1
 add.w d1,d1
 or.l (a1,d1.w),d0
; or.b #$80,d0 ; attached
a/b is online now  
Old 04 February 2018, 22:00   #4
ross
Defendit numerus
 
ross's Avatar
 
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,468
Quote:
Originally Posted by a/b View Post
I'm using two tables with precalculated sprite x/y (32 bits), so the code looks something like:
Code:
; a0=tablex, a1=tabley, d0=spritex, d1=spritey
 add.w d0,d0
 add.w d0,d0
 move.l (a0,d0.w),d0
 add.w d1,d1
 add.w d1,d1
 or.l (a1,d1.w),d0
; or.b #$80,d0 ; attached
Hi a/b, so you use n tables for the variable h value.
But the final single move.l d0,spritelist is nice.
I use something similar for AGA quarter pixels.
ross is offline  
Old 05 February 2018, 18:11   #5
dissident
Registered User
 
Join Date: Sep 2015
Location: Germany
Posts: 256
Quote:
Originally Posted by ross View Post
Code:
    lea spritelist,a0
    move.w  #x,d0
    move.w  #y,d1
    moveq   #h,d2
;    moveq   #-1,d3  ;attach
    
    move.w    d1,d6
    move.w    d1,d7
    ror.w    #8,d6
    add.w    d2,d7
    roxl.w    #8,d7
    addx.b    d6,d6
    move.w    d0,d5
    lsr.w    #1,d5
    addx.b    d6,d6
;    or.b    d3,d6
    move.b      d6,d7
    move.b      d5,d6
    move.w    d6,(a0)+
    move.w    d7,(a0)+
[EDIT1] I assumed you need an OCS solution, for AGA I use LUT.
[EDIT2] in my routines I need x,y and h to remain consistent, so the move to other registers,
you can rearrange the code if this property is not needed
[EDIT3] rol.w #8 -> ror.w #8
Hi Steril707,

just to make things clearer for you, which bits should be shifted to which positions, try this optimized OCS-version based on ross' routine:

Code:
;D0=xpos
;D1=ypos
;D3=height
;A0=sprite-structure

MOVE.W  D1,D2    ;Save ypos
ROL.W   #8,D1    ;SV7 SV6 SV5 SV4 SV3 SV2 SV1 SV0 --- --- --- --- --- --- --- SV8
ADD.W   D3,D2    ;Add sprite height
LSL.W   #8,D2    ;EV7 EV6 EV5 EV4 EV3 EV2 EV1 EV0 --- --- --- --- --- --- --- ---
ADDX.B  D1,D1    ;SV7 SV6 SV5 SV4 SV3 SV2 SV1 SV0 --- --- --- --- --- --- SV8 EV8
LSR.W   #1,D0    ;--- --- --- --- --- --- --- --- SH8 SH7 SH6 SH5 SH4 SH3 SH2 SH1
ADDX.B  D1,D1    ;SV7 SV6 SV5 SV4 SV3 SV2 SV1 SV0 --- --- --- --- --- SV8 EV8 SH0
MOVE.B  D1,D2    ;EV7 EV6 EV5 EV4 EV3 EV2 EV1 EV0 --- --- --- --- --- SV8 EV8 SH0
MOVE.B  D0,D1    ;SV7 SV6 SV5 SV4 SV3 SV2 SV1 SV0 SH8 SH7 SH6 SH5 SH4 SH3 SH2 SH1
MOVE.W  D1,(A0)+ ;SPRxPOS
;TAS     D2       ;ATT-bit
MOVE.W  D2,(A0)+ ;SPRxCTL

Last edited by dissident; 05 February 2018 at 20:39.
dissident is offline  
Old 05 February 2018, 18:54   #6
ross
Defendit numerus
 
ross's Avatar
 
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,468
Quote:
Originally Posted by dissident View Post
just to make things clearer for you, which bits should be shifted to which positions, try this optimized OCS-version:
That is *exactly* like mine but w/o x,y preservation

[and if you guess why the "strange"
roxl
, because i'm not too old to ror&rol
http://www.pouet.net/prod.php?which=61010] ]

Last edited by ross; 05 February 2018 at 19:19. Reason: []
ross is offline  
Old 05 February 2018, 20:42   #7
dissident
Registered User
 
Join Date: Sep 2015
Location: Germany
Posts: 256
Quote:
Originally Posted by ross View Post
That is *exactly* like mine but w/o x,y preservation

[and if you guess why the "strange"
roxl
, because i'm not too old to ror&rol
http://www.pouet.net/prod.php?which=61010] ]
Hey ross, I thought it was clear, that your routine was the template for my optimized code, which is good and made me rewrite my AGA-sprite positioning-routine. Anyway, thanks for the hint.
dissident is offline  
Old 05 February 2018, 22:40   #8
ross
Defendit numerus
 
ross's Avatar
 
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,468
Quote:
Originally Posted by dissident View Post
.. and made me rewrite my AGA-sprite positioning-routine.
ross 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
Would the Amiga be able to handle Angry Birds? Steve Retrogaming General Discussion 129 26 May 2023 17:40
How does Paula handle pending interrupts? bloodline Coders. Asm / Hardware 6 21 January 2018 15:45
How do you get the Handle of an existing Shape? earok Coders. Blitz Basic 1 22 April 2017 11:00
How to handle Screens and Colors in the GUI engine? AGS Coders. System 0 09 January 2014 20:49
How do you guys handle CommodoreUSA threads please? Pyromania project.EAB 9 17 February 2011 02:25

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 01:08.

Top

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