30 November 2009, 15:31 | #1 |
Tiddlypeeps
Join Date: Oct 2009
Location: Ireland
Posts: 67
|
Displaying images
I have been messing around with 68k assembly for a few weeks, the next step I want to make is to display an image on the screen.
I am using workbench 3.1 and I am using os includes to do everything at the moment, and am not confindent enough in my asm skills to do otherwise just yet. Can anyone point me to any tutorials or post up some sample code that does this? Cheers |
30 November 2009, 16:19 | #2 |
gone
Join Date: Apr 2007
Location: completely gone
Posts: 1,596
|
Hello Tiddlypeeps
What does your code do so far...? Displaying a pic is nice and easy but I'm not personally sure how to go about showing the pic in an OS friendly way - is that what you're after? |
30 November 2009, 19:29 | #3 |
Join Date: Jul 2008
Location: Sweden
Posts: 2,269
|
Here's an example which displays a 32 color picture. It's OS friendly, but it will pause the OS to poke the hardware directly.
Don't be alarmed by the amount of files and code, most of it is just library code for support, the actual picture showing part is in the showpic.s file. Last edited by Leffmann; 30 November 2009 at 19:42. Reason: fixed some files |
02 December 2009, 15:07 | #4 | |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
|
Quote:
You can get more control over individual optimization options with the Devpac-compatible OPT directive. I changed the doc to make that clearer in the next relase. |
|
02 December 2009, 16:12 | #5 |
Join Date: Jul 2008
Location: Sweden
Posts: 2,269
|
Hi Frank
Glad you told me. The behavior I wanted was to optimize .s and unspecified to the shortest, while leaving .b .w .l as they are since I explicitly say what size they are. I'll look into the OPT directive. |
02 December 2009, 16:46 | #6 |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
|
That's not possible, as vasm makes no difference between .s and .b for branches. I would suggest to do a search-replace in your editor to replace all ".s" by "" and then assemble with default settings.
|
24 October 2011, 08:09 | #7 |
A1200 040 SAM440EP 667
Join Date: Jan 2008
Location: Lisbon / Portugal
Posts: 873
|
First sorry for hijack this thread
I´m trying to display a pattern in a 1 bitplane screen with the following code found in Amiga Computing magazine 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 what´s 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; 24 October 2011 at 15:58. |
24 October 2011, 20:47 | #8 |
Join Date: Jul 2008
Location: Sweden
Posts: 2,269
|
You're specifying a 256 lines tall display window, but only have 200 lines in your screen buffer. Write $F4C1 to DIWSTOP to shorten the window to 200 lines ($2C + 200 = $F4).
Also if you're on AGA then 32 or 64 bit bitplane fetch mode might be enabled and you need to adjust DDFSTRT and DDFSTOP accordingly, or you can write 0 to FMODE $DFF1FC to set it to 16 bit fetch mode. |
24 October 2011, 20:57 | #9 |
Dazed and Confused
Join Date: Dec 2001
Location: portsmouth/uk
Posts: 242
|
As Leffmann says, or you could change the line
scr dcb.b 8000,$55 to scr dcb.b 10240,$55 and get the attached when you run it (I still got some intermittent (sprite?) garbage though). |
24 October 2011, 23:10 | #10 |
A1200 040 SAM440EP 667
Join Date: Jan 2008
Location: Lisbon / Portugal
Posts: 873
|
Thanks for the help. Already understood the problem and fixed the code
|
24 October 2011, 23:39 | #11 | |
Registered User
Join Date: Nov 2010
Location: .
Posts: 351
|
Quote:
I usually start my copperlists with the following code: Code:
dc.w spr0pth,$0000,spr0ptl,$0000,spr1pth,$0000,spr1ptl,$0000 dc.w spr2pth,$0000,spr2ptl,$0000,spr3pth,$0000,spr3ptl,$0000 dc.w spr4pth,$0000,spr4ptl,$0000,spr5pth,$0000,spr5ptl,$0000 dc.w spr6pth,$0000,spr6ptl,$0000,spr7pth,$0000,spr7ptl,$0000 |
|
25 October 2011, 08:20 | #12 |
gone
Join Date: Apr 2007
Location: completely gone
Posts: 1,596
|
jman: doing this:
Code:
dc.w spr0pth,$0000,spr0ptl,$0000 When you have sprite DMA enabled, what you should really do instead for any sprites you're not using, is set their address pointers to point at a dummy null sprite: Code:
lea copper(pc),a0 lea dummy_sprite(pc),a1 move.l a1,d0 move.w d0,6(a0) swap d0 move.w d0,2(a0) etc. copper: dc.w spr0pth,$0000,spr0ptl,$0000 dummy_sprite: dcb.l 1,0 Last edited by pmc; 25 October 2011 at 08:46. Reason: Added some code to make the example clearer |
25 October 2011, 10:53 | #13 |
move.l #$c0ff33,throat
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
|
Since he's not using any sprites it would be enough to disable sprite DMA in this case. He should disable the system anyway as otherwise all kind of random bugs can appear since the OS is running while he's banging the hardware registers. Plus, what PMC (hi o/ ) said regarding sprite pointer initialisation.
|
26 October 2011, 09:49 | #14 | |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
|
Quote:
Then you would also have to zero the SPRxDAT registers, IIRC. |
|
26 October 2011, 10:21 | #15 |
Registered User
Join Date: Dec 2007
Location: Dark Kingdom
Posts: 213
|
Or, you have to turn off sprite DMA during the VBLANK
|
26 October 2011, 12:17 | #16 |
move.l #$c0ff33,throat
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
|
See TDC's answer. Sprite DMA needs to be disabled in the vertical blanking period, otherwise you'll see the mentioned bug (mouse pointer from the OS is a sprite and thus can cause this "nice" bug you mentioned).
|
26 October 2011, 13:27 | #17 |
TDI
Join Date: Feb 2007
Location: Blitter Town
Posts: 124
|
*slaps forehead*
I wasn't switching my sprites off at the right time. Had that random garbage thing coming up periodically for ages |
26 October 2011, 15:06 | #18 | |
Registered User
Join Date: Nov 2010
Location: .
Posts: 351
|
Quote:
And this casts a dark shadow over all I'm doing to prepare registers before triggering a copperlist. Using DC.W to set registers is not the same as using move.w in the main code body, I suppose now. Example: wrong: Code:
dc.w bplcon1,$0 Code:
move.w #$0,bplcon1 Hey thanks again, It's great to be on EAB! Last edited by jman; 26 October 2011 at 19:45. |
|
26 October 2011, 15:25 | #19 | ||
move.l #$c0ff33,throat
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
|
Quote:
Quote:
These instructions are not the same. dc.w bplcon1,0 is not the same as move.w $0,bplcon1. Correct would be move.w #$0,bplcon1. It's good style to do it that way but you can actually do it in whichever section of your code (that allows code) you want. |
||
26 October 2011, 19:44 | #20 | |
Registered User
Join Date: Nov 2010
Location: .
Posts: 351
|
But then how is that different doing
Code:
dc.w spr0pth,$0000 Code:
move.w #$0,spr0pth Quote:
Thanks! Last edited by jman; 26 October 2011 at 20:57. Reason: I'm not feeling well these days |
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Screen not displaying on 2.6.1 | Amiga1992 | support.WinUAE | 4 | 25 August 2013 17:50 |
CDTV without picture displaying ?? | haynor666 | support.Hardware | 34 | 18 February 2013 05:26 |
Displaying sprites | Hewitson | Coders. General | 18 | 27 April 2011 16:35 |
displaying correct MagicWB-colors | Bamiga2002 | support.Apps | 3 | 26 July 2010 11:06 |
New WinUAE's and screen displaying problem | Sloppy Elf | support.WinUAE | 3 | 26 January 2007 14:18 |
|
|