include "base.s" ********* CONST *********************************** W = 320 ; screen/bitplane width in memory (in px) H = 256 ; screen/bitplane height in memoty (in px) BPLS = 2 ; number of bitplanes LEFF = 320 ; effective screen width (DDFSTOP-DDFSTRT)*2+16 MODULOS = W/8*BPLS-LEFF/8 ; number of bytes to skip per line ; W/8-LEFF/8 if non IL ; W/8*BPLS-LEFF/8 if IL BPLSIZE = W/8 ; bytes taken by one bitplane ; W/8*H if non IL ; W/8 if IL LINESIZE = W/8*BPLS ; Lentght of image line in bytes ; W/8 if non IL ; W/8*BPLS if IL ********* INIT ************************************ run: lea CUSTOM,a6 ; move the base to a6 move.w #$838F,DMACON(a6) ; activate copper+BPL+audio ; in DMA channel move.l #copper,COP1LCH(a6) ; move new copper to copper register move.w #0,COPJMP1(a6) ; (H and L) & activate new copper lea copperbpl,a0 ; set the needed variables before move.l #screen,d0 ; branching to rotine to bsr pokebpls ; poke bpls memoory ptr to copper ; move.w #$FFFF,screen ; test line lea irq3,a0 ; replace irq3 with our own move.l a0,$6C.w ; interrupt routine that will be ; played each time the vetrical ; blank occurs move.w #$E028,INTENA(a6) ; allow VBL+CIAA+CIAB interrupts! jsr ptplay ********* MAIN ************************************ main: bsr waitVBI ; wait for the vertical blanc ; before updating the screen btst #6,$BFE001 ; is lmb prssed bne main ; 0 = pressed jsr ptstop rts ********* IRQ3 ************************************ irq3: movem.l a0-a6/d0-d7,-(sp) ; save on stack lea CUSTOM,a6 ; just to be sure move.w INTREQR(a6),d0 ; what did trigger the irq and.w #$0070,d0 ; mask VBI COP BTL interrupts ; and then acknowledge only ; the one that was triggered move.w d0,INTREQ(a6) ; is necessary to tell the system that move.w d0,INTREQ(a6) ; the interrupt is beign handeld move.w d0,INTREQ(a6) ; need to be 3 time, dur to a bug ; fro cpu > 68000 ; https://amycoders.org/tutorials/frametime.html add.w #1,col move.w col,$DFF180 ; do stuff movem.l (sp)+,a0-a6/d0-d7 ; retore state from stack rte ; retun with rtE not rtS! ********* ROUTINES *********************************** *** play ptotracker 2.3b zype mod files * incbin the module in chipmem * ptplay: sub.l a0,a0 ; a0 = autovector base = 0 moveq #1,d0 ; d0 = 1 for PAL jsr _mt_install ; setup cia timer lea module,a0 ; module address in a0 moveq #0,d0 ; start at pos d0 = 0 sub.l a1,a1 ; a0 = 0 for sample using sample adr jsr _mt_init ; init soing move.b #1,_mt_enable ; set to 1 to start song rts ptstop: move.b #0,_mt_enable ; set to 0 to pause song jsr _mt_end ; end song jsr _mt_remove ; cleanup cia and set to ; original state rts *** poke bipls addresses into copper * a0: bpls pointer in copperlist * d0: address of bpls in memory * pokebpls: movem.l d0/d7/a0,-(sp) ; save used registers on the stack moveq #BPLS-1,d7 ; loop counter = number of bpls loopbpl: move.w d0,6(a0) ; low word in BPL1PTL swap d0 ; swap low and high move.w d0,2(a0) ; high word into BPL1PTH swap d0 ; original address back add.l #BPLSIZE,d0 ; d0 points to bpl2 data add.l #8,a0 ; a0 points to next bplptr dbf d7,loopbpl movem.l (sp)+,d0/d7/a0 ; restore saved registers rts ********* DATA in FAST MEM ************************ col: dc.w 0 ********* DATA in CHIP MEM ************************ section copperlist,data_C copper: dc.w BPLCON0,BPLS<<12!$0200 ; set bitplane number dc.w DIWSTRT,$2C81 ; define display window size dc.w DIWSTOP,$F4C1 ; 320 X 200 pixels ; $F4C1 for 200 px high ; $2CC1 dor 256 px high dc.w DDFSTRT,$38 ; define display data fetch dc.w DDFSTOP,$D0 ; size to 320 pxels dc.w BPL1MOD,MODULOS ; skip xxx px per line dc.w BPL2MOD,MODULOS copperbpl: dc.w BPL1PTH,$0000 ; give denise the pointer dc.w BPL1PTL,$0000 ; to the first bitplane dc.w BPL2PTH,$0000 ; give denise the pointer dc.w BPL2PTL,$0000 ; to the second bitplane dc.w BPL3PTH,$0000 ; give denise the pointer dc.w BPL3PTL,$0000 ; to the third bitplane dc.w BPL4PTH,$0000 ; give denise the pointer dc.w BPL4PTL,$0000 ; to the fotrh bitplane dc.w BPL5PTH,$0000 ; give denise the pointer dc.w BPL5PTL,$0000 ; to the fifth bitplane dc.w BPL6PTH,$0000 ; give denise the pointer dc.w BPL6PTL,$0000 ; to the sixth bitplane palette: dc.w $0180,$0000 dc.w $0182,$0FFF dc.w $0184,$0F00 dc.w $0186,$000F dc.w $FFFF,$FFFE ; copper end screen: dcb.b W/8*H*BPLS,0 ; reserve the memory fir the given parameters ; and set them to color 0 module: incbin "mysong.mod" ********* DATA in FAST MEM ************************ * for pt player at the end of the file * else it fails * section ptplayer,data_F pt: include "ptplayer.s"