Ultimate Amiga

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: Fixing AMOS's dual playfield bug  (Read 8857 times)

0 Members and 1 Guest are viewing this topic.

james666

  • AMOS Dev
  • A600
  • *****
  • Karma: 6
  • Offline Offline
  • Posts: 32
Fixing AMOS's dual playfield bug
« on: February 06, 2011, 12:52:09 PM »

AMOS has an annoying bug that makes it impossible to scroll the background screen horizontally in dual playfield mode with more than 16 pixel precision.  This can be seen by running the following example:

Code: [Select]
For I=0 To 1
   Screen Open I,640,200,8,Lowres
   Screen Display I,129,48,320,200
   Flash Off : Curs Off : Cls 0
   Polygon 0,199 To 80,100 To 160,170 To 240,50 To 319,199
   Screen Copy I,0,0,320,200 To I,320,0
Next I

Dual Playfield 0,1
Double Buffer : Autoback 0

Do
   Add SX0,2,0 To 320
   Add SX1,1,0 To 320
   Screen Offset 0,SX0,0
   Screen Offset 1,SX1,0
   Screen Swap : Wait Vbl
Loop


The dual playfield example in AmosPro slyly limits itself to vertical scrolling to avoid this problem while implying that horizonal scrolling would be just as easy!  It's a real pity that this was never fixed.  Not only is the classic  "Shadow of the Beast" smooth hardware parallax impossible, but dual playfield mode is also very useful for speeding up bobs.  For example you can have a scrolling background playfield and all the bobs blitted on the foreground playfield in quick mode so the background doesn't have to be overwritten and restored each time they move.  Blitz Basic used this trick quite extensively.

In an effort to right the wrongs of history I've hacked together a program with a custom Copper list and some hardware pokes that does horizontal dual playfield scrolling properly.  It might be fun to rewrite this in Assembler as a nice user-friendly extension.  It wouldn't be too hard to add some AGA support while we're at it...

Code: [Select]
'--------------- hardware registers ------------------------
_COLOR0=$180

_DMACON=$DDF096
_DIWSTRT=$8E
_DIWSTOP=$90
_DDFSTRT=$92
_DDFSTOP=$94
_BPLCON0=$100 : Rem screen mode 
_BPLCON1=$102 : Rem playfield horizontal scroll
_BPLCON2=$104 : Rem Playfield and sprite priorities

'bitplane pointers
_BPL1PTH=$E0
_BPL2PTH=$E4
_BPL3PTH=$E8
_BPL4PTH=$EC
_BPL5PTH=$F0
_BPL6PTH=$F4


'bitplane modulos (one for each playfield)
_BPL1MOD=$108
_BPL2MOD=$10A

_COP1LC=$DDF080 : Rem Pointer to copper list
'-------------------------------------------------------------
On Error Proc CLEAN_UP
On Break Proc CLEAN_UP

For I=0 To 1
   Screen Open I,640,200,8,Lowres
   Screen Display I,129,48,320,200
   Flash Off : Curs Off : Cls 0
   Polygon 0,199 To 80,100 To 160,170 To 240,50 To 319,199
   Screen Copy I,0,0,320,200 To I,320,0
Next I
Double Buffer : Autoback 0

Copper Off

Doke _DMACON,$180 : Rem kill bitplane and copper dma before we start tinkering   
Dim A(1)

'screen (x,y) position in hardware coords, width and height 
DTX=129 : Rem Make sure this is an odd number
DTY=48
DW=320
DH=200

For I=0 To 1
   Cop Move _BPLCON1,$0
   Cop Move _BPLCON2,0
   Cop Move _BPL1MOD,38
   Cop Move _BPL2MOD,38
   Cop Move _DIWSTRT,DTY*256+DTX
   Cop Move _DIWSTOP,(DTY+DH-256)*256+DTX+DW-256
   Cop Move _DDFSTRT,DTX/2-16 : Rem DDFSTRT and DDFSTOP change for hires
   Cop Move _DDFSTOP,DTX/2-8+8*(DW/16-1)
   '
   'start+32
   'first high bp pointer at start+34, low pointer at start+38 
   Screen 0
   Cop Movel _BPL1PTH,Logbase(0)-2
   Cop Movel _BPL3PTH,Logbase(1)-2
   Cop Movel _BPL5PTH,Logbase(2)-2
   
   Screen 1
   Cop Movel _BPL2PTH,Logbase(0)-2
   Cop Movel _BPL4PTH,Logbase(1)-2
   Cop Movel _BPL6PTH,Logbase(2)-2
   
   'Cop Move _BPLCON0,$4200 :rem 4 bitplanes, no dualplayfield
   
   Cop Move _BPLCON0,$6600 : Rem 6 bitplanes, dual playfield
   
   Cop Wait 0,47
   For C=0 To 15
      Cop Move _COLOR0+C*2,Colour(C)
   Next C
   
   Cop Wait 254,255
   
   A(I)=Cop Logic
   Cop Swap
   Screen Swap
