amiga.org
     
iconAll times are GMT -6. The time now is 05:59 AM. | Welcome to Forum, please register to access all of our features.

Amiga.org Operating System Specific Discussions Amiga OS Amiga OS -- Development Pattern screen

Amiga OS -- Development This particular forum deals with issues regarding development for all versions of AmigaOS.

Reply
 
Thread Tools Display Modes
Old 10-24-2011, 07:50 AM   #1
AlfaRomeo
Merely Curious
Points: 1,239, Level: 19 Points: 1,239, Level: 19 Points: 1,239, Level: 19
Activity: 2% Activity: 2% Activity: 2%
 
Join Date: Jul 2010
Posts: 8
Default Pattern screen

Hi,
Im trying to display a pattern in a 1 bitplane screen with the following code found in Amiga Computing Mag but it results in screen garbage and not in a regular pattern as it should be.
I already tried to find the bug but with no luck
Can someone point whats wrong in the code that results in the garbage displayed on the screen, please?

Code:
                         Section Screen,code_c
 
_LVOOpenLib    EQU    -552
_LVOCloseLib    EQU    -414
 
DiwStart    EQU    $8E
DiwStop        EQU    $90
DDFStart    EQU    $92
DDFStop        EQU    $94
BplCon0        EQU    $100
BplCon1        EQU    $102
Col0        EQU    $180
Col1        EQU    $182
BPL1PTH        EQU    $E0
BPL1PTL        EQU    $E2
 
        move.l    #scr,d0    ;Load address of our screen in d0
        move.w    d0,pl1l    ;Load low scr addr in Copper list
        swap    d0    ;Swap address in d0
        move.w    d0,pl1h    ;Load high scr addr in Copper list
 
        move.l     4.w,a6            ;ExecBase
        move.l    #0,d0
        lea    GfxName,a1
        jsr    _LVOOpenLib(a6)        ;Open GFX library
        move.l    d0,a1
        move.l    38(a1),WB    ;Store WB Copper addr
 
        move.l    4.w,a6
        jsr    _LVOCloseLib(a6)    ;Close GFX library
 
        move.l    #CopList,$DFF080    ;Load Copper list in Copper
 
Loop:        btst    #6,$BFE001    ;Test left mouse button
        bne    Loop        ;If not pressed keep in loop
 
        move.l    WB,$DFF080    ;Restore WB Copper
        rts
 
CopList:    dc.w    DiwStart,$2C81        ;Top left corner of the scr
        dc.w    DiwStop,$2CC1    ;Bottom right corner scr
        dc.w    DDFStart,$38    ;Data fetch start
        dc.w    DDFStop,$D0    ;Data fetch stop
        dc.w    BplCon0,$1000    ;Set 1 bitplane lo-res scr
        dc.w    BplCon1,$0    ;No horizontal offset
        dc.w    Col0,$0        ;Black background color
        dc.w    Col1,$FFF    ;White foreground color
        dc.w    BPL1PTH        ;Bitplane low high word    
pl1h
        dc.w    0
        dc.w    BPL1PTL        ;Bitplane low word
pl1l
        dc.w    0
        dc.w    $FFFF,$FFFE    ;End of copper list
 
WB        dc.l    0
 
scr        dcb.b    8000,$55     ;Block of 8000 bytes of a pattern
 
GfxName        dc.b    "graphics.library",0

Last edited by AlfaRomeo; 10-24-2011 at 07:58 AM..
AlfaRomeo is offline   Reply With Quote
Old 10-24-2011, 08:12 AM   #2
Thomas
Kindred of Babble-on
Points: 14,751, Level: 78 Points: 14,751, Level: 78 Points: 14,751, Level: 78
Activity: 2% Activity: 2% Activity: 2%
 
Thomas's Avatar
 
Join Date: Jun 2002
Posts: 2,995
Default Re: Pattern screen

The pattern needs to be in chip memory. Your program only works on machines without Fast RAM. Or run NoFastMem before you test your program.
__________________
Email: thomas-rapp@web.de
Home: thomas-rapp.homepage.t-online.de/
Thomas is offline   Reply With Quote
Old 10-24-2011, 12:05 PM   #3
Joloo
Beginner
Points: 4,772, Level: 44 Points: 4,772, Level: 44 Points: 4,772, Level: 44
Activity: 1% Activity: 1% Activity: 1%
 
Joloo's Avatar
 
Join Date: Oct 2006
Posts: 31
Default Re: Pattern screen

Well, your example works here, okay it is NTSC thus graphical glitches appear.

