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"
|