Falcon TrueColor video artifacts

C and PASCAL (or any other high-level languages) in here please

Moderators: simonsunnyboy, Mug UK, Zorro 2, Moderator Team

Post Reply
simonsunnyboy
Moderator
Moderator
Posts: 5225
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

Falcon TrueColor video artifacts

Post by simonsunnyboy »

Hi all,

I digged out one of my first tests of AHCC which was writing a driver/library for Falcon TrueColor graphics.
I have refactored the old source to fit the current AHCC v4.11 but the problem prevails.
grab0001.png
I get drawing artifacts on my screen (both real Falcon and Hatari), see the disorted line and the horizontal blank thing in the middle?

Can anyone comment what could be the cause?

Most stuffs are written in M68K but I glue it together with AHCC.

I only call the following PutPixel rout atm (and replacing with a C equivalent did not help):

Code: Select all

TC320x240_PutPixel:
	movem.l d3-d7/a1-a6,-(sp)
	clr.l d3
	; calculate onscreen position  screenptr + y*640 + x*2
	move.w d1,d3
	mulu #640,d3
	andi.l #$0000FFFF,d0
	lsl.l #1,d0
	add.w d0,d3
	adda.l d3,a0
	; draw pixel
	move.w d2,(a0)
	movem.l (sp)+,d3-d7/a1-a6
	rts

Regards,
ssb
You do not have the required permissions to view the files attached to this post.
Simon Sunnyboy/Paradize - http://paradize.atari.org/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee

simonsunnyboy
Moderator
Moderator
Posts: 5225
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

Re: Falcon TrueColor video artifacts

Post by simonsunnyboy »

Maybe someone adventurous wants to debug the whole thing. I have attached the executable below.
You do not have the required permissions to view the files attached to this post.
Simon Sunnyboy/Paradize - http://paradize.atari.org/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee

Dio
Captain Atari
Captain Atari
Posts: 451
Joined: Thu Feb 28, 2008 3:51 pm

Re: Falcon TrueColor video artifacts

Post by Dio »

I think the problem is add.w d0,d3

640*(something) approaches 16 bits after just over 100 lines, and if the 16-bit add fails to carry you'll get a bad address. I think the problem shows at any pixels on line 102 with an X greater than 127.

Change it to adda.w d0,a0, or add.l d0,d3 and I think it will probably work OK.

(I think you can also improve performance by not doing the and to d0, using adda instead, and not doing the clr and move from d1 to d3 - the input to mulu is 16-bit. And, obviously, not saving so many registers; if it's acceptable to trash d0 and d1 then a0 is the only other reg you need here. But get it working first :) ).

User avatar
Nyh
Atari God
Atari God
Posts: 1496
Joined: Tue Oct 12, 2004 2:25 pm
Location: Netherlands

Re: Falcon TrueColor video artifacts

Post by Nyh »

As you are on a 68030 you clould do something like this:

Code: Select all

  mulu   #320,d1
  ext.l  d0
  add.l  d0,d1
  move.w d2,0(2*d1.l,a0)
  rts
Hans Wessels

simonsunnyboy
Moderator
Moderator
Posts: 5225
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

Re: Falcon TrueColor video artifacts

Post by simonsunnyboy »

Thanks for your suggestions, actually the .w instead of the .l was the culprit. Pretty obvious but I was blind for my own code. 8)

@Nyh: I'm willing to optimize (ofcourse) but could you please explain your suggestion? I see it uses less instructions but what do they exactly do? Esp the ext.l instruction eludes me :(
Simon Sunnyboy/Paradize - http://paradize.atari.org/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee

Dio
Captain Atari
Captain Atari
Posts: 451
Joined: Thu Feb 28, 2008 3:51 pm

Re: Falcon TrueColor video artifacts

Post by Dio »

ext.l takes a word and sign-extends it to a long.

Another advantage of nyh's routine is that it doesn't corrupt a0 or d0.w, so this may allow the calling code to be more efficient.

simonsunnyboy
Moderator
Moderator
Posts: 5225
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

Re: Falcon TrueColor video artifacts

Post by simonsunnyboy »

The plain formula is screen[y*640+2*x]=color If I get it right, the *2 is left for the last step in this example but what exactly means "sign-extend"? d0/d1 are signed integers/int16_t from C view, screen coordinates, d2 is the 16bit pixel color.
Simon Sunnyboy/Paradize - http://paradize.atari.org/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee

User avatar
Nyh
Atari God
Atari God
Posts: 1496
Joined: Tue Oct 12, 2004 2:25 pm
Location: Netherlands

Re: Falcon TrueColor video artifacts

Post by Nyh »

Code: Select all

  mulu   #320,d1  ; Multiply by 320, d1 is now and 32 number
  ext.l  d0                     ; Convert d0 from a signed 16 bit integer to a signed 32 bit integer, if d1 was negative, the result will be a 32 bit negative
  add.l  d0,d1                ; Add them
  move.w d2,0(2*d1.l,a0); move d2 to the address A0+2*d2 (this is an 68030 instruction)
  rts
As d0 should be between 0-320 the ext.l instruction will only clear the upper 16 bits of the d0 register. The instruction takes the msb of the 16 bit register and fills the upper 16 bits with its value.

Hans Wessels

simonsunnyboy
Moderator
Moderator
Posts: 5225
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

Re: Falcon TrueColor video artifacts

Post by simonsunnyboy »

Thanks for the explanation! Implementation on my end will depend on the AHCC asssembler. Does it eat the 68030 specific instructions already?

IIRC AHCC produces only 68020 (or Coldfire) code.
Simon Sunnyboy/Paradize - http://paradize.atari.org/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee

Henk Robbers
AHCC Developer
AHCC Developer
Posts: 39
Joined: Mon Nov 14, 2011 2:37 pm

Re: Falcon TrueColor video artifacts

Post by Henk Robbers »

AHCC assembler can produce code for ALL 68K plus Coldfire

The default is 68000.
There are directives for introducing other machines.

Acceptable syntax:
move.w d2,0(a0,d1.l*2); (this is an 68020 instruction)

Everybody must read Motorola programmers reference manuals!!!!!!
They are all free downloads from the Motorola site(s) (or Freescale)

simonsunnyboy
Moderator
Moderator
Posts: 5225
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

Re: Falcon TrueColor video artifacts

Post by simonsunnyboy »

Nyh wrote:

Code: Select all

  mulu   #320,d1  ; Multiply by 320, d1 is now and 32 number
  ext.l  d0                     ; Convert d0 from a signed 16 bit integer to a signed 32 bit integer, if d1 was negative, the result will be a 32 bit negative
  add.l  d0,d1                ; Add them
  move.w d2,0(2*d1.l,a0); move d2 to the address A0+2*d2 (this is an 68030 instruction)
  rts
As d0 should be between 0-320 the ext.l instruction will only clear the upper 16 bits of the d0 register. The instruction takes the msb of the 16 bit register and fills the upper 16 bits with its value.

Hans Wessels

Current AHCC does not like this 68030 syntax. I used the 020 version under Hatari.
grab0002.png
You do not have the required permissions to view the files attached to this post.
Simon Sunnyboy/Paradize - http://paradize.atari.org/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee

Post Reply

Return to “C / PASCAL etc.”