Seems that Thomas is right, your assembler doesn't recognize the "CODE_C, DATA_C" attributes, which means that the code or data sections weren't forced to CHIP-RAM.

Either you take an other assembler or an old tool that modifies the hunks of an executable file to be forced to CHIP-RAM or you use the tools Thomas suggested.

Please note that your source code is really old and thus won't do anything on an AGA machine unless you remember and restore the display correctly.
Your example was adopted for this reason and also the PAL norm was used instead of NTSC.

Code:
       OUTPUT RAM:test

       include hardware/custom.i
       include graphics/gfxbase.i
       include exec/exec_lib.i
       include graphics/graphics_lib.i

       SECTION Text,CODE
main:
        move.l  #scr,D0                 ;Load address of our screen in d0
        move.w  D0,pl1l                 ;Load low scr addr in Copper list
        swap    D0                      ;Swap address in d0
        move.w  D0,pl1h                 ;Load high scr addr in Copper list

        move.l  4.w,A6                  ;ExecBase
        moveq   #33,D0
        lea     GfxName(pc),A1
        jsr     _LVOOpenLibrary(A6)     ;Open GFX library
        lea     _GfxBase(pc),A0
        move.l  D0,(A0)
        beq.b   out

* Remember current view
        movea.l D0,A6
        lea     _OldCop(pc),A0
        move.l  gb_LOFlist(A6),(A0)     ; Current copper list being used
        lea     _OldView(pc),A0
        move.l  gb_ActiView(A6),(A0)    ; Current view being viewed

* Reset the view
        suba.l  A1,A1                   ; NULL
        jsr     _LVOLoadView(A6)        ; Reset whole display!
        jsr     _LVOWaitTOF(A6)         ; Wait until system has done
        jsr     _LVOWaitTOF(A6)         ; all changes

        move.l  #CopperList,$DFF080     ;Load Copper list in Copper

Loop:   btst    #6,$BFE001              ;Test left mouse button
        bne.b   Loop                    ;If not pressed keep in loop

endit:
* Reset to remembered state the view (bring back Intuition)
        movea.l _GfxBase(pc),A6
        lea     $DFF000,A5

        move.l  gb_copinit(A6),cop1lc(A5)
        move.w  #0,copjmp1(A5)
        move.w  #$83E0,dmacon(A5)

        movea.l _OldView(pc),A1
        move.l  _OldCop(pc),gb_LOFlist(A6)
        jsr     _LVOLoadView(A6)

        movea.l  A6,A1
        movea.l  4.w,A6
        jsr      _LVOCloseLibrary(A6)

out:
        rts

_GfxBase:
        ds.l    1
_OldCop:
        ds.l    1
_OldView:
        ds.l    1

GfxName:
        dc.b    "graphics.library",0


        SECTION Screen,DATA_C
* Settings for an overscan PAL display; screen: 416x345 pixels
CopperList:
        dc.w    diwstrt,$2981   ;Top left corner of the scr
        dc.w    diwstop,$29C1   ;Bottom right corner scr
        dc.w    ddfstrt,$20     ;Data fetch start
        dc.w    ddfstop,$D8     ;Data fetch stop
        dc.w    bplcon0,$1000   ;Set 1 bitplane lo-res scr
        dc.w    bplcon1,$0      ;No horizontal offset
        dc.w    color+0,$0      ;Black background color
        dc.w    color+2,$FFF    ;White foreground color
        dc.w    bplpt+0         ;Bitplane low high word
pl1h:
        dc.w    0
        dc.w    bplpt+2         ;Bitplane low word
pl1l:
        dc.w    0
        dc.w    $FFFF,$FFFE     ;End of copper list

scr:
        dcb.b   17940,$55       ; Block of n bytes filled with a pattern


        END
Joloo is offline   Reply With Quote
Old 10-24-2011, 02:59 PM   #4
AlfaRomeo
Merely Curious
Points: 1,239, Level: 19 Points: 1,239, Level: 19 Points: 1,239, Level: 19
Activity: 2% Activity: 2% Activity: 2%
 
Join Date: Jul 2010
Posts: 8
Default Re: Pattern screen

Thanks for the help.
I thought that the command "section screen,code_c" at the beginning of the code was to force the code to be in ChipRam my compiler is DevPac 3.18, should recognise "code_c"

Last edited by AlfaRomeo; 10-24-2011 at 03:02 PM..
AlfaRomeo is offline   Reply With Quote
Old 10-30-2011, 09:58 AM   #5
Joloo
Beginner
Points: 4,772, Level: 44 Points: 4,772, Level: 44 Points: 4,772, Level: 44
Activity: 1% Activity: 1% Activity: 1%
 
Joloo's Avatar
 
