Registered User
Join Date: Jan 2016
Location: NL
Posts: 32
|
Quote:
the demo drastically slowed down
|
This also happens on my WinUAE config; so this is not because of FS-UAE you seem to use.
- While trying to find the cause of the slowing down I messed around with your code and consolidated some parts of it; this should be done even more, because the Movebar: procedure 'should be' 1 piece of code, this would cause the program to bounce-around a lot less...
- I also added some code to see the cpu-usage of the Movebar: procedure and raised the rasterline-wait to line 301, which is 1 line below the bottom-green line.
Code:
...
Main:
move.l $dff004,d0 ; wait
and.l #$0001ff00,d0 ; for
cmp.l #301<<8,d0 ; rasterline 301
bne.s Main
move.w #$f00,$dff180 ; start red cpu usage
bsr.s Movebar
move.w #$000,$dff180 ; end of red cpu usage
...
Here is the result of my t(h)inkering:
Code:
;*****************
;* Constants *
;*****************
OldOpenLibrary = -$198 ; -408
CloseLibrary = -$19E ; -414
DMASET= %1000001010000000
; -----axbcdefghij
; a: Blitter Nasty
; x: DMA below on
; b: Bitplane DMA (if this isn't set, sprites disappear!)
; c: Copper DMA
; d: Blitter DMA
; e: Sprite DMA
; f: Disk DMA
; g-j: Audio 3-0 DMA
SECTION CODESECTION,CODE ; This command will run the below code
; on FAST RAM (if enough) or CHIP RAM
START:
MOVE.L $4.W,A6 ; Exec pointer to A6
LEA.L GfxName(PC),A1 ; Set library pointer to A1
MOVEQ #0,D0
JSR OldOpenLibrary(A6) ; Open graphics.library
; write to D0 the offset
MOVE.L D0,A1 ; Use Base-pointer
MOVE.L $26(A1),oldcop ; Store copperlist system address,
; retrieved $26 from glib offset
JSR CloseLibrary(A6) ; Close graphics library
move.w $dff01c,oldint ; save INTENAR
move.w $dff002,olddma ; save DMACONR
move.w #$7fff,$dff09a ; disable INTENA = turn off OS
move.w #$7fff,$dff09c ; disable INTREQ
move.w #$7fff,$dff09c ; twice -> amiga4000 hw bug!
move.w #$7fff,$dff096 ; disable DMACON
move.w #DMASET,$dff096 ; enable necessary bits in DMACON
move.l #COPPERLIST,$dff080 ; COP1LC - Point to #COPPERLIST
move.w d0,$dff088 ; COPJMP1 - Start COP
Main:
move.l $dff004,d0 ; wait
and.l #$0001ff00,d0 ; for
cmp.l #301<<8,d0 ; rasterline 301
bne.s Main
move.w #$f00,$dff180 ; start red cpu usage
bsr.s Movebar
move.w #$000,$dff180 ; end of red cpu usage
.pause:
btst #10,$dff016 ; check for right mouse button
beq.s .pause ; pressed? pause!
btst #6,$bfe001 ; check for left mouse button
bne.s Main ; if not, repeat the above line
end:
move.w #$7fff,$dff096 ; clear DMACON
move.w olddma,d0
or.w #$8200,d0 ; set bits of DMACON state
move.w d0,$dff096 ; restore original DMACON
move.l oldcop,$dff080 ; restore original copperlist
move.w #0,$dff088 ; and activate it
move.w oldint,d0
or.w #$c000,d0 ; set bits of INTENAR state
move.w d0,$dff09a ; restore INTENA state = turn on OS
moveq #0,d0 ; nice clean
rts ; exit
GfxName:
dc.b "graphics.library",0,0
GfxBase: ; Dedicated to offset "graphics.library"
dc.l 0
oldcop: ; Dedicated to system COP address
dc.l 0
oldint:
dc.w 0 ; Dedicated to INTENA(R)
olddma:
dc.w 0 ; Dedicated to DMA
Direction_flag:
DC.B 0,0 ; direction flag
RbVPos:
; dc.b $26,$01 ; red bar h pos, v pos (always 0)
dc.b $01,$07
; $2d - VERT TOP LIMIT PAL
; $ff -
; $2c - VERT BOTTOM LIMIT PAL
Movebar:
tst.b Direction_flag
beq.s Movebar_down
bne.s Movebar_up
rts
Movebar_down:
addq.b #1,RbVPos
cmpi.b #$2c,RbVPos ; Bottom limit check
bne.s .draw
bchg #0,Direction_flag ; switch direction
.draw
bsr.s draw_bar
rts
draw_bar:
lea REDBAR, a0
cmpi.b #$ff, RbVPos
beq.s DrawBar_At_FF ; vpos at $ff
cmpi.b #$2c, RbVPos
bcs.s DrawBar_After_FF ; vpos from $00 to $2c
bhi.s DrawBar_Before_FF ; vpos from $2d to $ff
rts
Movebar_up:
subq.b #1,RbVPos
cmpi.b #$2d,RbVPos ; Upper limit check
bne.s .draw
bchg #0,Direction_flag ; switch direction
.draw
bsr.s draw_bar
rts
DrawBar_Before_FF:
move.w RbVPos,d0
move.w d0,(a0)+
move.w #$FFFE,(a0)+
move.l #$1800F00,(a0)+
add.w #$100,d0
move.w d0,(a0)+
move.w #$FFFE,(a0)+
move.l #$1800000,(a0)+
move.l #$ffdffffe,(a0)
rts
DrawBar_At_FF:
move.l #$FF07FFFE,(a0)+
move.l #$1800F00,(a0)+
move.l #$ffdffffe,(a0)+
move.l #$0007FFFE,(a0)+
move.l #$1800000,(a0)
rts
DrawBar_After_FF:
move.w RbVPos,d0
move.l #$ffdffffe,(a0)+
move.w d0,(a0)+
move.w #$FFFE,(a0)+
move.l #$1800F00,(a0)+
add.w #$100,d0
move.w d0,(a0)+
move.w #$FFFE,(a0)+
move.l #$1800000,(a0)
rts
SECTION GRAPHIC,DATA_C ; Section below MUST be executen on CHIP RAM,
; because COPPERLIST requires it
COPPERLIST:
dc.w $100, $200 ; BPLCON0 - THE BITLANE CONTROL
dc.w $180, $000 ; Color 0 - BLACK
dc.w $2c07,$fffe
dc.w $180, $0f0 ; Top screen green bar
dc.w $2d07,$fffe
dc.w $180, $000 ; Color 0 - BLACK
REDBAR:
dc.w 0,0
dc.w 0,0
dc.w 0,0
dc.w 0,0
dc.w 0,0
GREEN_BAR:
dc.w $2c07,$fffe
dc.w $180, $0f0 ; Bottom screen green bar
dc.w $2d07,$fffe
dc.w $180, $000 ; Color 0 - BLACK
END_COPPERLIST:
dc.w $FFFF,$FFFE ; END OF COPPERLIST
|