Amiga.org
Operating System Specific Discussions => Amiga OS => Amiga OS -- Development => Topic started by: AlfaRomeo on October 24, 2011, 02:50:15 PM
-
Hi,
I´m 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 :angry:
Can someone point what´s wrong in the code that results in the garbage displayed on the screen, please?
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
-
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.
-
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.
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
-
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 :angry: my compiler is DevPac 3.18, should recognise "code_c"
-
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
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