Join Date: Oct 2006
Posts: 31
Default Re: Pattern screen

Sorry for replying that late.

I never created a NTSC display thus I did guess that your chosen values were correctly. Unfortunately, it turned out the weren't.
Please read the chapter for Playfields (hardware reference manual) again, then you know that an ordinary display window of size 320x200 (NTSC) or 320x256 (PAL) starts at 129;41. It ends for a NTSC display window (screen) at 449;241 (129+320;41+200) or for PAL at 449;297 (129+320;41+256).
If you choose overscan dimensions instead the starting point is 100;26 (DIWSTRT) and you cannot go lower this value due to the interrupts.
Next, any other value depends on DIWSTRT and DIWSTOP, hence DDFSTRT and DDFSTOP were also incorrect in your example and thus I believe that this caused the graphical corruptions, not the assembler, since Devpac supports sections which will be put to CHIP-RAM, as you know.
I modified your example to use default NTSC values.
Hope you don't see any more those graphical corruptions.

Regards

Code:
       OUTPUT RAM:test

       include hardware/custom.i
       include graphics/gfxbase.i
       include exec/exec_lib.i
       include graphics/graphics_lib.i

       SECTION Text,CODE
main:
        move.l  #scr,D0                 ;Load address of our screen in d0
        move.w  D0,pl1l                 ;Load low scr addr in Copper list
        swap    D0                      ;Swap address in d0
        move.w  D0,pl1h                 ;Load high scr addr in Copper list

        move.l  4.w,A6                  ;ExecBase
        moveq   #33,D0
        lea     GfxName(pc),A1
        jsr     _LVOOpenLibrary(A6)     ;Open GFX library
        lea     _GfxBase(pc),A0
        move.l  D0,(A0)
        beq.b   out

* Remember current view
        movea.l D0,A6
        lea     _OldCop(pc),A0
        move.l  gb_LOFlist(A6),(A0)     ; Current copper list being used
        lea     _OldView(pc),A0
        move.l  gb_ActiView(A6),(A0)    ; Current view being viewed

* Reset the view
        suba.l  A1,A1                   ; NULL
        jsr     _LVOLoadView(A6)        ; Reset whole display!
        jsr     _LVOWaitTOF(A6)         ; Wait until system has done
        jsr     _LVOWaitTOF(A6)         ; all changes

        move.l  #CopperList,$DFF080     ;Load Copper list in Copper

Loop:   btst    #6,$BFE001              ;Test left mouse button
        bne.b   Loop                    ;If not pressed keep in loop

endit:
* Reset to remembered state the view (bring back Intuition)
        movea.l _GfxBase(pc),A6
        lea     $DFF000,A5

        move.l  gb_copinit(A6),cop1lc(A5)
        move.w  #0,copjmp1(A5)
        move.w  #$83E0,dmacon(A5)

        movea.l _OldView(pc),A1
        move.l  _OldCop(pc),gb_LOFlist(A6)
        jsr     _LVOLoadView(A6)

        movea.l  A6,A1
        movea.l  4.w,A6
        jsr      _LVOCloseLibrary(A6)

out:
        rts

_GfxBase:
        ds.l    1
_OldCop:
        ds.l    1
_OldView:
        ds.l    1

GfxName:
        dc.b    "graphics.library",0


        SECTION Screen,DATA_C
* Settings for a plain NTSC display; screen: 320x200 pixels
CopperList:
        dc.w    diwstrt,$2981   ;Top left corner of the scr (129;41 NTSC *or* PAL!)
        dc.w    diwstop,$F1C1   ;Bottom right corner scr (449;241 NTSC - for PAL use:
*                                449,297)
        dc.w    ddfstrt,$38     ;Data fetch start ($2981 & $FF / 2 - 8.5)
        dc.w    ddfstop,$D0     ;Data fetch stop ($38 + (320 / 2 - 8)
        dc.w    bplcon0,$1000   ;Set 1 bitplane lo-res scr
        dc.w    bplcon1,$0      ;No horizontal offset
        dc.w    color+0,$0      ;Black background color
        dc.w    color+2,$FFF    ;White foreground color
        dc.w    bplpt+0         ;Bitplane low high word
pl1h:
        dc.w    0
        dc.w    bplpt+2         ;Bitplane low word
pl1l:
        dc.w    0
        dc.w    $FFFF,$FFFE     ;End of copper list

scr:
        dcb.b   320/8*200,$55   ; Block of n bytes filled with a pattern

        END
Joloo is offline   Reply With Quote
Reply

Bookmarks

Tags
pattern , screen

Thread Tools
Display Modes

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