21 March 2013, 11:10 | #41 |
Global Moderator
Join Date: Nov 2001
Location: Derby, UK
Age: 48
Posts: 9,355
|
Code:
move.w #%1000010111000000, DMACON(a6) ; DMA set ON move.w #%0000000000111111, DMACON(a6) ; DMA set OFF I know what being set/unset. Am I right is assuming the first call to the DMA ON turns on the Blitter, Copper and Bitplane DMA and DMA Enable. Do the other DMA channels remain enabled, so the second DMA call is to turn them off? |
21 March 2013, 12:12 | #42 |
Registered User
Join Date: Jun 2008
Location: somewhere else
Posts: 521
|
The second call disable audio DMA, disk DMA and sprites DMA only.
|
21 March 2013, 12:16 | #43 |
Global Moderator
Join Date: Nov 2001
Location: Derby, UK
Age: 48
Posts: 9,355
|
Yes this is what I meant. Do they remain enabled and the first call just enables what's been specified?
For example Code:
move.w #$7fff,DMACON ; Disable all DMA(a6) move.w #$85C0,DMACON(a6) ; Enable Blitter, Copper, Bitplane DMA Last edited by BippyM; 21 March 2013 at 12:38. |
21 March 2013, 13:04 | #44 |
Computer Nerd
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 47
Posts: 3,810
|
|
21 March 2013, 13:11 | #45 |
Global Moderator
Join Date: Nov 2001
Location: Derby, UK
Age: 48
Posts: 9,355
|
Re: Code issues
Cool. Things are making sense now.
|
21 March 2013, 22:42 | #46 |
Registered User
Join Date: Feb 2013
Location: Lovisa / Finland
Age: 53
Posts: 80
|
bippym,
how is your code coming along? Have you made any MC68k-programs before? I am now preparing some more code for release during the weekend. |
21 March 2013, 22:45 | #47 |
Global Moderator
Join Date: Nov 2001
Location: Derby, UK
Age: 48
Posts: 9,355
|
Re: Code issues
I've done some whdload patching (with help from Stingray, Galahad and Codetapper) and I am comfortable with basic cracking etc..
As for actually written. Something.. nope not sure bean.. always got stuck with what to do lol. It takes forever due to family and work, but I'm getting there. Started creating the copperlist which will have all the register stuff in it.. Off to the gym now.. |
22 March 2013, 11:52 | #48 |
Global Moderator
Join Date: Nov 2001
Location: Derby, UK
Age: 48
Posts: 9,355
|
Guys,
Below is my code, but for some reason it just reboots the amiga... I cannot see why. I have written this pretty much myself, so there will be issues. You can see where I've commented stuff out to try and pinpoint the issue, but when I step through the debugger freezes on the dbf loop, although there is no reason why it should! If I just enable the BSR jumps at the beginning (and re-insert the RTS's) it will hang too.. Code:
; 8 Col screen 1 ; Open an 8 colour low-res screen, and display a picture in asm. ; ; 19/3/2013 14:30 ; ; Process for opening the screen is: ; ; 1). Backup current system. View, Copper,DMA, Audio/Disk controller (ADKON), Interrupts (INTENA, INTREQ) ; 2). Load in the GFX file and setup the bitplane pointers ; 3). Setup the palette ; 4). Create my copperlist (Include the enabling of the DMA, interrupts etc) ; 5). Copy the copper address into COP1 ; 7). Start the copper to display the picture ; 8). Display picture for 5 seconds (or so) ; 9). Restore the system copper(s), view and DMA, Interrupts etc ; 10). Exit the program incdir "mark_asm:open_screen/" ; Some equates for hardware and libary offsets ; Base custom address CUSTOM equ $dff000 ; Read addresses DMACONR equ $002 ADKCONR equ $010 INTENAR equ $01c INTREQR equ $01e ; Write addresses DMACON equ $096 ADKCON equ $09e INTENA equ $09a INTREQ equ $09c BPLCON0 equ $100 BPLCON1 equ $102 BPL1MOD equ $108 BPL2MOD equ $10a DIWSTRT equ $08e DIWSTOP equ $090 DDFSTRT equ $092 DDFSTOP equ $094 BPL1PTH equ $0e0 BPL1PTL equ $0e2 BPL2PTH equ $0e4 BPL2PTL equ $0e6 BPL3PTH equ $0e0 BPL3PTL equ $0e2 BPL4PTH equ $0e4 BPL4PTL equ $0e6 BPL5PTH equ $0e0 BPL5PTL equ $0e2 BPL6PTH equ $0e4 BPL6PTL equ $0e6 COP1LCH equ $080 COP1LCL equ $082 COP2LCH equ $084 COP2LCL equ $086 COPJMP1 equ $088 COPJMP2 equ $08A ; Library offsets execbase equ $4 openlibrary equ -552 closelibrary equ -414 forbid equ -132 permit equ -138 supervisor equ -30 loadview equ -222 waittof equ -270 ownblitter equ -456 disownblitter equ -462 waitblit equ -228 ; My offsets old_View_off equ 34 old_Clist1_off equ 38 old_Clist2_off equ 50 begin: movem.l d0-d7/a0-a6,-(sp) ; Backup the system registers jsr closesys ; jsr mysys ; jsr restoresys libfail: movem.l (sp)+,d0-d7/a0-a6 moveq.l #0,d0 ; No returncode to AmigaDOS rts ; First we backup the system and then take control closesys: move.l execbase,a6 ; Address of execbase into a6 lea gfxlibraryname,a1 ; address of the gfx lib into a1 moveq.l #0,d0 ; version of the library jsr openlibrary(a6) ; Open the library, address is returned in d0 move.l d0,gfxbase ; store the address of the library move.l d0,a6 ; Graphics library base address into a6 beq libfail ; Returned a 0 in d0, then lib failed to open. Let's quit ; Store the current system view and copperlists so we can restore them later move.l old_View_off(a6),sysview move.l old_Clist1_off(a6),sys1cop move.l old_Clist2_off(a6),sys2cop sub.l a1,a1 ; Null view for a blank screen jsr loadview(a6) ; Clear the screen jsr waittof(a6) ; Wait for the top of the next frame jsr waittof(a6) ; Wait again jsr ownblitter(a6) jsr waitblit(a6) ; Save the contents of the sys registers (DMA, ADKON, INTENA, INTREQ) lea CUSTOM,a6 ; Base address $dff000 move.w DMACONR(a6),d0 ; Store the contents of the DMA or.w #$8000,d0 ; Set it for re-writing later move.w d0,sysdma ; store for later move.w ADKCONR(a6),d0 ; Store the contents of the ADKCON register or.w #$8000,d0 ; Set it for re-writing later move.w d0,sysadkcon ; store for later move.w INTENAR(a6),d0 ; Store the contents of the interrupt-enable or.w #$8000,d0 ; Set it for re-writing later move.w d0,sysintena ; store for later move.w INTREQR(a6),d0 ; Store the contents of the interrupt-request or.w #$8000,d0 ; Set it for re-writing later move.w d0,sysintreq ; store for later ; System is now backed up, let's take it move.l execbase,a6 jsr forbid(a6) ; Disable the system move.l #$7fff,DMACON(a6) ; Disable all DMA channels move.l #$85C0,DMACON(a6) ; Enable Blitter, Copper, Bitplane DMA and turn DMAEN on and enable move.w #%1100000000000000, INTENA(a6) ; IRQ set ON move.w #%0011111111111111, INTENA(a6) ; IRQ set OFF ;rts mysys: ; Work out the bitplane sizes and addresses and pass to the copperlist. ; Bitplane info: 320*256*8. 40 words per line, 256 lines. 320x356/8bits = 10240bytes ; 10240*5=50kb : 2560 longs per bitplane ; lea bp1h,a0 ; first bitplane address in the copper moveq #3-1,d0 ; Number of bitplanes move.l #image,d1 ; Address of the picture into d1 setbpl: move.w d1,6(a0) ; bitplane low address pointer swap d1 move.w d1,2(a0) ; bitplane high address addq.w #8,a0 swap d1 add.l #40*256,d1 ; 10240 added for next plane dbf d0,setbpl ; branch until all bitplanes are copied ; load the copperlist into cop1lc lea mycopper,a0 ; Copper address into s1 move.l a0,COP1LCL(a6) ; and into the Cop1 register move.w d0,COPJMP1(a6) ; Start the copper ; Need to enable the following DMA channels: Copper, DMA, Blitter and Bitplane waitmouse: btst #6,$bfe001 bne waitmouse moveq #0,d0 ; rts rts ; My data structures, this includes the copperlist CNOP 0,4 ; Ensure we are on an even address! sys1cop: dc.l 0 ; To store the address of the first system copperlist sys2cop: dc.l 0 ; and the second system copperlist sysview: dc.l 0 ; The address to the system view gfxbase: dc.l 0 ; To store the return address of the graphics.library if successfully opened sysdma: dc.w 0 sysadkcon dc.w 0 sysintena dc.w 0 sysintreq dc.w 0 CNOP 0,4 gfxlibraryname: dc.b "graphics.library",0 ; Name of library we need CNOP 0,4 ; All the below needs to be in chipram as it is accessed by the custom chips! section chipram,data_c ; Bitplane information here. 3 bitplanes at 320x256 even ;bp1: dcb.b 10240,0 ; Bitplane 1 ;bp2: dcb.b 10240,0 ; Bitplane 2 ;bp3: dcb.b 10240,0 ; Bitplane 3 ; Copperlist below. We need to setup the following: ; BPLCON0 - Set an 8 colour, 3 bitplane display ; BPLCON1 - Unset set horizontal scroll delay (Set to 0) ; BPL1MOD & BPL2MOD - Set the modulo, again to 0 ; DIWSTRT - $2c81, and DIWSTOP to $2cc1 ; DDFSTRT - $0038 (Upper left), DDFSTOP to $00d0 (Lower right) ; BPL1PTH & BPL1PTL - BPL3PTH & BPLPTL - Address for each bitplane in memory. even mycopper: dc.w BPLCON0,$3200 ; %0011001000000000 dc.w BPLCON1,$0000 dc.w BPL1MOD,$0000,BPL2MOD,$0000 dc.w DIWSTRT,$2C81,DIWSTOP,$2CC1 dc.w DDFSTRT,$0038,DDFSTOP,$00D0 bp1h: dc.w BPL1PTH,$0000 ; Bitplane 1 high bytes register, use offset bp1l: dc.w BPL1PTL,$0000 ; Bitplane 1 high value, Bitplane 1 low register bp2h: dc.w BPL2PTH,$0000 ; Bitplane 1 high bytes register, use offset bp2l: dc.w BPL2PTL,$0000 ; Bitplane 1 high value, Bitplane 1 low register bp3h: dc.w BPL3PTH,$0000 ; Bitplane 1 high bytes register, use offset bp3l: dc.w BPL3PTL,$0000 ; Bitplane 1 high value, Bitplane 1 low register Palette: dc.w $0180,$0000,$0182,$0AAA,$0184,$0004,$0186,$0444 dc.w $0188,$0666,$018A,$0888,$018C,$0CCC,$018E,$0EEE dc.w $ffff,$fffe dc.w $ffff,$fffe even image: incbin "dh3:Open_Screen1/8cols.raw" |
22 March 2013, 12:31 | #49 |
Registered User
Join Date: May 2004
Location: Somewhere secret
Age: 50
Posts: 366
|
Code:
dbf d0,setbpl ; branch until all bitplanes are copied ; load the copperlist into cop1lc lea mycopper,a0 ; Copper address into s1 move.l a0,COP1LCL(a6) ; and into the Cop1 register move.w d0,COPJMP1(a6) |
22 March 2013, 12:33 | #50 |
Global Moderator
Join Date: Nov 2001
Location: Derby, UK
Age: 48
Posts: 9,355
|
yeah -1 ($FFFF), but I thought copjmp was a strobe address, and writing anything to it will start it!.
Will change it and see what happens. edit: That made no difference, but the following made a slight change move.l #$7fff,DMACON(a6) to move.w #$7fff,DMACON(a6) Now it just guru's, but not resetting the same! edit2: the move.w #$7fff,DMACON(a6) When this is executed, instant guru Last edited by BippyM; 22 March 2013 at 12:51. |
22 March 2013, 13:12 | #51 |
Computer Nerd
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 47
Posts: 3,810
|
Code:
begin: movem.l d0-d7/a0-a6,-(sp) ; Backup the system registers jsr closesys ; jsr mysys ; jsr restoresys libfail: movem.l (sp)+,d0-d7/a0-a6 moveq.l #0,d0 ; No returncode to AmigaDOS rts ; First we backup the system and then take control closesys: move.l execbase,a6 ; Address of execbase into a6 lea gfxlibraryname,a1 ; address of the gfx lib into a1 moveq.l #0,d0 ; version of the library jsr openlibrary(a6) ; Open the library, address is returned in d0 move.l d0,gfxbase ; store the address of the library move.l d0,a6 ; Graphics library base address into a6 beq libfail 1. When calling something like openlibrary, you have to compare the return value with 0. The system functions are not guaranteed to do that, so use a tst.l d0 before branching. 2. Look at how closesys is called, and then look at how the routine jumps back when openlibrary fails. |
22 March 2013, 13:23 | #52 |
move.l #$c0ff33,throat
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
|
Here's the reason for your crashes:
move.l execbase,a6 jsr forbid(a6) move.l #$7fff,DMACON(a6) ; Disable all DMA channels move.l #$85C0,DMACON(a6) ; Enable Blitter, Copper, Bitplane DMA and turn DMAEN on and enable move.w #%1100000000000000, INTENA(a6) ; IRQ set ON move.w #%0011111111111111, INTENA(a6) ; IRQ set OFF Also, your check if gfx lib has opened OK is fine since the move.l d0,gfxbase sets the flags, there is no tst.l needed! |
22 March 2013, 13:39 | #53 | ||
Computer Nerd
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 47
Posts: 3,810
|
Quote:
Quote:
Code:
; Save the contents of the sys registers (DMA, ADKON, INTENA, INTREQ) lea CUSTOM,a6 |
||
22 March 2013, 13:49 | #54 |
move.l #$c0ff33,throat
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
|
Please check the code properly! Also, there was a reason I gave a rather subtle hint as I wanted Bippy to spot the error.
|
22 March 2013, 14:11 | #55 |
Computer Nerd
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 47
Posts: 3,810
|
|
22 March 2013, 14:21 | #56 |
Global Moderator
Join Date: Nov 2001
Location: Derby, UK
Age: 48
Posts: 9,355
|
Bloody hell.. How did I miss that :/
Cheers guys.. To test |
22 March 2013, 16:10 | #57 | |
move.l #$c0ff33,throat
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
|
Quote:
Another (not so) subtle hint: If you have fixed your code and then wonder why you don't see any picture it might have to do with your DMA settings. |
|
22 March 2013, 17:03 | #58 |
Global Moderator
Join Date: Nov 2001
Location: Derby, UK
Age: 48
Posts: 9,355
|
Re: Code issues
Indeed I see no picture currently. I'll look again once I can get the daughter off my PC..
Thanks for the JIT tip. Using the debugger was frustrating |
22 March 2013, 17:09 | #59 |
Global Moderator
Join Date: Nov 2001
Location: Derby, UK
Age: 48
Posts: 9,355
|
Re: Code issues
Wooo.. I see a picture
There's still a bit of corruption and some of the palette looks wrong, which might be due to the copper. Need to investigate further. Exit code has now been written. Just to get the corruption gone and system stable then I plan to change bits.. Last edited by BippyM; 22 March 2013 at 18:06. |
22 March 2013, 19:26 | #60 |
Registered User
Join Date: Feb 2013
Location: Lovisa / Finland
Age: 53
Posts: 80
|
Bippym,
Good to know tou get the code to work at some level. Two hints to get the copperlist working: 1. lea mycopper,a0 ==> mycopper is a pointer and has to be handled as such. 2. move.l a0,COP1LCL(a6) ==> writing the address as a longword, take care to write it to the right location. The corrections to be made to the code are _very_ small, so don't over think them. If you have been looking at my code examples for starting the copperlist, you have to take notice of me using 2 different copperlists and therefore I store the pointer to the copperlists in a memorylocation, and address it as such. |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
My lost code | sardine | Looking for a game name ? | 0 | 21 July 2012 11:04 |
What's this code doing? | Jherek Carnelia | Coders. General | 13 | 15 August 2011 17:55 |
vB code for strikethrough | alexh | project.EAB | 3 | 07 May 2009 10:36 |
New EAB's vB Code | RCK | project.EAB | 6 | 23 April 2003 21:39 |
3D code and/or internet code for Blitz Basic 2.1 | EdzUp | Retrogaming General Discussion | 0 | 10 February 2002 11:40 |
|
|