SECTION TutDemo,CODE JUMPPTR Start INCDIR "" INCLUDE "PhotonsMiniStartup/PhotonsMiniWrapper1.02!.S" INCLUDE "Blitter-Register-List.S" P61mode =1 ;Try other modes ONLY IF there are no Fxx commands >= 20. ;(f.ex., P61.new_ditty only works with P61mode=1) ;; --- options common to all P61modes --- usecode =-1 ;CHANGE! to the USE hexcode from P61con for a big ;CPU-time gain! (See module usecodes at end of source) ;Multiple songs, single playroutine? Just "OR" the ;usecodes together! ;...STOP! Have you changed it yet!? ;) ;You will LOSE RASTERTIME AND FEATURES if you don't. P61pl=usecode&$400000 split4 =0 ;Great time gain, but INCOMPATIBLE with F03, F02, and F01 ;speeds in the song! That's the ONLY reason it's default 0. ;So ==> PLEASE try split4=1 in ANY mode! ;Overrides splitchans to decrunch 1 chan/frame. ;See ;@@ note for P61_SetPosition. splitchans=1 ;#channels to be split off to be decrunched at "playtime frame" ;0=use normal "decrunch all channels in the same frame" ;Experiment to find minimum rastertime, but it should be 1 or 2 ;for 3-4 channels songs and 0 or 1 with less channels. visuctrs=0 ;enables visualizers in this example: P61_visuctr0..3.w ;containing #frames (#lev6ints if cia=1) elapsed since last ;instrument triggered. (0=triggered this frame.) ;Easy alternative to E8x or 1Fx sync commands. asmonereport =0 ;ONLY for printing a settings report on assembly. Use ;if you get problems (only works in AsmOne/AsmPro, tho) p61system=0 ;1=system-friendly. Use for DOS/Workbench programs. p61exec =0 ;0 if execbase is destroyed, such as in a trackmo. p61fade =0 ;enable channel volume fading from your demo channels=4 ;<4 for game sound effects in the higher channels. Incompatible ; with splitchans/split4. playflag=0 ;1=enable music on/off capability (at run-time). .If 0, you can ;still do this by just, you know, not calling P61_Music... ;It's a convenience function to "pause" music in CIA mode. p61bigjtab=0 ;1 to waste 480b and save max 56 cycles on 68000. opt020 =0 ;1=enable optimizations for 020+. Please be 68000 compatible! ;splitchans will already give MUCH bigger gains, and you can ;try the MAXOPTI mode. p61jump =0 ;0 to leave out P61_SetPosition (size gain) ;1 if you need to force-start at a given position fex in a game C =0 ;If you happen to have some $dffxxx value in a6, you can ;change this to $xxx to not have to load it before P61_Music. clraudxdat=0 ;enable smoother start of quiet sounds. probably not needed. optjmp =1 ;0=safety check for jump beyond end of song. Clear it if you ;play unknown P61 songs with erroneous Bxx/Dxx commands in them oscillo =0 ;1 to get a sample window (ptr, size) to read and display for ;oscilloscope type effects (beta, noshorts=1, pad instruments) ;IMPORTANT: see ;@@ note about chipmem dc.w buffer. quietstart=0 ;attempt to avoid the very first click in some modules ;IMPORTANT: see ;@@ note about chipmem dc.w buffer. use1Fx=0 ;Optional extra effect-sync trigger (*). If your module is free ;from E commands, and you add E8x to sync stuff, this will ;change the usecode to include a whole code block for all E ;commands. You can avoid this by only using 1Fx. (You can ;also use this as an extra sync command if E8x is not enough, ;of course.) ;(*) Slideup values>116 causes bugs in Protracker, and E8 causes extra-code ;for all E-commands, so I used this. It's only faster if your song contains 0 ;E-commands, so it's only useful to a few, I guess. Bit of cyclemania. :) ;Just like E8x, you will get the trigger after the P61_Music call, 1 frame ;BEFORE it's heard. This is good, because it allows double-buffered graphics ;or effects running at < 50 fps to show the trigger synced properly. ;; --- CIA mode options (default) --- ifeq P61mode-1 p61cia =1 ;call P61_Music on the CIA interrupt instead of every frame. lev6 =1 ;1=keep the timer B int at least for setting DMA. ;0="FBI mode" - ie. "Free the B-timer Interrupt". ;0 requires noshorts=1, p61system=0, and that YOU make sure DMA ;is set at 11 scanlines (700 usecs) after P61_Music is called. ;AsmOne will warn you if requirements are wrong. ;DMA bits will be poked in the address you pass in A4 to ;P61_init. (Update P61_DMApokeAddr during playing if necessary, ;for example if switching Coppers.) ;P61_Init will still save old timer B settings, and initialize ;it. P61_End will still restore timer B settings from P61_Init. ;So don't count on it 'across calls' to these routines. ;Using it after P61_Init and before P61_End is fine. noshorts=0 ;1 saves ~1 scanline, requires Lev6=0. Use if no instrument is ;shorter than ~300 bytes (or extend them to > 300 bytes). ;It does this by setting repeatpos/length the next frame ;instead of after a few scanlines,so incompatible with MAXOPTI dupedec =0 ;0=save 500 bytes and lose 26 cycles - I don't blame you. :) ;1=splitchans or split4 must be on. suppF01 =1 ;0 is incompatible with CIA mode. It moves ~100 cycles of ;next-pattern code to the less busy 2nd frame of a notestep. ;If you really need it, you have to experiment as the support ;is quite complex. Basically set it to 1 and try the various ;P61modes, if none work, change some settings. endc ;; --- VBLANK mode options --- ifeq P61mode-2 p61cia =0 lev6 =1 ;still set sound DMA with a simple interrupt. noshorts=0 ;try 1 (and pad short instruments if nec) for 1 scanline gain dupedec =0 suppF01 =P61pl ;if 1, split4=1 may cause sound errors. but try it anyway. :) endc ;; --- COPPER mode options --- ifeq P61mode-3 p61cia =0 lev6 =0 ;don't set sound DMA with an interrupt. ;(use the copper to set sound DMA 11 scanlines after P61_Music) noshorts=1 ;You must pad instruments < 300 bytes for this mode to work. dupedec =0 suppF01 =P61pl ;if 1, split4=1 may cause sound errors. but try it anyway. :) endc ;; --- MAXOPTI mode options --- ifeq P61mode-4 p61cia =0 lev6 =0 noshorts=1 ;You must pad instruments < 300 bytes for this mode to work. dupedec =1 suppF01 =P61pl ;if 1, split4=1 may cause sound errors. but try it anyway. :) endc ;; --- screen buffer dimensions --- w =352 h =256 bplsize =w*h/8 ScrBpl =w/8 ;; --- logo dimensions --- logow =192 logoh =67 logomargin =(320-logow)/2 logobpl =logow/8 logobwid =logobpl*3 ;; --- font dimensions --- fontw =288 fonth =100 fontbpls =3 FontBpl =fontw/8 plotY =110 plotX =w-32 logobgcol =$44f bgcol =$225 ******************** MACROS ******************** logocolors:macro dc.w $068e,$0adf,$0dff dc.w $09bf,$056d,$044b,$033a endm ******************** DEMO ******************** Demo: move.w #$87e0,$dff096 bsr Init move.l #copper,$dff080 ;; --- Call P61_Init --- movem.l d0-a6,-(sp) lea Module1,a0 sub.l a1,a1 sub.l a2,a2 moveq #0,d0 jsr P61_Init movem.l (sp)+,d0-a6 bsr Main movem.l d0-a6,-(sp) jsr P61_End movem.l (sp)+,d0-a6 rts ;go back to system friendly wrapper exit. ********** ROUTINES ********** Main: movem.l d0-a6,-(sp) ************************** MainLoop: move.w #$02a,d0 ;wait for EOFrame bsr.w WaitRaster btst #2,$dff016 bne.b .normb move.w #$02b,d0 ;wait for EOFrame bsr.w WaitRaster bra.b MainLoop .normb: ;-----frame loop start--- bsr BounceScroller add.b #1,Spr+1 ;; --- sine lookup for raster bar vert. pos. --- lea Sine,a0 move.w SineCtr,d6 move.w #$4d-6+37,d7 add.w (a0,d6.w),d7 addq.w #2,d6 cmp.w #SineEnd-Sine,d6 blt.s .nowrap2 moveq #0,d6 .nowrap2: move.w d6,SineCtr ;; --- in front or behind flag --- lea BarInFront,a2 ;default source address for RGB color values cmp.w #50*2,d6 blt.s .behind cmp.w #150*2,d6 bge.s .behind bra.s .cont .behind: lea BarBehind,a2 .cont: lea waitras1,a0 move d7,d0 moveq #6-1,d1 .l: move.b d0,(a0) add.w #1,d0 move.w (a2)+,d2 ;background color from list move.w d2,6(a0) move.w (a2)+,6+4*1(a0) move.w (a2)+,6+4*2(a0) move.w (a2)+,6+4*3(a0) move.w (a2)+,6+4*4(a0) move.w (a2)+,6+4*5(a0) move.w (a2)+,6+4*6(a0) move.w (a2)+,6+4*7(a0) add.w #4*9,a0 ;step to next. DBF d1,.l bsr Scrollit moveq #32,d2 move.b LastChar(PC),d0 cmp.b #'I',d0 bne.s .noi moveq #16,d2 .noi: move.w ScrollCtr(PC),d0 addq.w #4,d0 cmp.w d2,d0 blo.s .nowrap move.l ScrollPtr(PC),a0 cmp.l #ScrollTextWrap,a0 blo.s .noplot lea ScrollText(PC),a0 .noplot: bsr PlotChar ;preserves a0 addq.w #1,a0 move.l a0,ScrollPtr clr.w d0 .nowrap: move.w d0,ScrollCtr ;-----frame loop end--- btst #6,$bfe001 bne.w MainLoop ************************** movem.l (sp)+,d0-a6 rts row =288*3*20/8 col =4 PlotChar: ;a0=scrollptr movem.l d0-a6,-(sp) lea $dff000,a6 bsr BlitWait moveq #0,d0 move.b (a0)+,d0 ;ASCII value move.b d0,LastChar sub.w #32,d0 lea FontTbl(PC),a0 move.b (a0,d0.w),d0 divu #9,d0 ;row move.l d0,d1 swap d1 ;remainder (column) mulu #row,d0 mulu #col,d1 add.l d1,d0 ;offset into font bitmap add.l #Font,d0 move.l #$09f00000,BLTCON0(a6) move.l #$ffffffff,BLTAFWM(a6) move.l d0,BLTAPTH(a6) move.l #Screen+ScrBpl*3*plotY+plotX/8,BLTDPTH(a6) move.w #FontBpl-col,BLTAMOD(a6) move.w #ScrBpl-col,BLTDMOD(a6) move.w #20*3*64+2,BLTSIZE(a6) movem.l (sp)+,d0-a6 rts Scrollit: ;; --- scroll! --- bltoffs =plotY*ScrBpl*3 blth =20 bltw =w/16 bltskip =0 ;modulo brcorner=blth*ScrBpl*3-2 movem.l d0-a6,-(sp) lea $dff000,a6 bsr BlitWait move.l #$49f00002,BLTCON0(a6) move.l #$ffffffff,BLTAFWM(a6) move.l #Screen+bltoffs+brcorner,BLTAPTH(a6) move.l #Screen+bltoffs+brcorner,BLTDPTH(a6) move.w #bltskip,BLTAMOD(a6) move.w #bltskip,BLTDMOD(a6) move.w #blth*3*64+bltw,BLTSIZE(a6) movem.l (sp)+,d0-a6 rts Init: movem.l d0-a6,-(sp) moveq #0,d1 lea Screen,a1 move.w #bplsize*fontbpls/2-1,d0 .l: move.w #0,(a1)+ addq.w #1,d1 dbf d0,.l lea Logo,a0 ;ptr to first bitplane of logo lea CopBplP,a1 ;where to poke the bitplane pointer words. move #3-1,d0 .bpll: move.l a0,d1 swap d1 move.w d1,2(a1) ;hi word swap d1 move.w d1,6(a1) ;lo word addq #8,a1 ;point to next bpl to poke in copper lea LogoBpl(a0),a0 dbf d0,.bpll lea SprP,a1 lea Spr,a0 move.l a0,d1 swap d1 move.w d1,2(a1) swap d1 move.w d1,6(a1) lea NullSpr,a0 move.l a0,d1 moveq #7-1,d0 .sprpl: addq.w #8,a1 swap d1 move.w d1,2(a1) swap d1 move.w d1,6(a1) DBF d0,.sprpl lea FontE-7*2,a0 lea FontPalP+2,a1 moveq #7-1,d0 .coll: move.w (a0)+,(a1)+ addq.w #2,a1 DBF d0,.coll movem.l (sp)+,d0-a6 rts CopyB: ;d0,a0,a1=count,source,destination .l: move.b (a0)+,(a1)+ subq.l #1,d0 bne.s .l rts BlitWait: tst DMACONR(a6) ;for compatibility .waitblit: btst #6,DMACONR(a6) bne.s .waitblit rts BounceScroller: MOVEM.L D0-A6,-(SP) lea Screen,a0 ;ptr to first bitplane of font move.w BounceY(PC),d0 move.w BounceYaccel(PC),d1 add.w d1,BounceYspeed add.w BounceYspeed(PC),d0 bpl.s .nobounce move.w #32,BounceYspeed clr.w d0 .nobounce: move.w d0,BounceY lsr.w #3,d0 mulu #3*scrbpl,d0 add.l d0,a0 lea ScrBplP,a1 ;where to poke the bitplane pointer words. moveq #fontbpls-1,d0 .bpll2: move.l a0,d1 swap d1 move.w d1,2(a1) ;hi word swap d1 move.w d1,6(a1) ;lo word addq #8,a1 ;point to next bpl to poke in copper lea ScrBpl(a0),a0 dbf d0,.bpll2 MOVEM.L (SP)+,D0-A6 RTS even ********** PLAYROUTINE CODE ********** ;Note: if this is put in its own section (or compiled as separate binary), then ;jsr +P61_InitOffset,P61_MusicOffset,P61_EndOffset,P61_SetPositionOffset ;to call the routines. Playrtn: include "P6111/P6111-Play.i" ********** DATA ********** FontTbl: dc.b 43,38 blk.b 5,0 dc.b 42 blk.b 4,0 dc.b 37,40,36,41 dc.b 26,27,28,29,30,31,32,33,34,35 blk.b 5,0 dc.b 39,0 dc.b 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21 dc.b 22,23,24,25 EVEN ScrollPtr: dc.l ScrollText ScrollText: dc.b "JUST FOR THE RETRO FEELING OF IT! YOU DIG??" blk.b w/32,' ' ScrollTextWrap: LastChar:dc.b 0 EVEN ScrollCtr: dc.w 0 BounceY: dc.w 48*8 BounceYspeed: dc.w 0 BounceYaccel: dc.w -1 SineCtr: dc.w 0 gfxname: dc.b "graphics.library",0 EVEN Sine: INCBIN "Sine.37.200.w" SineEnd: SECTION TutData,DATA_C Spr: dc.w $ec40,$fc00 ;Vstart.b,Hstart/2.b,Vstop.b,%A0000SEH dc.w %0000011111000000,%0000000000000000 dc.w %0001111111110000,%0000000000000000 dc.w %0011111111111000,%0000000000000000 dc.w %0111111111111100,%0000000000000000 dc.w %0110011111001100,%0001100000110000 dc.w %1110011111001110,%0001100000110000 dc.w %1111111111111110,%0000000000000000 dc.w %1111111111111110,%0000000000000000 dc.w %1111111111111110,%0010000000001000 dc.w %1111111111111110,%0001100000110000 dc.w %0111111111111100,%0000011111000000 dc.w %0111111111111100,%0000000000000000 dc.w %0011111111111000,%0000000000000000 dc.w %0001111111110000,%0000000000000000 dc.w %0000011111000000,%0000000000000000 dc.w %0000000000000000,%0000000000000000 dc.w 0,0 NullSpr: dc.w $2a20,$2b00 dc.w 0,0 dc.w 0,0 BarBehind: dc.w $558 ;color00 value logocolors dc.w $99d ;color00... logocolors dc.w $fff logocolors dc.w $99d logocolors dc.w $558 logocolors dc.w logobgcol logocolors BarInFront: dc.w $558 dc.w $558 dc.w $558 dc.w $558 dc.w $558 dc.w $558 dc.w $558 dc.w $558 dc.w $99d dc.w $99d dc.w $99d dc.w $99d dc.w $99d dc.w $99d dc.w $99d dc.w $99d dc.w $fff dc.w $fff dc.w $fff dc.w $fff dc.w $fff dc.w $fff dc.w $fff dc.w $fff dc.w $99d dc.w $99d dc.w $99d dc.w $99d dc.w $99d dc.w $99d dc.w $99d dc.w $99d dc.w $558 dc.w $558 dc.w $558 dc.w $558 dc.w $558 dc.w $558 dc.w $558 dc.w $558 dc.w logobgcol logocolors Copper: dc.w $1fc,0 ;slow fetch mode, AGA compatibility dc.w $100,$0200 dc.b 0,$8e,$4c,$81 dc.b 0,$90,$2c,$c1 dc.w $92,$38+logomargin/2 dc.w $94,$d0-logomargin/2 dc.w $108,logobwid-logobpl dc.w $10a,logobwid-logobpl dc.w $102,0 dc.w $1a2,$cc5 dc.w $1a4,0 dc.w $1a6,$752 SprP: dc.w $120,0 dc.w $122,0 dc.w $124,0 dc.w $126,0 dc.w $128,0 dc.w $12a,0 dc.w $12c,0 dc.w $12e,0 dc.w $130,0 dc.w $132,0 dc.w $134,0 dc.w $136,0 dc.w $138,0 dc.w $13a,0 dc.w $13c,0 dc.w $13e,0 CopBplP: dc.w $e0,0 dc.w $e2,0 dc.w $e4,0 dc.w $e6,0 dc.w $e8,0 dc.w $ea,0 dc.w $0180,logobgcol dc.w $2c07,$fffe LogoPal: dc.w $0180,$044f,$0182,$068e,$0184,$0adf,$0186,$0dff dc.w $0188,$09bf,$018a,$056d,$018c,$044b,$018e,$033a dc.w $100,$3200 waitras1: dc.w $8007,$fffe dc.w $180,$558 dc.w $182,0 dc.w $184,0 dc.w $186,0 dc.w $188,0 dc.w $18a,0 dc.w $18c,0 dc.w $18e,0 waitras2: dc.w $8107,$fffe dc.w $180,$99d dc.w $182,0 dc.w $184,0 dc.w $186,0 dc.w $188,0 dc.w $18a,0 dc.w $18c,0 dc.w $18e,0 waitras3: dc.w $8207,$fffe dc.w $180,$fff dc.w $182,0 dc.w $184,0 dc.w $186,0 dc.w $188,0 dc.w $18a,0 dc.w $18c,0 dc.w $18e,0 waitras4: dc.w $8307,$fffe dc.w $180,$99d dc.w $182,0 dc.w $184,0 dc.w $186,0 dc.w $188,0 dc.w $18a,0 dc.w $18c,0 dc.w $18e,0 waitras5: dc.w $8407,$fffe dc.w $180,$558 dc.w $182,0 dc.w $184,0 dc.w $186,0 dc.w $188,0 dc.w $18a,0 dc.w $18c,0 dc.w $18e,0 waitras6: dc.w $8507,$fffe dc.w $180,logobgcol dc.w $182,0 dc.w $184,0 dc.w $186,0 dc.w $188,0 dc.w $18a,0 dc.w $18c,0 dc.w $18e,0 dc.w $9607,$fffe dc.w $100,$0200 dc.w $96bf,$fffe FontPalP: dc.w $0182,$0ddd,$0184,$0833,$0186,$0334 dc.w $0188,$0a88,$018a,$099a,$018c,$0556,$018e,$0633 ScrBplP: dc.w $e0,0 dc.w $e2,0 dc.w $e4,0 dc.w $e6,0 dc.w $e8,0 dc.w $ea,0 dc.w $108,ScrBpl*FontBpls-320/8 dc.w $10a,ScrBpl*Fontbpls-320/8 dc.w $92,$38 dc.w $94,$d0 dc.w $100,fontbpls*$1000+$200 dc.w $9707,$fffe dc.w $180,$44e dc.w $9807,$fffe dc.w $180,$44f dc.w $9907,$fffe dc.w $180,$44e dc.w $9d07,$fffe dc.w $180,$44d dc.w $9e07,$fffe dc.w $180,$44e dc.w $9f07,$fffe dc.w $180,$44d dc.w $a407,$fffe dc.w $180,$44c dc.w $a507,$fffe dc.w $180,$44d dc.w $a607,$fffe dc.w $180,$44c dc.w $ab07,$fffe dc.w $180,$43c dc.w $ac07,$fffe dc.w $180,$44c dc.w $ad07,$fffe dc.w $180,$43c dc.w $b207,$fffe dc.w $180,$33b dc.w $b307,$fffe dc.w $180,$43c dc.w $b407,$fffe dc.w $180,$33b dc.w $b907,$fffe dc.w $180,$33a dc.w $ba07,$fffe dc.w $180,$33b dc.w $bb07,$fffe dc.w $180,$33a dc.w $c007,$fffe dc.w $180,$339 dc.w $c107,$fffe dc.w $180,$33a dc.w $c207,$fffe dc.w $180,$339 dc.w $c707,$fffe dc.w $180,$329 dc.w $c807,$fffe dc.w $180,$339 dc.w $c907,$fffe dc.w $180,$329 dc.w $ce07,$fffe dc.w $180,$228 dc.w $cf07,$fffe dc.w $180,$329 dc.w $d007,$fffe dc.w $180,$228 dc.w $d507,$fffe dc.w $180,$227 dc.w $d607,$fffe dc.w $180,$228 dc.w $d707,$fffe dc.w $180,$227 dc.w $dc07,$fffe dc.w $180,$226 dc.w $dd07,$fffe dc.w $180,$227 dc.w $de07,$fffe dc.w $180,$226 dc.w $e307,$fffe dc.w $180,bgcol dc.w $e407,$fffe dc.w $180,$226 dc.w $e507,$fffe dc.w $180,bgcol dc.w $ffdf,$fffe ;; --- bottom plate start --- dc.w $0807,$fffe dc.w $180,$236 dc.w $0a07,$fffe dc.w $180,$247 dc.w $0b07,$fffe dc.w $180,$236 dc.w $0e07,$fffe dc.w $180,$258 dc.w $0f07,$fffe dc.w $180,$236 dc.w $1507,$fffe dc.w $180,$269 dc.w $1607,$fffe dc.w $180,$236 ;; --- mirror split --- dc.w $17df,$fffe dc.w $182,$0468 dc.w $184,$0235 dc.w $186,$0358 dc.w $188,$0689 dc.w $18a,$069a dc.w $18c,$07bc dc.w $18e,$08dd dc.w $108,(ScrBpl*FontBpls-320/8)-(ScrBpl*FontBpls*2) dc.w $10a,(ScrBpl*Fontbpls-320/8)-(ScrBpl*FontBpls*2) dc.w $2007,$fffe dc.w $180,$27a dc.w $182,$27a dc.w $184,$27a dc.w $186,$27a dc.w $188,$27a dc.w $18a,$27a dc.w $18c,$27a dc.w $18e,$27a dc.w $2107,$fffe dc.w $180,$236 dc.w $182,$0468 dc.w $184,$0235 dc.w $186,$0358 dc.w $188,$0689 dc.w $18a,$069a dc.w $18c,$07bc dc.w $18e,$08dd ;; --- bottom plate stop --- dc.w $2c07,$fffe dc.w $180,$38b dc.w $2d07,$fffe dc.w $180,$235 dc.w $2e07,$fffe dc.w $180,$247 dc.w $2f07,$fffe dc.w $180,$258 ;; --- bottom plate thickness --- dc.w $3007,$fffe dc.w $180,bgcol dc.w $ffff,$fffe CopperE: Font: INCBIN "media/FastCarFont.284x100x3" FontE: Logo: INCBIN "sky3.raw" LogoE: dcb.b logobwid*6,0 Module1: incbin "P61.new_ditty" ;usecode $c00b43b SECTION TutBSS,BSS_C Screen: ds.b bplsize*fontbpls END Bit Channel 1001 ABCD -> D 0 000 0 1 001 0 2 010 0 3 011 0 4 100 1 5 101 1 6 110 1 7 111 1 %11110000 =$f0