Next I

'enable copper and bitplane DMA
Doke _DMACON,$8180


'The Cop Swap command copies all the commands that have been defined
'with the Cop Move and Cop Wait instructions since the _previous_ Cop Swap
'into a list starting at Cop Logic, then swaps the physical and logical
'pointers.  If there have been no Cop Move or Cop Wait instructions
'since the last Cop Swap we get garbage copied into Cop Logic before the swap.
'We just want to swap the pointers so we have to poke _COP1LC manually

CL=0

Dim SX(1),BO(1),FS(1)

For SLOOP=1 To 2000
   Add SX(0),2,0 To 320 : Rem horizontal scroll offset in pixels
   Add SX(1),1,0 To 320
   
   For PF=0 To 1
      BO(PF)=SX(PF)/16 : Rem scroll offset in words
      R=SX(PF)-BO(PF)*16 : Rem remainder
      If R
         FS(PF)=16-R : Rem finescroll
      Else
         FS(PF)=0
         BO(PF)=BO(PF)-1
      End If
      BO(PF)=BO(PF)*2 : Rem offset in bytes to be added to bitplane pointers   
   Next PF
   
   Doke A(CL)+2,FS(0)+FS(1)*16 : Rem poke finescroll value in logical copper list

   'update the bitplane pointers of screen 0
   Screen 0
   For BP=0 To 2
      BPADD=Logbase(BP)+BO(0)
      BPADDH=BPADD/$10000
      BPADDL=BPADD-BPADDH*$10000
      Doke A(CL)+34+BP*8,BPADDH
      Doke A(CL)+38+BP*8,BPADDL
   Next BP
   
   'update the bitplane pointers of screen 1
   Screen 1
   For BP=3 To 5
      BPADD=Logbase(BP-3)+BO(1)
      BPADDH=BPADD/$10000
      BPADDL=BPADD-BPADDH*$10000
      Doke A(CL)+34+BP*8,BPADDH
      Doke A(CL)+38+BP*8,BPADDL
   Next BP
   
   Loke _COP1LC,A(CL) : Rem Swap copper lists
   Screen Swap
   Wait Vbl
   CL=1-CL
Next SLOOP
Wait Key

CLEAN_UP

Procedure CLEAN_UP
   Copper On
   End
End Proc
                   
Logged

SamuraiCrow

  • compile-time wierdo
  • Forum Mod
  • A1200
  • *****
  • Karma: 5
  • Offline Offline
  • Gender: Male
  • Posts: 946
  • Compile-time wierdo
Re: Fixing AMOS's dual playfield bug
« Reply #1 on: February 07, 2011, 03:18:53 PM »

The scroll bug only exerts itself on one of the odd-numbered offsets and only on one of the playfields.  See this example to see how to do horizontal scrolling.  I think it only works if the foreground playfield is an even offset so it scrolls at 2 pixel offsets to keep it even.

An extension that would fix this would be neat though.
Logged

Lonewolf10

  • AMOS Extensions Developer
  • AMOS Dev
  • A2000
  • *****
  • Karma: 3
  • Offline Offline
  • Gender: Male
  • Posts: 618
    • http://www.aliensrcooluk.com
Re: Fixing AMOS's dual playfield bug
« Reply #2 on: February 24, 2011, 01:06:20 PM »

An extension that would fix this would be neat though.


Noted.

I won't get around to adding it to my extension for a few months as I am in the middle of creating my own (ASM only) Amiga demo. The good news is that I learnt how to do a hardware scroll as part of my demo :)

All the known info regarding AMOS screens can be found on www.AmigaCoding.com here.

Has anyone checked to see if Pietro Ghizzoni's updated AMOS files fixed this problem?


Regards,
Lonewolf10

« Last Edit: February 24, 2011, 01:15:01 PM by Lonewolf10 »
Logged

james666

  • AMOS Dev
  • A600
  • *****
  • Karma: 6
  • Offline Offline
  • Posts: 32
Re: Fixing AMOS's dual playfield bug
« Reply #3 on: April 09, 2011, 04:13:27 PM »

I decided to put my money where my mouth is and turn this into a user-friendly AMOS Pro extension, which I'm tentatively calling "Display Library".  It's pretty simple so far but it lets you merge two AMOS screens into a lowres dual playfield display and scroll them independently.  It also supports 2x16 colour playfields if AGA is available.  I plan to work this into a full blown AGA extension but I suspect that will take a few more months...

