home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Amiga Demo Collection
/
TheAmigaDemoCollectionCDCUE.img
/
S
/
showtime05
/
Bonus
/
BScreen.lha
/
Blitterscreen
/
BScreen.i
< prev
next >
Wrap
Text File
|
1992-12-20
|
17KB
|
726 lines
*Routines:
*BScreenInit inizializza copperlist
*BScreenConvert converte lo schermo chunky su schermo fisico
*BScreenWait aspetta che il processo di conversione
* fatto partire da BScreenConvert o BScreenReStart finisca
*BScreenReStart rifa' la conversione usando gli schermi usati
* l'ultima volta da BScreenConvert
*mk2xY usata per inizializzare da BScreenInit
*c2bs usata per effettuare la conversione da BScreenConvert
;Costanti globali
BScreenPlaneW equ 320
BScreenPlaneH equ 256
BScreenPlaneSize equ (BScreenPlaneW/8)*BScreenPlaneH
BScreenChunkyW equ 160 ;Width of chunky screen
BScreenChunkyH equ 128 ;Height of chunky screen
BScreenChunkySize equ BScreenChunkyW*BScreenChunkyH
BScreenYStart equ $28
;**************
;Little macro to reduce code redundancies
BScreenStartMacro macro
move.w #1,bltbsy ;in case of calc faster than conversion
.waitblt\@
btst.b #6,$dff002
bne.s .waitblt\@
move.w #$8040,$dff09c ;activate blit intreq
endm
* -----------
;****** Global variables ******
bltpc dc.l 0 ;pointer to blitterinstructions to be done
bltbsy dc.w 0 ;this is 0 if all blitter-passes are done
*******************************
*Inizializza la copperlist (usare quella fatta apposta)
*in base alle variabili settate all'inizio del modulo
BScreenInit
movem.l d2-d7/a2-a6,-(sp)
*--- Copy the Common Coplist section to the two buffers (do not touch a1)
lea.l BScreenCoplist,a0
lea.l BScreenCoplist0,a2
lea.l BScreenCoplist1,a3
lea.l BScreenCoplist_End,a4
.coploop
COLOR0 $a00
move.w (a0),(a2)+ ;coplist 0
move.w (a0)+,(a3)+ ;coplist 1
COLOR0 $000
cmpa.l a0,a4 ;alla fine???
bne.s .coploop
move.l a2,.cop0free
move.l a3,.cop1free
*--- Initialize the coptable used in Int3
move.l #BScreenCoplist0,BScreenCopTable
move.l #BScreenCoplist1,BScreenCopTable+4
*--- fill the two copperlists
move.l #BScreenYStart,d2 ;ystart
move.l #BScreenChunkyH,d3 ;anz lines
move.l #BScreenPlaneW/8,d5 ;linesize
move.l #$01020010,d1 ;value for make bitplanes (first time)
move.l .cop0free(PC),a0
lea.l BScreenSpriteData0,a1
lea.l BScreenSpriteBuffer0,a2 ;buffer per gli sprites di copertura
bsr mk2xY ;effettua i precalcoli e fa partire il blitter
move.l #$fffffffe,(a0)+ ;istruzione di fine coplist
move.l #$01020021,d1 ;value for make bitplanes (first time)
move.l .cop1free(PC),a0
lea.l BScreenSpriteData1,a1
lea.l BScreenSpriteBuffer1,a2 ;buffer per gli sprites di copertura
bsr mk2xY ;effettua i precalcoli e fa partire il blitter
move.l #$fffffffe,(a0)+ ;istruzione di fine coplist
movem.l (sp)+,d2-d7/a2-a6
rts
.cop0free ds.l 1
.cop1free ds.l 1
;**************************
;Converte schermo chunky su schermo fisico in formato speciale
;bisogna aver chiamato prima BScreenInit e settato la routine
;di interrupt livello 3 predefinita
;IN:
; a0 ^Schermo chunky da convertire
; a1 ^Schermo planare su cui convertire inizializzato in BScreenInit
BScreenConvert
movem.l d0-d7/a0-a6,-(sp)
lea.l BScreenList,a6
lea.l BScreenBuffer,a2
lea.l BScreenScrambleBuffer,a3
move.l #BScreenChunkySize,d0
move.l #BScreenPlaneSize,d1
jsr c2bs ;hehehe =:)) adios copperscreen...
movem.l (sp)+,d0-d7/a0-a6
rts
******************************************
;Io la richiamo in BScreenInit con i parametri gia' a posto
*** 2xY: Make a special 2x2 or 2x1 screen ***
* NOTE: 2x2 or 2x1 depends on the modulo/doublescan-bit you chose
* in header coplist! Also make sure sprites are 64bit, highest
* pri, and chose the spritebank that got a dark color at offset 1
* (col 1,17,33....)
* IN: ALL BUFFERS IN CHIPMEM!!!
* ^spritebuffer: A2 (size: 312*4*2*8)
* ^Sprite data to use: A1
* ^Coplist: A0
* first value of shift for coplist: D1.l ($1020001 or $1020021)
* Ystart: D2.l number of lines (0-127): D3.w
* linesize: D5.w
mk2xY
bsr BScreen_mspr ;gen cover-sprites in (a2)+ and copmoves in (a0)+
bsr BScreen_mbpl ;gen planes ptr and lines shifters
rts
*
* installa i puntatori ai bitplanes e tutti i waits sfasati
* IN:
* a0 ^coplist
* d1.l first value of shift (#$01020010 first time,#$01020021 the second)
* d2.l YStart
* d3.w num of lines
* d5.w linesize
* OUT:
* a0 ^primo byte libero della coplist dopo i dati installati
*
BScreen_mbpl
movem.l d0-d7/a1-a6,-(sp)
ext.l d5
* Generate waits and shifts with $102
and.l #$ff,d2 ;maschera Y Start a modulo 256
sub.b #1,d2 ;sub #1: prev line
ror.l #8,d2 ; $YY000000
move.l #$00e1fffe,d4 ;last X-Wait valid for copper
or.l d2,d4 ; $YYe1fffe Wait for copper
*
move.w d3,d0 ;num of lines
subq.w #1,d0 ;ok for cicle
.mf256yanz
; move.l #$01020010,d7 ;costant : NOW d1 is used as input for this
move.w #2-1,d6 ;two times
.mf256do2
move.l d4,(a0)+
add.l #$01000000,d4 ;cwait
move.l d1,(a0)+
eor.l #$00000031,d1 ;horiz shift
; ^---- 3: 1 -> 2 -> 1 -> 2 ....
dbra d6,.mf256do2
dbra d0,.mf256yanz
movem.l (sp)+,d0-d7/a1-a6
rts
.mfloffs dc.l 0
*
* Sprites that mask out doubleplane-data-rubbish
* IN:
* a0 coplist to cover
* a1 ^ to sprite datas to insert (BScreenSpriteData0 the first time, BScreenSpriteData1 the second)
* a2 sprite buffer (COPLIST: FMODE=$F, $dff104=$003f!)
* OUT:
* a0 first byte clear over the filled coplist
* mksprites into sprbuf=(a2)+ and according coppermoves in (a0)+
*
BScreen_mspr
movem.l d0-d7/a1-a6,-(sp) ;no a0! coz *copl
move.l #$00968020,(a0)+ ;rehash sprites (for safety)
;allinea sprbuf a multiplo di 16
move.l a2,d0 ;indirizzo buffers per sprites
add.l #15,d0 ;15 bytes dopo
and.l #$fffffff0,d0 ;machero
move.l d0,a2 ;align
move.w #$0120,d1 ;spr0pth
move.w #8-1,d7 ;sprcnt, numero sprites usati
.mf2mkspr
* cmoves for sprptr in copl
move.l a2,d0 ;indirizzo buffer
move.w d1,(a0)+ ;registro in coplist ($120,$124,...)
addq.w #2,d1 ;hiptr -> loptr
swap d0 ;bit piu' significativi
move.w d0,(a0)+ ;in coplist.
swap d0 ;hiwd, bit meno significativi
move.w d1,(a0)+ ;reg incoplist ($122,$126,...)
addq.w #2,d1 ;next sprptr
move.w d0,(a0)+ ;indirizzo basso on coplist
* make sprbuf ;a1 ^sprdata a2 ^coplist
move.l (a1)+,(a2)+ ;ctl1 (vstart+hstart+null.w)
move.l #0,(a2)+ ;dummy for 64bit fetchmode
move.l (a1)+,(a2)+ ;ctl2 (vstop+ctrl+null.w)
move.l #0,(a2)+ ;dummy for 64bit fetchmode
move.l (a1)+,d2 ;plane data 0
move.l (a1)+,d3 ;plane data 1
move.l d2,d4
ror.l #1,d4 ;plane data 0 >> 1
move.l d3,d5
ror.l #1,d5 ;plane data 1 >> 1 (but!!! is ever 0!!!)
move.w #128-1,d6 ;number of lines to fill
.mf2mksprdat
move.l d2,(a2)+ ;plane data 0
move.l d2,(a2)+ ;again (a line is 64 bit wide)
move.l d3,(a2)+ ;plane data 1
move.l d3,(a2)+ ;again
;2nd line, now fill the shifted line
move.l d4,(a2)+ ;plane data 0
move.l d4,(a2)+
move.l d5,(a2)+ ;plane data 1
move.l d5,(a2)+ ;2nd plane
dbra d6,.mf2mksprdat ;fill all lines
move.l #$0,(a2)+ ;8 words nulle per fine sprite
move.l #$0,(a2)+
move.l #$0,(a2)+
move.l #$0,(a2)+
dbra d7,.mf2mkspr ;do all sprites
movem.l (sp)+,d0-d7/a1-a6 ;ohne a0! weil *copl
rts
*
* ctl 1, ctl 2, plane 0, plane 1 (to be lsr'd for 2nd line)
BScreenSpriteData0
dc.l $28400000,$a7020000,$aaaaaaaa,$00000000
dc.l $28600000,$a7020000,$aaaaaaaa,$00000000 ;1 & 2 nonattached, col 1 :)
dc.l $28800000,$a7020000,$aaaaaaaa,$00000000
dc.l $28800000,$a7820000,$00000000,$00000000
dc.l $28a00000,$a7020000,$aaaaaaaa,$00000000
dc.l $28a00000,$a7820000,$00000000,$00000000
dc.l $28c00000,$a7020000,$aaaaaaaa,$00000000
dc.l $28c00000,$a7820000,$00000000,$00000000
BScreenSpriteData1
dc.l $28400000,$a7020000,$55555555,$00000000
dc.l $28600000,$a7020000,$55555555,$00000000 ;1 & 2 nonattached, col 1 :)
dc.l $28800000,$a7020000,$55555555,$00000000
dc.l $28800000,$a7820000,$00000000,$00000000
dc.l $28a00000,$a7020000,$55555555,$00000000
dc.l $28a00000,$a7820000,$00000000,$00000000
dc.l $28c00000,$a7020000,$55555555,$00000000
dc.l $28c00000,$a7820000,$00000000,$00000000
**************************************
;Io la richiamo in BScreenConvert
*** non-scrambled chunky-to-planar ***
* not really c2p (!), destination is special 2x2 or 2x1 screen
*
* IN: ALL BUFFERS IN CHIPMEM *except blitterlist (a6)* !!!
*
* a3: scramble-buffer at size of chunky buffer
*
* other regs identical to sc2bs ! they are:
*
* a6: blitter-list buffer (size: less than 2k)
* a0: chunky buffer a1: screen a2: pass-buffer (half size of chunky buffer)
* d0.l: number of chunky pixels d1.l: planeoffset
c2bs
tst.w bltbsy
bne.s c2bs ;for the very unlikely case your mapping-
;engine renders faster than blitterc2p ;)
move.l a6,bltpc ;handler starts at bltpc
movem.l d0-d1/a0-a3,-(sp)
move.l a3,a4 ;well....
*** init values
move.l #$04000096,(a6)+
move.l #$80400096,(a6)+
move.l #$ffff0044,(a6)+
move.l #$ffff0046,(a6)+
*** scrambling passes
;subpass 1
lea (a0),a3
move.l a3,(a6)+
move.w #$004c,-2(a6) ;B
move.w a3,(a6)+
move.w #$004e,(a6)+
lea 4(a0),a3
move.l a3,(a6)+
move.w #$0050,-2(a6) ;A
move.w a3,(a6)+
move.w #$0052,(a6)+
lea (a4),a3
move.l a3,(a6)+
move.w #$0054,-2(a6) ;D
move.w a3,(a6)+
move.w #$0056,(a6)+
move.l #$8de40040,(a6)+
move.l #$00000042,(a6)+
move.l #$00ff0070,(a6)+ ;cdat
move.l #$00060064,(a6)+
move.l #$00060062,(a6)+ ;a/b mod
move.l #$00060066,(a6)+ ;d mod
move.l d0,d6
lsr.l #3,d6 ;1/4 of scr, words => /8
move.w d6,(a6)+
move.w #$5C,(a6)+ ;SIZV
move.l #$0001005E,(a6)+ ;SIZH+start
;subpass2
lea 2(a0),a3
move.l a3,(a6)+
move.w #$004c,-2(a6) ;B
move.w a3,(a6)+
move.w #$004e,(a6)+
lea 6(a0),a3
move.l a3,(a6)+
move.w #$0050,-2(a6) ;A
move.w a3,(a6)+
move.w #$0052,(a6)+
lea 2(a4),a3
move.l a3,(a6)+
move.w #$0054,-2(a6) ;D
move.w a3,(a6)+
move.w #$0056,(a6)+
move.l #$8de40040,(a6)+
move.l #$00000042,(a6)+
move.l #$00ff0070,(a6)+ ;cdat
move.l #$00060064,(a6)+
move.l #$00060062,(a6)+ ;a/b mod
move.l #$00060066,(a6)+ ;d mod
move.l d0,d6
lsr.l #3,d6 ;1/4 of scr, words => /8
move.w d6,(a6)+
move.w #$5C,(a6)+ ;SIZV
move.l #$0001005E,(a6)+ ;SIZH+start
;subpass 3
lea -4(a0,d0.l),a3
move.l a3,(a6)+
move.w #$004c,-2(a6) ;B
move.w a3,(a6)+
move.w #$004e,(a6)+
lea -8(a0,d0.l),a3
move.l a3,(a6)+
move.w #$0050,-2(a6) ;A
move.w a3,(a6)+
move.w #$0052,(a6)+
lea -4(a4,d0.l),a3
move.l a3,(a6)+
move.w #$0054,-2(a6) ;D
move.w a3,(a6)+
move.w #$0056,(a6)+
move.l #$8de40040,(a6)+
move.l #$00020042,(a6)+
move.l #$ff000070,(a6)+ ;cdat
move.l #$00060064,(a6)+
move.l #$00060062,(a6)+ ;a/b mod
move.l #$00060066,(a6)+ ;d mod
move.l d0,d6
lsr.l #3,d6 ;1/4 of scr, words => /8
move.w d6,(a6)+
move.w #$5C,(a6)+ ;SIZV
move.l #$0001005E,(a6)+ ;SIZH+start
;subpass 4
lea -2(a0,d0.l),a3
move.l a3,(a6)+
move.w #$004c,-2(a6) ;B
move.w a3,(a6)+
move.w #$004e,(a6)+
lea -6(a0,d0.l),a3
move.l a3,(a6)+
move.w #$0050,-2(a6) ;A
move.w a3,(a6)+
move.w #$0052,(a6)+
lea -2(a4,d0.l),a3
move.l a3,(a6)+
move.w #$0054,-2(a6) ;D
move.w a3,(a6)+
move.w #$0056,(a6)+
move.l #$8de40040,(a6)+
move.l #$00020042,(a6)+
move.l #$ff000070,(a6)+ ;cdat
move.l #$00060064,(a6)+
move.l #$00060062,(a6)+ ;a/b mod
move.l #$00060066,(a6)+ ;d mod
move.l d0,d6
lsr.l #3,d6 ;1/4 of scr, words => /8
move.w d6,(a6)+
move.w #$5C,(a6)+ ;SIZV
move.l #$0001005E,(a6)+ ;SIZH+start
***
movem.l (sp)+,d0-d1/a0-a3
move.l a3,a0 ;scrambled data is now there
bra sc2bsenter
*** scrambled chunky-to-planar =:) ***
sc2bs
tst.w bltbsy
bne sc2bs
move.l a6,bltpc
sc2bsenter:
* IN: IN: ALL BUFFERS IN CHIPMEM *except blitterlist (a6)* !!!
*
* a6: blitter-list buffer (size: less than 2k)
* a0: chunky buffer a1: screen a2: pass-buffer (half size of chunky buffer)
* d0.l: number of chunky pixels d1.l: planeoffset
*** init values
move.l #$04000096,(a6)+
move.l #$80400096,(a6)+
move.l #$ffff0044,(a6)+
move.l #$ffff0046,(a6)+
;offsets to end of buffers for blitter DESCing
move.l d0,d6 ;len of chscr
move.l d6,d5
lsr.l #1,d5 ;len of buf2
move.l d6,d4
lsr.l #2,d4 ;len of 1 plane = 320*128/8, ok.
*** Pass 1, planes 7654
lea (a0),a3
move.l a3,(a6)+
move.w #$004c,-2(a6) ;B
move.w a3,(a6)+
move.w #$004e,(a6)+
lea 2(a0),a3
move.l a3,(a6)+
move.w #$0050,-2(a6) ;A
move.w a3,(a6)+
move.w #$0052,(a6)+
move.l a2,(a6)+
move.w #$0054,-2(a6) ;D
move.w a2,(a6)+
move.w #$0056,(a6)+
move.l #$4de40040,(a6)+
move.l #$00000042,(a6)+
move.l #$0f0f0070,(a6)+ ;cdat
move.l #$00020064,(a6)+
move.l #$00020062,(a6)+ ;a/b mod
move.l #$00000066,(a6)+ ;d mod
move.w d4,(a6)+ ;d4: nr_pix/4 (words!)
move.w #$5C,(a6)+ ;SIZV
move.l #$0001005E,(a6)+ ;SIZH+start
*** Pass 2, planes 76
lea (a2),a3
move.l a3,(a6)+
move.w #$004c,-2(a6) ;B
move.w a3,(a6)+
move.w #$004e,(a6)+
lea 2(a2),a3
move.l a3,(a6)+
move.w #$0050,-2(a6) ;A
move.w a3,(a6)+
move.w #$0052,(a6)+
lea (a1),a3
add.w d1,a3
add.w d1,a3
add.w d1,a3 ;4th "doubleplane"
move.l a3,(a6)+
move.w #$0054,-2(a6) ;D
move.w a3,(a6)+
move.w #$0056,(a6)+
move.l #$2de40040,(a6)+
move.l #$00000042,(a6)+
move.l #$33330070,(a6)+ ;cdat
move.l #$00020064,(a6)+
move.l #$00020062,(a6)+ ;a/b mod
move.l #$00000066,(a6)+ ;d mod
move.w d4,d0
lsr.w #1,d0
move.w d0,(a6)+ ;d4: nr_pix/8 (words!)
move.w #$5C,(a6)+ ;SIZV
move.l #$0001005E,(a6)+ ;SIZH+start
*** Pass 2, planes 54
lea -2(a2,d5.l),a3
move.l a3,(a6)+
move.w #$004c,-2(a6) ;B
move.w a3,(a6)+
move.w #$004e,(a6)+
lea -4(a2,d5.l),a3
move.l a3,(a6)+
move.w #$0050,-2(a6) ;A
move.w a3,(a6)+
move.w #$0052,(a6)+
lea -2(a1,d4.l),a3
add.w d1,a3
add.w d1,a3 ;3rd "doubleplane"
move.l a3,(a6)+
move.w #$0054,-2(a6) ;D
move.w a3,(a6)+
move.w #$0056,(a6)+
move.l #$2de40040,(a6)+
move.l #$00020042,(a6)+ ;DESC
move.l #$cccc0070,(a6)+ ;cdat
move.l #$00020064,(a6)+
move.l #$00020062,(a6)+ ;a/b mod
move.l #$00000066,(a6)+ ;d mod
move.w d4,d0
lsr.w #1,d0
move.w d0,(a6)+ ;d4: nr_pix/8 (words!)
move.w #$5C,(a6)+ ;SIZV
move.l #$0001005E,(a6)+ ;SIZH+start
*** Pass 1, planes 3210
lea -2(a0,d6.l),a3
move.l a3,(a6)+
move.w #$004c,-2(a6) ;B
move.w a3,(a6)+
move.w #$004e,(a6)+
lea -4(a0,d6.l),a3
move.l a3,(a6)+
move.w #$0050,-2(a6) ;A
move.w a3,(a6)+
move.w #$0052,(a6)+
lea -2(a2,d5.l),a3
move.l a3,(a6)+
move.w #$0054,-2(a6) ;D
move.w a3,(a6)+
move.w #$0056,(a6)+
move.l #$4de40040,(a6)+
move.l #$00020042,(a6)+
move.l #$f0f00070,(a6)+ ;cdat
move.l #$00020064,(a6)+
move.l #$00020062,(a6)+ ;a/b mod
move.l #$00000066,(a6)+ ;d mod
move.w d4,(a6)+ ;d4: nr_pix/4 (words!)
move.w #$5C,(a6)+ ;SIZV
move.l #$0001005E,(a6)+ ;SIZH+start
*** Pass 2, planes 32
lea (a2),a3
move.l a3,(a6)+
move.w #$004c,-2(a6) ;B
move.w a3,(a6)+
move.w #$004e,(a6)+
lea 2(a2),a3
move.l a3,(a6)+
move.w #$0050,-2(a6) ;A
move.w a3,(a6)+
move.w #$0052,(a6)+
lea (a1),a3
add.w d1,a3 ;2nd "doubleplane"
move.l a3,(a6)+
move.w #$0054,-2(a6) ;D
move.w a3,(a6)+
move.w #$0056,(a6)+
move.l #$2de40040,(a6)+
move.l #$00000042,(a6)+
move.l #$33330070,(a6)+ ;cdat
move.l #$00020064,(a6)+
move.l #$00020062,(a6)+ ;a/b mod
move.l #$00000066,(a6)+ ;d mod
move.w d4,d0
lsr.w #1,d0
move.w d0,(a6)+ ;d4: nr_pix/8 (words!)
move.w #$5C,(a6)+ ;SIZV
move.l #$0001005E,(a6)+ ;SIZH+start
*** Pass 2, planes 10
lea -2(a2,d5.l),a3
move.l a3,(a6)+
move.w #$004c,-2(a6) ;B
move.w a3,(a6)+
move.w #$004e,(a6)+
lea -4(a2,d5.l),a3
move.l a3,(a6)+
move.w #$0050,-2(a6) ;A
move.w a3,(a6)+
move.w #$0052,(a6)+
lea -2(a1,d4.l),a3
;1st "doubleplane"
move.l a3,(a6)+
move.w #$0054,-2(a6) ;D
move.w a3,(a6)+
move.w #$0056,(a6)+
move.l #$2de40040,(a6)+
move.l #$00020042,(a6)+ ;DESC
move.l #$cccc0070,(a6)+ ;cdat
move.l #$00020064,(a6)+
move.l #$00020062,(a6)+ ;a/b mod
move.l #$00000066,(a6)+ ;d mod
move.w d4,d0
lsr.w #1,d0
move.w d0,(a6)+ ;d4: nr_pix/8 (words!)
move.w #$5C,(a6)+ ;SIZV
move.l #$0001005E,(a6)+ ;SIZH+start
*** end of initblit
move.l #0,(a6)+
BScreenStartMacro
rts
;******************************
;Wait for previous phase of blitscreen to finish
BScreenWait
.loop
tst.w bltbsy
bne.s .loop
rts
;******************************
;Start the conversion inizialized with c2bs another time
;with the same buffers
BScreenReStart
move.l #BScreenList,bltpc
BScreenStartMacro
rts