My WIP is attached.  The testext.lib file needs to be copied to your APsystem folder and configured as extension number 24 in the editor.  The new commands are described in demo1.amos.
Logged

BooBoo

  • Amiga Guru
  • A600
  • ****
  • Karma: 3
  • Offline Offline
  • Posts: 168
Re: Fixing AMOS's dual playfield bug
« Reply #4 on: April 10, 2011, 01:58:32 PM »

sounds very intresting 2*16 :)
Logged

Lonewolf10

  • AMOS Extensions Developer
  • AMOS Dev
  • A2000
  • *****
  • Karma: 3
  • Offline Offline
  • Gender: Male
  • Posts: 618
    • http://www.aliensrcooluk.com
Re: Fixing AMOS's dual playfield bug
« Reply #5 on: August 05, 2011, 05:49:04 PM »


Wow, I vanish for a few months and you do this!

Cool, will download and have a play with it over the next few weeks (I'd normally say days, but I'm very busy at the moment). :)


Regards,
Lonewolf10
Logged

Lonewolf10

  • AMOS Extensions Developer
  • AMOS Dev
  • A2000
  • *****
  • Karma: 3
  • Offline Offline
  • Gender: Male
  • Posts: 618
    • http://www.aliensrcooluk.com
Re: Fixing AMOS's dual playfield bug
« Reply #6 on: August 15, 2011, 11:46:54 AM »

My WIP is attached.  The testext.lib file needs to be copied to your APsystem folder and configured as extension number 24 in the editor.  The new commands are described in demo1.amos.

I tried all 3 demo's today - demo's 1 and 2 appear to do nothing (atleast with my setup on WinUAE) other than setup the 2 mountains (triangles) which quickly vanish off of the screen. Demo 3 doesn't go anywhere - the Dlcheckaga command doesn't seem to work, even with the AGA chipset selected in WinUAE (and CPU's 68060,68040 or 68020 selected).


Also, I tried compiling demo 3. It compiled, but crashed when I ran it (error 80000006). I used my Extension Examiner program (available on Aminet) to check your extension and everything looks to be set up ok, so it must be something to do with your code that is causing the crash :(

Keep us posted on your progress.


Regards,
Lonewolf10
Logged

james666

  • AMOS Dev
  • A600
  • *****
  • Karma: 6
  • Offline Offline
  • Posts: 32
Re: Fixing AMOS's dual playfield bug
« Reply #7 on: August 18, 2011, 01:28:56 PM »

I tried all 3 demo's today - demo's 1 and 2 appear to do nothing (atleast with my setup on WinUAE) other than setup the 2 mountains (triangles) which quickly vanish off of the screen. Demo 3 doesn't go anywhere - the Dlcheckaga command doesn't seem to work, even with the AGA chipset selected in WinUAE (and CPU's 68060,68040 or 68020 selected).

Also, I tried compiling demo 3. It compiled, but crashed when I ran it (error 80000006). I used my Extension Examiner program (available on Aminet) to check your extension and everything looks to be set up ok, so it must be something to do with your code that is causing the crash :(

How very embarrassing.  It works fine on my WinUAE installation but crashes and burns as described above when I try it on my real A1200 with 030 board.  It looks as if the initialisation routine isn't running properly.  I wonder if this might be due to a kickstart 3.1 dependency in my code as the A1200 only has 3.0.  Which version are you using?
Logged

Lonewolf10

  • AMOS Extensions Developer
  • AMOS Dev
  • A2000
  • *****
  • Karma: 3
  • Offline Offline
  • Gender: Male
  • Posts: 618
    • http://www.aliensrcooluk.com
Re: Fixing AMOS's dual playfield bug
« Reply #8 on: August 20, 2011, 05:16:15 PM »


After re-reading my previous post, I noticed that I didn't mention anything about which ROM I used, so I tried using the 3.0 and 3.1 ROM's I have with WinUAE (2.0.1)...

KS ROM v3.0 (A4000) rev 39.106 (512k) [391513-02/391514-02]
KS ROM v3.1 (A4000)(Cloanto) rev 40.68 (512k)
KS ROM v3.1 (A500,A600,A2000) rev 40.63 (512k)

... and still couldn't get it to work :(

I also tried one of WinUAE's default config's incase I was overlooking something in my AGA setup...

A1200 + 8 MB RAM (3.1 ROM, 68020, AGA)

... but still couldn't get it to work :(


Could you send me your WinUAE config? Which version of WinUAE are you running?


Regards,
Lonewolf10
Logged
Pages: [1]   Go Up
 

TinyPortal 2.2.2 © 2005-2022