diff --git a/source/blend/blend.asm b/source/blend/blend.asm index 7443b6f..8ab8cc4 100644 --- a/source/blend/blend.asm +++ b/source/blend/blend.asm @@ -93,7 +93,7 @@ DEBUG_DETAIL SET 10 NEWAGE_DEBUG = 1 - include "../framework/framework.i" + include "framework.i" ; Chip memory use: @@ -341,7 +341,7 @@ NEWAGE_DEBUG = 1 LABEL pd_SIZEOF IFND FW_DEMO_PART - include "../framework/framework.asm" + include "framework.asm" ENDC entrypoint: @@ -369,7 +369,7 @@ entrypoint: CALLFW SetCopper IF 1 - PUTMSG 10,<"%d: Waiting for first pic (%d music frames)">,fw_FrameCounterLong(a6),fw_MusicFrameCount-2(a6) + PUTMSG 10,<"%d: Waiting for first pic (%d music frames)">,fw_FrameCounter-2(a6),fw_MusicFrameCount-2(a6) .wait CALLFW VSyncWithTask @@ -382,7 +382,7 @@ entrypoint: lea pd_SpeedCodeTask(a6),a1 CALLFW AddTask - PUTMSG 10,<"%d: Waiting for third pic (%d music frames)">,fw_FrameCounterLong(a6),fw_MusicFrameCount-2(a6) + PUTMSG 10,<"%d: Waiting for third pic (%d music frames)">,fw_FrameCounter-2(a6),fw_MusicFrameCount-2(a6) .wait2 CALLFW VSyncWithTask @@ -557,7 +557,7 @@ bln_init: CALLFW TrackloaderDiskMotorOff ENDC - PUTMSG 10,<"%d: Prep task done!">,fw_FrameCounterLong(a6) + PUTMSG 10,<"%d: Prep task done!">,fw_FrameCounter-2(a6) rts ;-------------------------------------------------------------------- @@ -812,7 +812,7 @@ bln_clear_clip_buffers: ;-------------------------------------------------------------------- bln_intro: - PUTMSG 10,<"%d: Intro (%d music frames)">,fw_FrameCounterLong(a6),fw_MusicFrameCount-2(a6) + PUTMSG 10,<"%d: Intro (%d music frames)">,fw_FrameCounter-2(a6),fw_MusicFrameCount-2(a6) CALLFW SetBlitterQueueSingleFrame bsr bln_clear_db_buffers @@ -838,7 +838,7 @@ bln_intro: bsr bln_handle_parts move.w d7,pd_SequenceBlocksLeft(a6) bne.s .noallownext - PUTMSG 30,<"%d: Sequence done! (%d music frames)">,fw_FrameCounterLong(a6),fw_MusicFrameCount-2(a6) + PUTMSG 30,<"%d: Sequence done! (%d music frames)">,fw_FrameCounter-2(a6),fw_MusicFrameCount-2(a6) move.w #3,pd_AllowLoadLastImage(a6) .noallownext @@ -874,14 +874,14 @@ bln_intro: cmp.w #2,pd_TCPicsDone(a6) bge.s .nowait - PUTMSG 10,<"%d: Waiting for 2nd pic (%d music frames)">,fw_FrameCounterLong(a6),fw_MusicFrameCount-2(a6) + PUTMSG 10,<"%d: Waiting for 2nd pic (%d music frames)">,fw_FrameCounter-2(a6),fw_MusicFrameCount-2(a6) .wait CALLFW VSyncWithTask cmp.w #2,pd_TCPicsDone(a6) blt.s .wait .nowait - PUTMSG 10,<"%d: Intro B sequence (%d music frames)">,fw_FrameCounterLong(a6),fw_MusicFrameCount-2(a6) + PUTMSG 10,<"%d: Intro B sequence (%d music frames)">,fw_FrameCounter-2(a6),fw_MusicFrameCount-2(a6) lea bln_b_part_sequence(pc),a0 bsr bln_load_part_sequences @@ -890,7 +890,7 @@ bln_intro: ;-------------------------------------------------------------------- bln_bars: - PUTMSG 10,<"%d: Bars (%d music frames)">,fw_FrameCounterLong(a6),fw_MusicFrameCount-2(a6) + PUTMSG 10,<"%d: Bars (%d music frames)">,fw_FrameCounter-2(a6),fw_MusicFrameCount-2(a6) CALLFW SetBlitterQueueSingleFrame @@ -927,7 +927,7 @@ bln_bars: ;-------------------------------------------------------------------- bln_holes: - PUTMSG 10,<"%d: Holes (%d music frames)">,fw_FrameCounterLong(a6),fw_MusicFrameCount-2(a6) + PUTMSG 10,<"%d: Holes (%d music frames)">,fw_FrameCounter-2(a6),fw_MusicFrameCount-2(a6) CALLFW SetBlitterQueueSingleFrame @@ -959,7 +959,7 @@ bln_holes: cmp.w #5040+32*6,fw_MusicFrameCount(a6) blt.s .wait - PUTMSG 10,<"%d: Starting holes (%d music frames)">,fw_FrameCounterLong(a6),fw_MusicFrameCount-2(a6) + PUTMSG 10,<"%d: Starting holes (%d music frames)">,fw_FrameCounter-2(a6),fw_MusicFrameCount-2(a6) BLTWAIT move.w fw_FrameCounter(a6),pd_OldFrameCount(a6) @@ -1026,7 +1026,7 @@ bln_holes: rts .loadgreetings - PUTMSG 10,<"%d: Allow Loading of Image 5 (%d music frames)">,fw_FrameCounterLong(a6),fw_MusicFrameCount-2(a6) + PUTMSG 10,<"%d: Allow Loading of Image 5 (%d music frames)">,fw_FrameCounter-2(a6),fw_MusicFrameCount-2(a6) move.w #5,pd_AllowLoadLastImage(a6) lea pd_CirclePots(a6),a4 lea bln_circle_greetings_scripts(pc),a0 @@ -1045,7 +1045,7 @@ bln_holes: ;-------------------------------------------------------------------- bln_greetings: - PUTMSG 10,<"%d: Greetings (%d music frames)">,fw_FrameCounterLong(a6),fw_MusicFrameCount-2(a6) + PUTMSG 10,<"%d: Greetings (%d music frames)">,fw_FrameCounter-2(a6),fw_MusicFrameCount-2(a6) IFD FW_DEMO_PART lea .loader(pc),a0 @@ -1084,7 +1084,7 @@ bln_greetings: move.l pd_TrueColorImage2(a6),a0 move.l pd_EndLogoBuffer(a6),a1 CALLFW DecompressZX0 - PUTMSG 10,<"%d: Endlogo loaded/decompressed (%d music frames)">,fw_FrameCounterLong(a6),fw_MusicFrameCount-2(a6) + PUTMSG 10,<"%d: Endlogo loaded/decompressed (%d music frames)">,fw_FrameCounter-2(a6),fw_MusicFrameCount-2(a6) rts .endlogofile @@ -1219,7 +1219,7 @@ bln_update_copper_list_pointers: ;-------------------------------------------------------------------- bln_prepare_circle_speedcode: - PUTMSG 10,<"%d: Preparing circle smc">,fw_FrameCounterLong(a6) + PUTMSG 10,<"%d: Preparing circle smc">,fw_FrameCounter-2(a6) lea bln_circleinfo,a4 move.l pd_CircleSpeedcodeBuffer(a6),a2 move.l a2,a3 @@ -1273,7 +1273,7 @@ bln_prepare_circle_speedcode: .done suba.l pd_CircleSpeedcodeBuffer(a6),a2 add.l a2,a2 - PUTMSG 10,<"%d: Done %ld bytes">,fw_FrameCounterLong(a6),a2 + PUTMSG 10,<"%d: Done %ld bytes">,fw_FrameCounter-2(a6),a2 CALLFW FlushCaches rts @@ -1679,7 +1679,7 @@ bln_fade_step_down: ;-------------------------------------------------------------------- bln_prepare_circle_masks: - PUTMSG 10,<"%d: Preparing circle masks">,fw_FrameCounterLong(a6) + PUTMSG 10,<"%d: Preparing circle masks">,fw_FrameCounter-2(a6) bsr bln_clear_clip_buffers BLTWAIT @@ -1759,7 +1759,7 @@ bln_prepare_circle_masks: bra.s .rloop .done suba.l pd_CircleMasksBuffer(a6),a3 - PUTMSG 10,<"%d: Done %ld bytes">,fw_FrameCounterLong(a6),a3 + PUTMSG 10,<"%d: Done %ld bytes">,fw_FrameCounter-2(a6),a3 rts ;-------------------------------------------------------------------- @@ -5003,7 +5003,7 @@ bln_greeting_line_update: bra.s bln_update_circle_pot_info .noupdate rts -.kill PUTMSG 10,<"%d: Greeting killed (%d music frames)">,fw_FrameCounterLong(a6),fw_MusicFrameCount-2(a6) +.kill PUTMSG 10,<"%d: Greeting killed (%d music frames)">,fw_FrameCounter-2(a6),fw_MusicFrameCount-2(a6) subq.w #1,pd_GreetingCount(a6) moveq.l #0,d0 move.w d0,cp_Radius(a4) @@ -5017,7 +5017,7 @@ bln_load_circle_nop: rts bln_load_circle_eye_1: - PUTMSG 10,<"%d: Load circle eye 1 (%d music frames)">,fw_FrameCounterLong(a6),fw_MusicFrameCount-2(a6) + PUTMSG 10,<"%d: Load circle eye 1 (%d music frames)">,fw_FrameCounter-2(a6),fw_MusicFrameCount-2(a6) move.w #112,cp_CenterPosX(a4) move.w #51,cp_CenterPosY(a4) moveq.l #0,d0 @@ -5043,7 +5043,7 @@ bln_load_circle_eye_1: rts bln_load_circle_pos_eye_1_sunset: - PUTMSG 10,<"%d: Load circle eye sunset 2 (%d music frames)">,fw_FrameCounterLong(a6),fw_MusicFrameCount-2(a6) + PUTMSG 10,<"%d: Load circle eye sunset 2 (%d music frames)">,fw_FrameCounter-2(a6),fw_MusicFrameCount-2(a6) move.w #112,cp_CenterPosX(a4) move.w #62,cp_CenterPosY(a4) moveq.l #0,d0 @@ -5070,7 +5070,7 @@ bln_load_circle_pos_eye_1_sunset: rts bln_load_circle_pos_eye_2: - PUTMSG 10,<"%d: Load circle eye 2 (%d music frames)">,fw_FrameCounterLong(a6),fw_MusicFrameCount-2(a6) + PUTMSG 10,<"%d: Load circle eye 2 (%d music frames)">,fw_FrameCounter-2(a6),fw_MusicFrameCount-2(a6) move.w #240,cp_CenterPosX(a4) move.w #126,cp_CenterPosY(a4) moveq.l #0,d0 @@ -5096,7 +5096,7 @@ bln_load_circle_pos_eye_2: rts bln_load_circle_pos_eye_2_skin: - PUTMSG 10,<"%d: Load circle eye skin (%d music frames)">,fw_FrameCounterLong(a6),fw_MusicFrameCount-2(a6) + PUTMSG 10,<"%d: Load circle eye skin (%d music frames)">,fw_FrameCounter-2(a6),fw_MusicFrameCount-2(a6) move.w #240,cp_CenterPosX(a4) move.w #117,cp_CenterPosY(a4) moveq.l #0,d0 @@ -5123,7 +5123,7 @@ bln_load_circle_pos_eye_2_skin: rts bln_load_circle_cham_bg_1: - PUTMSG 10,<"%d: Load cham bg 1 (%d music frames)">,fw_FrameCounterLong(a6),fw_MusicFrameCount-2(a6) + PUTMSG 10,<"%d: Load cham bg 1 (%d music frames)">,fw_FrameCounter-2(a6),fw_MusicFrameCount-2(a6) move.w #272,cp_CenterPosX(a4) move.w #34,cp_CenterPosY(a4) moveq.l #0,d0 @@ -5149,7 +5149,7 @@ bln_load_circle_cham_bg_1: rts bln_load_circle_greets_bg_1: - PUTMSG 10,<"%d: Load greets bg 1 (%d music frames)">,fw_FrameCounterLong(a6),fw_MusicFrameCount-2(a6) + PUTMSG 10,<"%d: Load greets bg 1 (%d music frames)">,fw_FrameCounter-2(a6),fw_MusicFrameCount-2(a6) move.w #176,cp_CenterPosX(a4) move.w #75,cp_CenterPosY(a4) moveq.l #0,d0 @@ -5176,7 +5176,7 @@ bln_load_circle_greets_bg_1: bln_load_circle_greets_bg_2: - PUTMSG 10,<"%d: Load greets bg 2 (%d music frames)">,fw_FrameCounterLong(a6),fw_MusicFrameCount-2(a6) + PUTMSG 10,<"%d: Load greets bg 2 (%d music frames)">,fw_FrameCounter-2(a6),fw_MusicFrameCount-2(a6) move.w #128,cp_CenterPosX(a4) move.w #149,cp_CenterPosY(a4) moveq.l #0,d0 @@ -5202,7 +5202,7 @@ bln_load_circle_greets_bg_2: rts bln_load_circle_greets_bg_3: - PUTMSG 10,<"%d: Load greets bg 3 (%d music frames)">,fw_FrameCounterLong(a6),fw_MusicFrameCount-2(a6) + PUTMSG 10,<"%d: Load greets bg 3 (%d music frames)">,fw_FrameCounter-2(a6),fw_MusicFrameCount-2(a6) move.w #80,cp_CenterPosX(a4) move.w #32,cp_CenterPosY(a4) moveq.l #0,d0 @@ -5228,7 +5228,7 @@ bln_load_circle_greets_bg_3: rts bln_load_circle_greets_bg_4: - PUTMSG 10,<"%d: Load greets bg 4 (%d music frames)">,fw_FrameCounterLong(a6),fw_MusicFrameCount-2(a6) + PUTMSG 10,<"%d: Load greets bg 4 (%d music frames)">,fw_FrameCounter-2(a6),fw_MusicFrameCount-2(a6) move.w #208,cp_CenterPosX(a4) move.w #28,cp_CenterPosY(a4) moveq.l #0,d0 @@ -5254,7 +5254,7 @@ bln_load_circle_greets_bg_4: rts bln_load_circle_greets_bg_5: - PUTMSG 10,<"%d: Load greets bg 5 (%d music frames)">,fw_FrameCounterLong(a6),fw_MusicFrameCount-2(a6) + PUTMSG 10,<"%d: Load greets bg 5 (%d music frames)">,fw_FrameCounter-2(a6),fw_MusicFrameCount-2(a6) move.w #48,cp_CenterPosX(a4) move.w #118,cp_CenterPosY(a4) moveq.l #0,d0 @@ -5289,7 +5289,7 @@ bln_load_next_greeting: beq.s .reallykill move.w (a0)+,d1 move.w (a0)+,d2 - PUTMSG 10,<"%d: Next greeting at %d,%d Pair: %d">,fw_FrameCounterLong(a6),d0,d1,d2 + PUTMSG 10,<"%d: Next greeting at %d,%d Pair: %d">,fw_FrameCounter-2(a6),d0,d1,d2 move.w d0,cp_CenterPosX(a4) move.w d1,cp_CenterPosY(a4) move.w d2,cp_Pair(a4) @@ -5303,7 +5303,7 @@ bln_load_next_greeting: .retry move.l pd_GreetingLinePtr(a6),a0 movem.w (a0)+,d0-d4 - PUTMSG 10,<"%d: Greeting from %d,%d to %d,%d, shift %d">,fw_FrameCounterLong(a6),d0,d1,d2,d3,d4 + PUTMSG 10,<"%d: Greeting from %d,%d to %d,%d, shift %d">,fw_FrameCounter-2(a6),d0,d1,d2,d3,d4 move.w d0,cp_FgRelPosX(a4) beq.s .kill @@ -5359,21 +5359,21 @@ bln_load_next_greeting: ;-------------------------------------------------------------------- bln_reverse_big_circle_to_backward: - PUTMSG 10,<"%d: Reversing big circle (%d music frames)">,fw_FrameCounterLong(a6),fw_MusicFrameCount-2(a6) + PUTMSG 10,<"%d: Reversing big circle (%d music frames)">,fw_FrameCounter-2(a6),fw_MusicFrameCount-2(a6) move.l #bln_big_circle_rad_backward_update,cp_FrameRoutine(a4) rts ;-------------------------------------------------------------------- bln_reverse_smaller_circle_to_backward: - PUTMSG 10,<"%d: Reversing smaller circle (%d music frames)">,fw_FrameCounterLong(a6),fw_MusicFrameCount-2(a6) + PUTMSG 10,<"%d: Reversing smaller circle (%d music frames)">,fw_FrameCounter-2(a6),fw_MusicFrameCount-2(a6) move.l #bln_smaller_circle_rad_backward_update,cp_FrameRoutine(a4) rts ;-------------------------------------------------------------------- bln_reverse_small_circle_to_backward: - PUTMSG 10,<"%d: Reversing smaller circle (%d music frames)">,fw_FrameCounterLong(a6),fw_MusicFrameCount-2(a6) + PUTMSG 10,<"%d: Reversing smaller circle (%d music frames)">,fw_FrameCounter-2(a6),fw_MusicFrameCount-2(a6) move.l #bln_small_circle_rad_backward_update,cp_FrameRoutine(a4) rts @@ -5598,13 +5598,13 @@ bln_circle_greet6_script: dc.w $000 ; is required for true color image decoding bln_images_palette: - include "../data/blend/fiveimg_ham.pal.asm" + include "data/blend/fiveimg_ham.pal.asm" bln_leaves_tc_10: - incbin "../data/blend/leavestc_10.raw" + incbin "data/blend/leavestc_10.raw" bln_endlogo_palette: - include "../data/blend/PLT_DSRLogo01c_ham.pal.asm" + include "data/blend/PLT_DSRLogo01c_ham.pal.asm" dc.l 0 bln_circlerads: @@ -5718,32 +5718,32 @@ bln_circleinfo: dc.w 0 bln_andyou_image: - incbin "../data/blend/andyou_128x92x2.BPL" + incbin "data/blend/andyou_128x92x2.BPL" bln_blend_image_1: - incbin "../data/blend/fiveimg1_ham.raw" + incbin "data/blend/fiveimg1_ham.raw" IFND FW_DEMO_PART section "bln_cat",data,chip bln_blend_image_2: - incbin "../data/blend/fiveimg2_ham.raw" + incbin "data/blend/fiveimg2_ham.raw" bln_blend_image_3: - incbin "../data/blend/fiveimg3_ham.raw" + incbin "data/blend/fiveimg3_ham.raw" bln_blend_image_4: - incbin "../data/blend/fiveimg4_ham.raw" + incbin "data/blend/fiveimg4_ham.raw" bln_blend_image_5: - incbin "../data/blend/fiveimg5_ham.raw" + incbin "data/blend/fiveimg5_ham.raw" bln_endlogo_image: - incbin "../data/blend/PLT_DSRLogo01c_ham.raw" + incbin "data/blend/PLT_DSRLogo01c_ham.raw" IFD ENABLE_PART_MUSIC section "part_music_samples",data,chip ; section for music playback part_music_smp: - incbin "../data/music/dsr_68k_tune_2_v11.lsbank" + incbin "data/music/dsr_68k_tune_2_v11.lsbank" section "part_music_data",data ; section for music playback part_music_data: - incbin "../data/music/dsr_68k_tune_2_v11.lsmusic" + incbin "data/music/dsr_68k_tune_2_v11.lsmusic" ENDC ENDC END \ No newline at end of file diff --git a/source/bulb/bulb.asm b/source/bulb/bulb.asm index ed4e47f..faabf21 100644 --- a/source/bulb/bulb.asm +++ b/source/bulb/bulb.asm @@ -95,7 +95,7 @@ DEBUG_DETAIL SET 10 NEWAGE_DEBUG = 1 - include "../framework/framework.i" + include "framework.i" ; Memory use: @@ -236,7 +236,7 @@ NEWAGE_DEBUG = 1 LABEL pd_SIZEOF IFND FW_DEMO_PART - include "../framework/framework.asm" + include "framework.asm" ENDC entrypoint: @@ -442,7 +442,7 @@ blb_init_colors: blb_init_shade_table: move.l pd_ShadeTableXor(a6),a0 - PUTMSG 10,<"%d: Init Shade Table %p">,fw_FrameCounterLong(a6),a0 + PUTMSG 10,<"%d: Init Shade Table %p">,fw_FrameCounter-2(a6),a0 move.l a0,a1 moveq.l #0,d0 .xorloop @@ -519,7 +519,7 @@ blb_main: CALLFW SetBlitterQueueMultiFrame move.w #-1,pd_CurrBlitSize(a6) - PUTMSG 10,<"%d: Main!">,fw_FrameCounterLong(a6) + PUTMSG 10,<"%d: Main!">,fw_FrameCounter-2(a6) lea .vblstuff(pc),a0 move.l a0,fw_VBlankIRQ(a6) @@ -531,7 +531,7 @@ blb_main: CALLFW VSyncWithTask - PUTMSG 10,<"%d: Main 2">,fw_FrameCounterLong(a6) + PUTMSG 10,<"%d: Main 2">,fw_FrameCounter-2(a6) bsr blb_flip_db_frame bsr blb_create_bulb_copperlist bsr blb_patch_in_text_sprites_to_copperlist @@ -601,14 +601,14 @@ blb_main: .nowrapbqwrite cmp.l pd_BqDataReadPtr(a6),a1 bne.s .nowait - PUTMSG 40,<"%d: Waiting for space Read: %p Write: %p">,fw_FrameCounterLong(a6),pd_BqDataReadPtr(a6),pd_BqDataWritePtr(a6) + PUTMSG 40,<"%d: Waiting for space Read: %p Write: %p">,fw_FrameCounter-2(a6),pd_BqDataReadPtr(a6),pd_BqDataWritePtr(a6) CALLFW JoinBlitterQueue CALLFW VSyncWithTask bra.s .waitforbqspaceloop .nowait move.l a1,pd_BqDataWritePtr(a6) move.l a2,pd_CurrLineColorsPtr(a6) - PUTMSG 40,<"%d: Done a frame Read: %p Write: %p">,fw_FrameCounterLong(a6),pd_BqDataReadPtr(a6),pd_BqDataWritePtr(a6) + PUTMSG 40,<"%d: Done a frame Read: %p Write: %p">,fw_FrameCounter-2(a6),pd_BqDataReadPtr(a6),pd_BqDataWritePtr(a6) subq.w #1,pd_PartCountDown(a6) bne .loop @@ -659,17 +659,17 @@ blb_main: tst.w pd_NextQueueTriggerFrame(a6) beq.s .nodrop subq.w #1,pd_LampFrameNum(a6) - PUTMSG 10,<"%d: Framedrop %d vs %d!">,fw_FrameCounterLong(a6),pd_NextQueueTriggerFrame-2(a6),d0 + PUTMSG 10,<"%d: Framedrop %d vs %d!">,fw_FrameCounter-2(a6),pd_NextQueueTriggerFrame-2(a6),d0 .nodrop addq.w #2,d0 move.w d0,pd_NextQueueTriggerFrame(a6) - PUTMSG 20,<"%d: Triggering queue %p">,fw_FrameCounterLong(a6),a0 + PUTMSG 20,<"%d: Triggering queue %p">,fw_FrameCounter-2(a6),a0 move.w -4(a0),pd_CurrBlitSize(a6) BLTWAIT CALLFW TriggerCustomBlitterQueue rts .nop - PUTMSG 20,<"%d: Ignoring">,fw_FrameCounterLong(a6) + PUTMSG 20,<"%d: Ignoring">,fw_FrameCounter-2(a6) rts ;-------------------------------------------------------------------- @@ -683,7 +683,7 @@ blb_brighten: lea pd_LampPalette(a6),a1 CALLFW FadePaletteTo - PUTMSG 10,<"%d: Brighten!">,fw_FrameCounterLong(a6) + PUTMSG 10,<"%d: Brighten!">,fw_FrameCounter-2(a6) move.w #SWING_FRAMES*4,pd_SwingFrameNum(a6) move.w #PAINT_FRAMES*4,pd_PaintFrameNum(a6) @@ -749,14 +749,14 @@ blb_brighten: .nowrapbqwrite cmp.l pd_BqDataReadPtr(a6),a1 bne.s .nowait - PUTMSG 40,<"%d: Waiting for space Read: %p Write: %p">,fw_FrameCounterLong(a6),pd_BqDataReadPtr(a6),pd_BqDataWritePtr(a6) + PUTMSG 40,<"%d: Waiting for space Read: %p Write: %p">,fw_FrameCounter-2(a6),pd_BqDataReadPtr(a6),pd_BqDataWritePtr(a6) CALLFW JoinBlitterQueue CALLFW VSyncWithTask bra.s .waitforbqspaceloop .nowait move.l a1,pd_BqDataWritePtr(a6) move.l a2,pd_CurrLineColorsPtr(a6) - PUTMSG 40,<"%d: Done a frame Read: %p Write: %p">,fw_FrameCounterLong(a6),pd_BqDataReadPtr(a6),pd_BqDataWritePtr(a6) + PUTMSG 40,<"%d: Done a frame Read: %p Write: %p">,fw_FrameCounter-2(a6),pd_BqDataReadPtr(a6),pd_BqDataWritePtr(a6) subq.w #1,pd_PartCountDown(a6) bne .loop @@ -3269,13 +3269,13 @@ blb_do_lamp_rotations: moveq.l #-NUM_LAMP_ROTATIONS/2,d1 .loop - PUTMSG 40,<"%d: Rotation %d to %p">,fw_FrameCounterLong(a6),d1,a4 + PUTMSG 40,<"%d: Rotation %d to %p">,fw_FrameCounter-2(a6),d1,a4 PUSHM d1/d7 bsr blb_calc_sheers bsr blb_rotate_chunky - PUTMSG 40,<"%d: C2P">,fw_FrameCounterLong(a6) + PUTMSG 40,<"%d: C2P">,fw_FrameCounter-2(a6) lea pd_LampSprites(a6),a3 REPT 3 move.l a4,a1 @@ -3503,10 +3503,10 @@ blb_text_panels: dc.l 0 blb_lamp_palette: - incbin "../data/bulb/lamp_64x32x16.PAL" + incbin "data/bulb/lamp_64x32x16.PAL" blb_lamp_off_palette: - incbin "../data/bulb/lamp_off_64x32x16.PAL" + incbin "data/bulb/lamp_off_64x32x16.PAL" blb_lamp_white_palette: REPT 15 @@ -3530,7 +3530,7 @@ blb_lamp_angle_table: include "langletable.asm" blb_lamp_chunky: - incbin "../data/bulb/lamp_48x32x16.chk" + incbin "data/bulb/lamp_48x32x16.chk" section "blb_anim",data @@ -3596,25 +3596,25 @@ blb_extra_copperlist_ptr: COP_END blb_bulb_pic: - incbin "../data/bulb/PLT_Lampscene_ham.raw" + incbin "data/bulb/PLT_Lampscene_ham.raw" blb_text_1_data: ;blk.b 2560,255 - incbin "../data/bulb/text1.BPL" + incbin "data/bulb/text1.BPL" blb_text_2_data: ;blk.b 2560,255 - incbin "../data/bulb/text2.BPL" + incbin "data/bulb/text2.BPL" blb_text_3_data: ;blk.b 2560,255 - incbin "../data/bulb/text3.BPL" + incbin "data/bulb/text3.BPL" blb_text_4_data: ;blk.b 2560,255 - incbin "../data/bulb/text4.BPL" + incbin "data/bulb/text4.BPL" blb_text_5_data: ;blk.b 2560,255 - incbin "../data/bulb/text5.BPL" + incbin "data/bulb/text5.BPL" END \ No newline at end of file diff --git a/source/endpart/endpart.asm b/source/endpart/endpart.asm index 400b4ca..c74651a 100644 --- a/source/endpart/endpart.asm +++ b/source/endpart/endpart.asm @@ -75,7 +75,7 @@ DEBUG_DETAIL SET 10 NEWAGE_DEBUG = 1 - include "../framework/framework.i" + include "framework.i" ; Memory use: @@ -115,7 +115,7 @@ NEWAGE_DEBUG = 1 LABEL pd_SIZEOF IFND FW_DEMO_PART - include "../framework/framework.asm" + include "framework.asm" ENDC entrypoint: @@ -420,7 +420,7 @@ enp_write_textline: .nextline - PUTMSG 40,<"%d: NL">,fw_FrameCounterLong(a6) + PUTMSG 40,<"%d: NL">,fw_FrameCounter-2(a6) move.l pd_TextLinePtr(a6),a0 .retrychar tst.b (a0) @@ -1058,20 +1058,20 @@ enp_extra_copperlist_ptr: COP_END enp_font_data: - incbin "../data/endpart/PJZ_font_8x16x4.BPL" + incbin "data/endpart/PJZ_font_8x16x4.BPL" IFND FW_DEMO_PART IFD ENABLE_PART_MUSIC section "part_music_samples",data,chip ; section for music playback part_music_smp: - incbin "../data/music/desire_68k_tune3_v2.lsbank" + incbin "data/music/desire_68k_tune3_v2.lsbank" section "part_music_data",data ; section for music playback part_music_data: - incbin "../data/music/desire_68k_tune3_v2.lsmusic" + incbin "data/music/desire_68k_tune3_v2.lsmusic" ENDC section "enp_screenshots",data,chip enp_screenshots: ds.b ((SCREENSHOTS_WIDTH/8)*ENDP_HEIGHT)*SCREENSHOTS_PLANES - incbin "../data/endpart/screenshots_320x1620.BPL" + incbin "data/endpart/screenshots_320x1620.BPL" ENDC END \ No newline at end of file diff --git a/source/framework/framework.asm b/source/framework/framework.asm index 402ed34..523b485 100644 --- a/source/framework/framework.asm +++ b/source/framework/framework.asm @@ -2,92 +2,92 @@ ; link all parts together depending on the settings - include "../framework/framework.i" + include "framework.i" IF FW_STANDALONE_FILE_MODE - include "../framework/os_startupcode.asm" + include "os_startupcode.asm" ELSE - include "../framework/trackmo_startupcode.asm" + include "trackmo_startupcode.asm" ENDC - include "../framework/framework_misc.asm" + include "framework_misc.asm" IF FW_MULTITASKING_SUPPORT - include "../framework/framework_tasks.asm" + include "framework_tasks.asm" ENDC IF FW_BLITTERQUEUE_SUPPORT - include "../framework/framework_blitterqueue.asm" + include "framework_blitterqueue.asm" ENDC IF FW_DYNAMIC_MEMORY_SUPPORT - include "../framework/framework_memory.asm" + include "framework_memory.asm" ENDC IF FW_MUSIC_SUPPORT - include "../framework/framework_music.asm" + include "framework_music.asm" ENDC IF FW_MULTIPART_SUPPORT - include "../framework/framework_multipart.asm" + include "framework_multipart.asm" ENDC IF FW_SINETABLE_SUPPORT - include "../framework/framework_sinetable.asm" + include "framework_sinetable.asm" ENDC IF FW_SCRIPTING_SUPPORT - include "../framework/framework_scripting.asm" + include "framework_scripting.asm" ENDC IF FW_PALETTE_LERP_SUPPORT - include "../framework/framework_palettelerp.asm" + include "framework_palettelerp.asm" ENDC IFEQ FW_STANDALONE_FILE_MODE - include "../framework/framework_trackloader.asm" - include "../framework/framework_dos.asm" + include "framework_trackloader.asm" + include "framework_dos.asm" ELSE IF FW_HD_TRACKMO_MODE - include "../framework/framework_hdloader.asm" - include "../framework/framework_dos.asm" + include "framework_hdloader.asm" + include "framework_dos.asm" ENDC ENDC IF FW_MUSIC_SUPPORT IFNE FW_MUSIC_PLAYER_CHOICE==0 - include "../framework/musicplayers/player_none.asm" + include "musicplayers/player_none.asm" ENDC IFNE FW_MUSIC_PLAYER_CHOICE==1 - include "../framework/musicplayers/player_lsp_vbl.asm" + include "musicplayers/player_lsp_vbl.asm" ENDC IFNE FW_MUSIC_PLAYER_CHOICE==2 - include "../framework/musicplayers/player_lsp_cia.asm" + include "musicplayers/player_lsp_cia.asm" ENDC IFNE FW_MUSIC_PLAYER_CHOICE==3 fail "Sorry, P61 not ported to this framework (yet). Use LSP instead." ENDC - IFNE (FW_MUSIC_PLAYER_CHOICE==4)|(FW_MUSIC_PLAYER_CHOICE==5) - ;include "../framework/musicplayers/player_pretracker_std.asm" - include "../framework/musicplayers/player_raspberry_casket.asm" + IFNE (FW_MUSIC_PLAYER_CHOICE>=4)&&(FW_MUSIC_PLAYER_CHOICE<=6) + ;include "musicplayers/player_pretracker_std.asm" + include "musicplayers/player_raspberry_casket.asm" ENDC ENDC IF FW_LZ4_SUPPORT fw_DecompressLZ4: - include "../framework/unpackers/lz4_normal.asm" + include "unpackers/lz4_normal.asm" ENDC IF FW_ZX0_SUPPORT fw_DecompressZX0: - ;include "../framework/unpackers/zx0.asm" - include "../framework/unpackers/zx0_faster.asm" + ;include "unpackers/zx0.asm" + include "unpackers/zx0_faster.asm" ENDC IF FW_DOYNAX_SUPPORT fw_DecompressDoynax: - include "../framework/unpackers/doynax.asm" + include "unpackers/doynax.asm" ENDC - include "../framework/framework_chip_section.asm" + include "framework_chip_section.asm" IF FW_STANDALONE_FILE_MODE ; framework structure is allocated from RAM and pointer is placed here diff --git a/source/framework/framework.i b/source/framework/framework.i index 321806b..cbea4bc 100644 --- a/source/framework/framework.i +++ b/source/framework/framework.i @@ -1,24 +1,24 @@ IFND FRAMEWORK_I FRAMEWORK_I SET 1 - include "../includes/hardware/custom.i" - include "../includes/hardware/copper.i" - include "../includes/hardware/cia.i" - include "../includes/hardware/intbits.i" - include "../includes/hardware/dmabits.i" - include "../includes/hardware/adkbits.i" - include "../includes/hardware/blitbits.i" - include "../includes/exec/types.i" - include "../includes/exec/nodes.i" - include "../includes/exec/lists.i" - include "../includes/exec/macros.i" - include "../includes/exec/execbase.i" - include "../includes/dos/doshunks.i" - include "../includes/lvo/lvo.i" - include "../framework/framework_macros.i" + include "hardware/custom.i" + include "hardware/copper.i" + include "hardware/cia.i" + include "hardware/intbits.i" + include "hardware/dmabits.i" + include "hardware/adkbits.i" + include "hardware/blitbits.i" + include "exec/types.i" + include "exec/nodes.i" + include "exec/lists.i" + include "exec/macros.i" + include "exec/execbase.i" + include "dos/doshunks.i" + include "lvo/lvo.i" + include "framework_macros.i" FWGENLVOTABLE SET 0 - include "../framework/framework_lvos.i" + include "framework_lvos.i" ; error color codes ERROR_OUTOFMEMORY = $0f00 ; one of the memory stacks ran out of memory @@ -60,6 +60,10 @@ DEFF_DELTA32 = (3<=4)&&(FW_MUSIC_PLAYER_CHOICE<=6) APTR fw_PretrackerMyPlayer APTR fw_PretrackerMySong ULONG fw_PretrackerProgress + IF (FW_MUSIC_PLAYER_CHOICE>=5) APTR fw_PretrackerCopperlist ENDC + IF (FW_MUSIC_PLAYER_CHOICE==6) + APTR fw_PretrackerBgTask + APTR fw_PretrackerCopperlistStart + APTR fw_PretrackerCopperlistEnd + APTR fw_PretrackerCopperReadPtr + APTR fw_PretrackerCopperWritePtr + ENDC + ENDC ENDC IFD gbd_SIZEOF diff --git a/source/framework/framework_dos.asm b/source/framework/framework_dos.asm index 21a6ce1..53cc594 100644 --- a/source/framework/framework_dos.asm +++ b/source/framework/framework_dos.asm @@ -17,7 +17,7 @@ ; Trashes: probably all registers ; fw_ExecuteNextPart: - PUTMSG 10,<10,"%d: *** Preparing to execute next part %s ***">,fw_FrameCounterLong(a6),a0 + PUTMSG 10,<10,"%d: *** Preparing to execute next part %s ***">,fw_FrameCounter-2(a6),a0 bsr.s fw_LoadNextPart PUSHM a0 @@ -25,15 +25,15 @@ fw_ExecuteNextPart: POPM IF FW_MUSIC_SUPPORT - PUTMSG 10,<"%d: *** Executing next part %p at music frame %d">,fw_FrameCounterLong(a6),a0,fw_MusicFrameCount-2(a6) + PUTMSG 10,<"%d: *** Executing next part %p at music frame %d">,fw_FrameCounter-2(a6),a0,fw_MusicFrameCount-2(a6) ELSE - PUTMSG 10,<"%d: *** Executing next part %p">,fw_FrameCounterLong(a6),a0 + PUTMSG 10,<"%d: *** Executing next part %p">,fw_FrameCounter-2(a6),a0 ENDC jsr (a0) IF FW_MUSIC_SUPPORT - PUTMSG 10,<"%d: *** Part finished at music frame %d",10>,fw_FrameCounterLong(a6),fw_MusicFrameCount-2(a6) + PUTMSG 10,<"%d: *** Part finished at music frame %d",10>,fw_FrameCounter-2(a6),fw_MusicFrameCount-2(a6) ELSE - PUTMSG 10,<"%d: *** Part finished",10>,fw_FrameCounterLong(a6) + PUTMSG 10,<"%d: *** Part finished",10>,fw_FrameCounter-2(a6) ENDC bsr fw_RestoreFrameworkBase @@ -57,7 +57,7 @@ fw_ExecuteNextPart: ; Trashes: probably all registers ; fw_LoadNextPart: - PUTMSG 10,<10,"%d: *** Loading next part %s ***">,fw_FrameCounterLong(a6),a0 + PUTMSG 10,<10,"%d: *** Loading next part %s ***">,fw_FrameCounter-2(a6),a0 clr.l fw_LastLoadedPart(a6) bsr fw_DropCurrentMemoryAllocations bsr fw_FindFile @@ -75,7 +75,7 @@ fw_LoadNextPart: fw_WaitForPartLoaded: tst.l fw_LastLoadedPart(a6) bne.s .done - PUTMSG 10,<"%d: Part not yet fully loaded. Waiting.">,fw_FrameCounterLong(a6) + PUTMSG 10,<"%d: Part not yet fully loaded. Waiting.">,fw_FrameCounter-2(a6) .loop bsr fw_Yield tst.l fw_LastLoadedPart(a6) beq.s .loop @@ -89,7 +89,7 @@ fw_WaitForPartLoaded: ; just before ExecuteNextPart starts the part after loading/decrunching. ; ; Hooks can be installed by writing fw_PrePartLaunchHook(a6). -; If this field is NULL, this function does nothing. +; If this field is NULL, this function does nothing. ; fw_PrePartLaunchHook(a6) is cleared prior to executing the hook. ; fw_CheckPrePartLaunchHook: @@ -251,7 +251,7 @@ fw_LoadFile: ; a1 = Dir entry structure of the file ; fw_LoadPlainFileEntry: - PUTMSG 10,<"%d: Loading plain file from offset %ld, size %ld">,fw_FrameCounterLong(a6),de_DiskOffset(a1),de_DiskLength(a1) + PUTMSG 10,<"%d: Loading plain file from offset %ld, size %ld">,fw_FrameCounter-2(a6),de_DiskOffset(a1),de_DiskLength(a1) tst.b de_Flags+1(a1) bpl.s fw_LoadPlainFileEntryToFast move.l de_DiskLength(a1),d0 @@ -420,8 +420,8 @@ fw_LoadAndInPlaceDecrunchToBuffer: ; ; In : a0 = source buffer ; a1 = Dir entry structure -; a2 = target buffer -; Out: a0 = END of the buffer written +; a2 = target buffer +; Out: a0 = END of the buffer written ; a1 = Dir entry structure ; fw_DecrunchToBuffer: @@ -431,7 +431,7 @@ fw_DecrunchToBuffer: IF FW_DOYNAX_SUPPORT cmp.w #DEFF_DOYNAX,d0 bne.s .nodoynax - PUTMSG 10,<"%d: DoynaxDecrunch from %p (%ld) to %p (%ld)">,fw_FrameCounterLong(a6),a0,de_DiskLength(a1),a2,de_MemorySize(a1) + PUTMSG 10,<"%d: DoynaxDecrunch from %p (%ld) to %p (%ld)">,fw_FrameCounter-2(a6),a0,de_DiskLength(a1),a2,de_MemorySize(a1) move.l a2,a1 bsr doynaxdepack bra .decdone @@ -441,7 +441,7 @@ fw_DecrunchToBuffer: IF FW_ZX0_SUPPORT cmp.w #DEFF_ZX0,d0 bne.s .nozx0 - PUTMSG 10,<"%d: ZX0Decrunch from %p (%ld) to %p (%ld)">,fw_FrameCounterLong(a6),a0,de_DiskLength(a1),a2,de_MemorySize(a1) + PUTMSG 10,<"%d: ZX0Decrunch from %p (%ld) to %p (%ld)">,fw_FrameCounter-2(a6),a0,de_DiskLength(a1),a2,de_MemorySize(a1) move.l a2,a1 bsr zx0_decompress bra.s .decdone @@ -452,7 +452,7 @@ fw_DecrunchToBuffer: cmp.w #DEFF_LZ4,d0 bne.s .nolz4 move.l de_DiskLength(a1),d0 - PUTMSG 10,<"%d: LZ4Decrunch from %p (%ld) to %p (%ld)">,fw_FrameCounterLong(a6),a0,d0,a2,de_MemorySize(a1) + PUTMSG 10,<"%d: LZ4Decrunch from %p (%ld) to %p (%ld)">,fw_FrameCounter-2(a6),a0,d0,a2,de_MemorySize(a1) move.l a2,a1 bsr lz4_depack bra.s .decdone @@ -477,7 +477,7 @@ fw_DecrunchToBuffer: PUSHM a2 move.l de_MemorySize(a1),d0 beq.s .d8done - PUTMSG 10,<"%d: Delta8 decoding %p %ld bytes">,fw_FrameCounterLong(a6),a2,d0 + PUTMSG 10,<"%d: Delta8 decoding %p %ld bytes">,fw_FrameCounter-2(a6),a2,d0 moveq.l #0,d1 subq.l #1,d0 .d8loop @@ -492,7 +492,7 @@ fw_DecrunchToBuffer: .d8done POPM .nodelta - PUTMSG 10,<"%d: Decrunching done">,fw_FrameCounterLong(a6) + PUTMSG 10,<"%d: Decrunching done">,fw_FrameCounter-2(a6) rts ;-------------------------------------------------------------------- @@ -505,7 +505,7 @@ fw_LoadFileToBuffer: PUSHM a0-a3 move.l de_DiskOffset(a1),d0 move.l de_DiskLength(a1),d1 - PUTMSG 10,<"%d: Loading file %p to buffer %p (%ld)">,fw_FrameCounterLong(a6),a1,a0,d1 + PUTMSG 10,<"%d: Loading file %p to buffer %p (%ld)">,fw_FrameCounter-2(a6),a1,a0,d1 bsr fw_TrackloaderLoad POPM rts @@ -521,7 +521,7 @@ fw_LoadFileToBuffer: ; Out: a1 = end of decrunching pointer ; fw_TrackmoLoadAndDecrunchToBuffer: - PUTMSG 10,<"%d: Trackmo Loading and Decrunching %p">,fw_FrameCounterLong(a6),a1 + PUTMSG 10,<"%d: Trackmo Loading and Decrunching %p">,fw_FrameCounter-2(a6),a1 move.w #DEFM_PACKMODE,d0 and.w de_Flags(a1),d0 IF FW_TRACKMO_LZ4_SUPPORT|FW_TRACKMO_LZ4_DLT8_SUPPORT @@ -550,7 +550,7 @@ fw_TrackmoLoadAndDecrunchToBuffer: ;-------------------------------------------------------------------- ; Load and decrunch a part ; -; Reads, allocates, decrunches and relocates all hunks for the given +; Reads, allocates, decrunches and relocates all hunks for the given ; directory entry. ; ; In : a1 = Dir entry structure @@ -558,7 +558,7 @@ fw_TrackmoLoadAndDecrunchToBuffer: ; fw_LoadAndDecrunchPart: move.l d7,-(sp) - PUTMSG 10,<"%d: Loading and Decrunching %p">,fw_FrameCounterLong(a6),a1 + PUTMSG 10,<"%d: Loading and Decrunching %p">,fw_FrameCounter-2(a6),a1 tst.b de_NumHunks(a1) bne.s .cont @@ -674,7 +674,7 @@ fw_LoadAndDecrunchPart: IF FW_ZX0_SUPPORT .inplacedecrunch - PUTMSG 10,<"%d: In-place loading and decrunching %ld bytes to %p (%d)">,fw_FrameCounterLong(a6),de_DiskLength(a1),a0,d7 + PUTMSG 10,<"%d: In-place loading and decrunching %ld bytes to %p (%d)">,fw_FrameCounter-2(a6),de_DiskLength(a1),a0,d7 PUSHM a1-a3 move.l (a3,d7.w),a0 bsr fw_LoadAndInPlaceDecrunchToBuffer @@ -686,7 +686,7 @@ fw_LoadAndDecrunchPart: .trackloadlz4 move.l (a3,d7.w),a0 PUSHM a1-a3 - PUTMSG 10,<"%d: LZ4 loading and decrunching %ld bytes to %p (%d)">,fw_FrameCounterLong(a6),de_DiskLength(a1),a0,d7 + PUTMSG 10,<"%d: LZ4 loading and decrunching %ld bytes to %p (%d)">,fw_FrameCounter-2(a6),de_DiskLength(a1),a0,d7 bsr fw_TrackmoLoadAndDecrunchToBuffer move.l a1,a0 POPM @@ -728,7 +728,7 @@ fw_LoadAndDecrunchPart: .clearmem move.l (a3,d7.w),d0 add.l de_MemorySize(a1),d0 - PUTMSG 10,<"%d: End of buffer %p, expected %p, memory size %ld">,fw_FrameCounterLong(a6),a0,d0,de_MemorySize(a1) + PUTMSG 10,<"%d: End of buffer %p, expected %p, memory size %ld">,fw_FrameCounter-2(a6),a0,d0,de_MemorySize(a1) sub.l a0,d0 ; bytes to clear .clearit @@ -818,7 +818,7 @@ fw_PreloadPart: IFEQ FW_HD_TRACKMO_MODE bsr fw_FindFile move.l d7,-(sp) - PUTMSG 10,<"%d: Preparing loading and decrunching of %p">,fw_FrameCounterLong(a6),a1 + PUTMSG 10,<"%d: Preparing loading and decrunching of %p">,fw_FrameCounter-2(a6),a1 tst.b de_NumHunks(a1) bne.s .cont diff --git a/source/framework/framework_lvos.i b/source/framework/framework_lvos.i index b322712..4147550 100644 --- a/source/framework/framework_lvos.i +++ b/source/framework/framework_lvos.i @@ -61,6 +61,9 @@ _LVOFrameWorkVSyncWithTask = _LVOFrameWorkVSync DEFFWFUNC InitPaletteLerpSameColor DEFFWFUNC FadePaletteTo DEFFWFUNC DoFadePaletteStep + IFEQ FW_PALETTE_LERP_SUPPORT-2 + DEFFWFUNC DoFadePaletteStepBlueNoise + ENDC ENDC IF FW_SCRIPTING_SUPPORT diff --git a/source/framework/framework_macros.i b/source/framework/framework_macros.i index 06ca5ea..103b253 100644 --- a/source/framework/framework_macros.i +++ b/source/framework/framework_macros.i @@ -76,7 +76,7 @@ BLTWAIT MACRO ; channels, minterm, shift a, shift b, (optional: target) BLTCON_SET MACRO ; write both bltcon0/bltcon1 - IFNC '\5','' + IFNC '\5','' move.l #(((BLTEN_\1+((\2)&$ff))|(\3<<12))<<16)|(\4<<12),\5 ELSE move.l #(((BLTEN_\1+((\2)&$ff))|(\3<<12))<<16)|(\4<<12),bltcon0(a5) @@ -86,7 +86,7 @@ BLTCON_SET MACRO ; channels, minterm, shift a, (optional: target) BLTCON0_SET MACRO ; write only bltcon0 - IFNC '\4','' + IFNC '\4','' move.w #((BLTEN_\1+((\2)&$ff))|(\3<<12)),\4 ELSE move.w #((BLTEN_\1+((\2)&$ff))|(\3<<12)),bltcon0(a5) @@ -96,7 +96,7 @@ BLTCON0_SET MACRO ; channels, minterm, shift a, shift b, bltcon1 flags, (optional: target) BLTCON_SET_X MACRO ; write both bltcon0/bltcon1 - IFNC '\6','' + IFNC '\6','' move.l #(((BLTEN_\1+((\2)&$ff))|(\3<<12))<<16)|(\4<<12)|(\5),\6 ELSE move.l #(((BLTEN_\1+((\2)&$ff))|(\3<<12))<<16)|(\4<<12)|(\5),bltcon0(a5) diff --git a/source/framework/framework_memory.asm b/source/framework/framework_memory.asm index 6ea32b4..a1f2f13 100644 --- a/source/framework/framework_memory.asm +++ b/source/framework/framework_memory.asm @@ -39,7 +39,7 @@ fw_InitMemoryManagement: ; Memory of other allocation direction is unchanged. ; fw_DropCurrentMemoryAllocations: - PUTMSG 10,<"%d: DropCurrentMemoryAllocations">,fw_FrameCounterLong(a6) + PUTMSG 10,<"%d: DropCurrentMemoryAllocations">,fw_FrameCounter-2(a6) IFGE DEBUG_DETAIL-20 PUSHM a0/a1/d0 ELSE @@ -198,7 +198,7 @@ fw_PopMemoryState: ; d1/a1: Trashed. ; fw_AllocFast: - PUTMSG 10,<"%d: AllocFast(%ld)">,fw_FrameCounterLong(a6),d0 + PUTMSG 10,<"%d: AllocFast(%ld)">,fw_FrameCounter-2(a6),d0 addq.l #3,d0 and.w #-4,d0 @@ -233,7 +233,7 @@ fw_AllocFast: ; d1/a1: Trashed. ; fw_AllocChip: - PUTMSG 10,<"%d: AllocChip(%ld)">,fw_FrameCounterLong(a6),d0 + PUTMSG 10,<"%d: AllocChip(%ld)">,fw_FrameCounter-2(a6),d0 addq.l #7,d0 and.w #-8,d0 @@ -281,7 +281,7 @@ fw_AllocChip: ; IF FW_64KB_PAGE_MEMORY_SUPPORT fw_AllocChip64KB: - PUTMSG 10,<"%d: AllocChip64KB(%ld)">,fw_FrameCounterLong(a6),d0 + PUTMSG 10,<"%d: AllocChip64KB(%ld)">,fw_FrameCounter-2(a6),d0 addq.l #7,d0 and.w #-8,d0 diff --git a/source/framework/framework_misc.asm b/source/framework/framework_misc.asm index 6dfe7b9..14f99c9 100644 --- a/source/framework/framework_misc.asm +++ b/source/framework/framework_misc.asm @@ -13,12 +13,12 @@ fw_Error: ;-------------------------------------------------------------------- ; Sets the base copperlist and irq (empty screen). ; -; Background colour is unchanged, sprites and display are disabled. +; Background colour is unchanged, sprites and display are disabled. ; ; Out: Trashes d0/a0 ; fw_SetBaseCopper: - PUTMSG 10,<"%d: SetBaseCopper">,fw_FrameCounterLong(a6) + PUTMSG 10,<"%d: SetBaseCopper">,fw_FrameCounter-2(a6) moveq.l #0,d0 IF FW_VBL_IRQ_SUPPORT move.l d0,fw_VBlankIRQ(a6) @@ -35,6 +35,15 @@ fw_SetBaseCopper: move.l fw_VBR(a6),a0 move.l fw_DefaultIRQ(a6),$6c(a0) + IF FW_SOFT_IRQ_SUPPORT + lea fw_softint_irq(pc),a1 + move.l a1,$64(a0) + ENDC + IF FW_AUDIO_IRQ_SUPPORT + move.l $70(a0),fw_OldSystemAudioIRQ(a6) + lea fw_audio_irq(pc),a1 + move.l a1,$70(a0) + ENDC move.w #INTF_BLIT,intena(a5) ; disable blitter interrupt move.w #INTF_BLIT|INTF_COPER,intreq(a5) @@ -43,6 +52,10 @@ fw_SetBaseCopper: ELSE move.w #INTF_SETCLR|INTF_INTEN|INTF_VERTB,intena(a5) ; enable vblank interrupt ENDC + IF FW_SOFT_IRQ_SUPPORT + move.w #INTF_SOFTINT,intreq(a5) + move.w #INTF_SETCLR|INTF_SOFTINT,intena(a5) ; enable soft interrupt + ENDC bsr.s fw_VSync move.w #DMAF_SETCLR|DMAF_MASTER|DMAF_BLITTER|DMAF_RASTER|DMAF_COPPER,dmacon(a5) .clrspr @@ -86,6 +99,10 @@ fw_VSyncWithTask: ENDC fw_VSync: IF FW_LMB_EXIT_SUPPORT + IFEQ FW_LMB_EXIT_SUPPORT-2 + tst.w fw_DisableLMBExit(a6) + bne.s .noabort + ENDC btst #6,$bfe001 beq .abortdemo ENDC @@ -115,26 +132,40 @@ fw_VSync: ENDC ;-------------------------------------------------------------------- -; Waits until the global framecounter reaches the given frame +; Waits until the global framecounter reaches at least the given frame ; ; In : d0.w - frame to wait for ; Out: May trash all registers! ; fw_WaitForFrame: - PUTMSG 10,<"%d: Waiting for frame %d">,fw_FrameCounterLong(a6),d0 -.loop - cmp.w fw_FrameCounter(a6),d0 - bmi.s .endwait - PUSHM d0 + PUTMSG 20,<"%d: Waiting for frame %d">,fw_FrameCounter-2(a6),d0 IF FW_MULTITASKING_SUPPORT - bra fw_VSyncWithTask - ELSE - bra fw_VSync - ENDC - POPM + move.l #$1ff00,d1 + and.l vposr(a5),d1 + cmp.l #FW_MAX_VPOS_FOR_BG_TASK<<8,d1 + ble.s .enoughtime + ; we're close to the VBL, spin + BLTHOGON +.spin cmp.w fw_FrameCounter(a6),d0 + bmi.s .endwait + ; check if we have gone past the VBL + move.l #$1ff00,d1 + and.l vposr(a5),d1 + cmp.l #FW_MAX_VPOS_FOR_BG_TASK<<8,d1 + bgt.s .spin +.enoughtime +.loop cmp.w fw_FrameCounter(a6),d0 + bmi.s .endwait + move.w d0,-(sp) + bsr fw_VSyncWithTask + move.w (sp)+,d0 bra.s .loop + ELSE +.spin cmp.w fw_FrameCounter(a6),d0 + bpl.s .spin + ENDC .endwait - PUTMSG 10,<"%d: Waiting done">,fw_FrameCounterLong(a6) + PUTMSG 20,<"%d: Waiting done">,fw_FrameCounter-2(a6) rts ;-------------------------------------------------------------------- @@ -155,11 +186,15 @@ fw_FlushCaches: IF FW_COPPER_IRQ_SUPPORT fw_copper_irq: + IF FW_A5_A6_UNTOUCHED PUSHM d0/a0/a5/a6 lea $dff000,a5 - move.w #INTF_COPER,intreq(a5) ;acknowledge the copper-irq. - move.w #INTF_COPER,intreq(a5) ;acknowledge the copper-irq. move.l fw_BasePtr(pc),a6 + ELSE + PUSHM d0/a0 + ENDC + move.w #INTF_COPER,intreq(a5) ;acknowledge the copper-irq. + move.w #INTF_COPER,intreq(a5) ;acknowledge the copper-irq. move.l fw_CopperIRQ(a6),d0 beq.s .nocop move.l d0,a0 @@ -176,21 +211,29 @@ fw_vblank_standard_irq: btst #INTB_COPER,$dff000+intreqr+1 bne.s fw_copper_irq ENDC + + IF FW_A5_A6_UNTOUCHED + IF FW_VBL_IRQ_SUPPORT|(FW_MUSIC_SUPPORT&FW_VBL_MUSIC_IRQ) + PUSHM d0-d3/a0-a3 + ENDC + ELSE IF FW_VBL_IRQ_SUPPORT|(FW_MUSIC_SUPPORT&FW_VBL_MUSIC_IRQ) PUSHM d0-d3/a0-a3/a5/a6 ELSE PUSHM a5/a6 ENDC lea $dff000,a5 + move.l fw_BasePtr(pc),a6 + ENDC move.w #INTF_VERTB,intreq(a5) ;acknowledge the VBL-irq. move.w #INTF_VERTB,intreq(a5) ;acknowledge the VBL-irq. - move.l fw_BasePtr(pc),a6 addq.w #1,fw_FrameCounter(a6) IF (FW_MUSIC_SUPPORT&FW_VBL_MUSIC_IRQ) - tst.w fw_MusicEnabled(a6) + move.l fw_MusicTickRoutine(a6),d0 beq.s .skipmus - bsr fw_MusicPlay + move.l d0,a0 + jsr (a0) ; IRQ must maintain d4-d7/a4 .skipmus ENDC IF FW_VBL_IRQ_SUPPORT @@ -200,6 +243,57 @@ fw_vblank_standard_irq: jsr (a0) ; IRQ must maintain d4-d7/a4 .novbl ENDC + + IF FW_A5_A6_UNTOUCHED + IF FW_VBL_IRQ_SUPPORT|(FW_MUSIC_SUPPORT&FW_VBL_MUSIC_IRQ) POPM + ENDC + ELSE + POPM + ENDC nop - rte \ No newline at end of file + rte + + IF FW_SOFT_IRQ_SUPPORT +fw_softint_irq: + IFEQ FW_A5_A6_UNTOUCHED + PUSHM a5/a6 + lea $dff000,a5 + move.l fw_BasePtr(pc),a6 + ENDC + move.w #INTF_SOFTINT,intreq(a5) + pea .skip(pc) + move.l fw_SoftIRQ(a6),-(sp) + beq.s .nopsy + rts +.nopsy addq.l #8,sp +.skip + IFEQ FW_A5_A6_UNTOUCHED + POPM + ENDC + nop + rte + ENDC + + IF FW_AUDIO_IRQ_SUPPORT +fw_audio_irq: + PUTMSG 60,<"INT %lx">,$dff000+intenar + IFEQ FW_A5_A6_UNTOUCHED + PUSHM a5/a6 + lea $dff000,a5 + move.l fw_BasePtr(pc),a6 + ENDC + move.w #INTF_AUD0|INTF_AUD1|INTF_AUD2|INTF_AUD3,intreq(a5) + pea .skip(pc) + move.l fw_AudioIRQ(a6),-(sp) + beq.s .noaud + rts ; IRQ must maintain d0-d7/a1-a4 +.noaud addq.l #8,sp +.skip + IFEQ FW_A5_A6_UNTOUCHED + POPM + ENDC + nop + rte + + ENDC diff --git a/source/framework/framework_multipart.asm b/source/framework/framework_multipart.asm index 2aa5434..6fd6279 100644 --- a/source/framework/framework_multipart.asm +++ b/source/framework/framework_multipart.asm @@ -34,7 +34,7 @@ ; with all your variable space cleared. ; ; Make sure that you don't free the memory allocated here until -; the end of your part! The demo framework will call +; the end of your part! The demo framework will call ; RestoreFrameworkBase automatically at exit of your part. ; ; Flushes the caches (if available), too. @@ -44,7 +44,7 @@ ; Trashes: everything except a5/a6 ; fw_InitPart: - PUTMSG 10,<"%d: InitPart(%ld)">,fw_FrameCounterLong(a6),d0 + PUTMSG 10,<"%d: InitPart(%ld)">,fw_FrameCounter-2(a6),d0 PUSHM d0 bsr fw_RestoreFrameworkBase POPM @@ -67,8 +67,8 @@ fw_InitPart: move.l a6,fw_PartFwBase(a6) move.l fw_PartDataSize(a6),d7 - addq.w #3,d7 - lsr.w #2,d7 + sub.l #fw_SIZEOF-3,d7 + lsr.l #2,d7 beq.s .skipclr subq.w #1,d7 moveq.l #0,d0 @@ -98,7 +98,7 @@ fw_InitPart: move.l a6,(a0) bsr fw_FlushCaches ENABLE_INTS - PUTMSG 20,<"%d: InitPart done %p">,fw_FrameCounterLong(a6),a6 + PUTMSG 20,<"%d: InitPart done %p">,fw_FrameCounter-2(a6),a6 rts ;-------------------------------------------------------------------- @@ -111,7 +111,7 @@ fw_InitPart: ; Trashes: everything except a5/a6 ; fw_RestoreFrameworkBase: - PUTMSG 10,<"%d: RestoreFrameworkBase(%p)">,fw_FrameCounterLong(a6),a6 + PUTMSG 10,<"%d: RestoreFrameworkBase(%p)">,fw_FrameCounter-2(a6),a6 DISABLE_INTS move.l fw_PartFwBase(a6),a0 move.l fw_PrimaryFwBase(a6),a1 @@ -206,6 +206,6 @@ fw_FixA6BaseInTaskStacks: fw_lvo_offsets: FWGENLVOTABLE SET 1 - include "../framework/framework_lvos.i" + include "framework_lvos.i" dc.w 0 FWGENLVOTABLE SET 0 diff --git a/source/framework/framework_music.asm b/source/framework/framework_music.asm index b0557f8..d87bc4b 100644 --- a/source/framework/framework_music.asm +++ b/source/framework/framework_music.asm @@ -8,16 +8,15 @@ fw_StartMusic: move.l fw_MusicData(a6),a0 move.l fw_MusicSamples(a6),a1 bsr fw_MusicInit - move.w #1,fw_MusicEnabled(a6) rts ;-------------------------------------------------------------------- ; Stops the music playback if music is active ; fw_StopMusic: - tst.w fw_MusicEnabled(a6) + tst.l fw_MusicTickRoutine(a6) bne.s .cont rts -.cont clr.w fw_MusicEnabled(a6) +.cont clr.l fw_MusicTickRoutine(a6) bra fw_MusicStop diff --git a/source/framework/framework_palettelerp.asm b/source/framework/framework_palettelerp.asm index 2f0a309..808ecd6 100644 --- a/source/framework/framework_palettelerp.asm +++ b/source/framework/framework_palettelerp.asm @@ -106,7 +106,7 @@ fw_FadePaletteTo: ror.w #4,d1 move.w cl_Red+le_Current(a1),d3 lsr.w #1,d1 - add.w #$80,d1 + add.w #$400,d1 lsr.w #1,d3 sub.w d3,d1 asr.w d2,d1 @@ -118,7 +118,7 @@ fw_FadePaletteTo: clr.b d1 move.w cl_Green+le_Current(a1),d3 lsr.w #1,d1 - add.w #$80,d1 + add.w #$400,d1 lsr.w #1,d3 sub.w d3,d1 asr.w d2,d1 @@ -129,7 +129,7 @@ fw_FadePaletteTo: ror.w #4,d1 move.w cl_Blue+le_Current(a1),d3 lsr.w #1,d1 - add.w #$80,d1 + add.w #$400,d1 lsr.w #1,d3 sub.w d3,d1 asr.w d2,d1 @@ -158,6 +158,7 @@ fw_DoFadePaletteStep: moveq.l #0,d4 .loop addq.w #2,a1 +.loop2 move.w (a1),d1 ; cl_Steps beq.s .skip moveq.l #1,d4 @@ -184,10 +185,81 @@ fw_DoFadePaletteStep: dbra d0,.loop rts .skip - lea cl_SIZEOF-2(a1),a1 - dbra d0,.loop + lea cl_SIZEOF(a1),a1 + dbra d0,.loop2 + subq.w #2,a1 tst.w d4 bne.s .noend st (a0) .noend rts + + IFEQ FW_PALETTE_LERP_SUPPORT-2 +; a1 = lerp structures +; d0 = number of colors +fw_DoFadePaletteStepBlueNoise: + move.l fw_BlueNoiseTablePtr(a6),a0 + move.w #1024*2,d2 + move.w d0,d1 + add.w d1,d1 + add.w d0,d1 + add.w d1,d1 + sub.w d1,d2 + move.w fw_BlueNoisePos(a6),d1 + cmp.w d2,d1 + blt.s .nowrap + sub.w d2,d1 +.nowrap + adda.w d1,a0 + add.w d0,d1 + add.w d0,d1 + move.w d1,fw_BlueNoisePos(a6) + subq.w #1,d0 + bcc.s .loop + rts +.loop + addq.w #2,a1 + move.w (a1),d1 ; cl_Steps + beq.s .skip + subq.w #1,d1 + move.w d1,(a1)+ ; cl_Steps + move.w (a1)+,d1 ; cl_Red+le_Add + add.w (a1),d1 ; cl_Red+le_Current + move.w d1,(a1)+ ; cl_Red+le_Current + move.w (a1)+,d2 ; cl_Green+le_Add + add.w (a1),d2 ; cl_Green+le_Current + move.w d2,(a1)+ ; cl_Green+le_Current + move.w (a1)+,d3 ; cl_Blue+le_Add + add.w (a1),d3 ; cl_Blue+le_Current + move.w d3,(a1)+ ; cl_Blue+le_Current + + bra.s .addnoise +.skip + addq.w #2,a1 + movem.l (a1)+,d1/d2/d3 ; cl_Red/cl_Green/cl_Blue+le_Current +.addnoise + add.w (a0)+,d1 + bcc.s .nofr + moveq.l #-1,d1 +.nofr + add.w (a0)+,d2 + bcc.s .nofg + moveq.l #-1,d2 +.nofg + add.w (a0)+,d3 + bcc.s .nofb + moveq.l #-1,d3 +.nofb + lsr.w #4,d1 + moveq.l #15,d2 + rol.w #4,d3 + and.w d2,d3 + moveq.l #-16,d2 + and.b cl_Green+le_Current-(cl_Blue+le_Current+2)(a1),d2 + or.b d3,d2 + move.b d2,d1 + move.w d1,-cl_SIZEOF(a1) ; cl_Color + dbra d0,.loop + rts + + ENDC diff --git a/source/framework/framework_scripting.asm b/source/framework/framework_scripting.asm index fa96779..dedb5bc 100644 --- a/source/framework/framework_scripting.asm +++ b/source/framework/framework_scripting.asm @@ -14,7 +14,7 @@ ; In : a0 = script pointer ; fw_InstallScript: - PUTMSG 10,<"%d: Script at %p installed">,fw_FrameCounterLong(a6),a0 + PUTMSG 10,<"%d: Script at %p installed">,fw_FrameCounter-2(a6),a0 move.l a0,fw_ScriptPointer(a6) move.w fw_FrameCounter(a6),fw_ScriptFrameOffset(a6) rts @@ -37,7 +37,7 @@ fw_CheckScript: move.w (a0)+,d0 move.l a0,fw_ScriptPointer(a6) pea -2(a0,d0.w) - PUTMSG 10,<"%d: Script hit %p">,fw_FrameCounterLong(a6),(sp) + PUTMSG 10,<"%d: Script hit %p">,fw_FrameCounter-2(a6),(sp) tst.w (a0) bne.s .exit PUTMSG 10,<"Script terminated."> @@ -48,7 +48,7 @@ fw_CheckScript: ;-------------------------------------------------------------------- ; Install a music-frame based script ; -; Routines of the script will be executed via CheckMusicScript once +; Routines of the script will be executed via CheckMusicScript once ; the given absolute music frame numbers have been reached (or passed). ; ; A script is built in this way: @@ -60,7 +60,7 @@ fw_CheckScript: ; In : a0 = script pointer ; fw_InstallMusicScript: - PUTMSG 10,<"%d: MusicScript at %p installed">,fw_FrameCounterLong(a6),a0 + PUTMSG 10,<"%d: MusicScript at %p installed">,fw_FrameCounter-2(a6),a0 move.l a0,fw_MusicScriptPointer(a6) rts @@ -81,7 +81,7 @@ fw_CheckMusicScript: move.w (a0)+,d0 move.l a0,fw_MusicScriptPointer(a6) pea -2(a0,d0.w) - PUTMSG 10,<"%d: MusicScript (%d) hit %p">,fw_FrameCounterLong(a6),fw_MusicFrameCount-2(a6),(sp) + PUTMSG 10,<"%d: MusicScript (%d) hit %p">,fw_FrameCounter-2(a6),fw_MusicFrameCount-2(a6),(sp) tst.w (a0) bne.s .exit PUTMSG 10,<"MusicScript terminated."> diff --git a/source/framework/framework_sinetable.asm b/source/framework/framework_sinetable.asm index 267bbaa..7ba4e3c 100644 --- a/source/framework/framework_sinetable.asm +++ b/source/framework/framework_sinetable.asm @@ -7,7 +7,7 @@ ; accessible through the fw_SinTable(a6) and fw_CosTable(a6) base pointers. ; fw_InitSineTable: - PUTMSG 10,<"%d: Script at %p installed">,fw_FrameCounterLong(a6),a0 + PUTMSG 10,<"%d: Init Sine table %p">,fw_FrameCounter-2(a6),a0 IF FW_DYNAMIC_MEMORY_SUPPORT move.l #(1024+256)*2,d0 bsr fw_AllocFast @@ -23,7 +23,6 @@ fw_InitSineTable: move.l a1,fw_FastMemStack(a6) ENDC - PUTMSG 10,<"%d: Init Sine table %p">,fw_FrameCounterLong(a6),a0 moveq.l #0,d0 ; amp=16384, length=1024 move.w #511+2,a1 .loop subq.l #2,a1 @@ -53,5 +52,5 @@ fw_InitSineTable: .cloop move.l (a0)+,(a1)+ dbra d0,.cloop - PUTMSG 10,<"%d: Sine table done">,fw_FrameCounterLong(a6) + PUTMSG 10,<"%d: Sine table done">,fw_FrameCounter-2(a6) rts diff --git a/source/framework/framework_tasks.asm b/source/framework/framework_tasks.asm index 8bb6f63..7aeebee 100644 --- a/source/framework/framework_tasks.asm +++ b/source/framework/framework_tasks.asm @@ -32,7 +32,7 @@ fw_InitTasks: ; Out: All registers are unchanged. ; fw_AddTask: - PUTMSG 10,<"%d: AddTask(%p,%p,%s)">,fw_FrameCounterLong(a6),a0,a1,LN_NAME(a1) + PUTMSG 10,<"%d: AddTask(%p,%p,%s)">,fw_FrameCounter-2(a6),a0,a1,LN_NAME(a1) tst.l ft_USP(a1) bne fw_Error IF FW_TOP_BOTTOM_MEM_SECTIONS @@ -59,7 +59,7 @@ fw_AddTask: .cleanup ;move.l fw_BasePtr(pc),a6 move.l (sp)+,a1 ; suppress M68kDeadWrite used by REMOVE - PUTMSG 10,<"%d: background task %p (%s) finished">,fw_FrameCounterLong(a6),a1,LN_NAME(a1) + PUTMSG 10,<"%d: background task %p (%s) finished">,fw_FrameCounter-2(a6),a1,LN_NAME(a1) .waitforsafearea move.l #$1ff00,d0 @@ -111,6 +111,9 @@ fw_KillTaskContext: clr.l fw_PrimaryUSP(a6) move.w fw_MainCurrentFrame(a6),d0 ENABLE_INTS + btst #DMAB_BLTDONE-8,dmaconr(a5) + beq.s .loop + BLTHOGON .loop cmp.w fw_FrameCounter(a6),d0 beq.s .loop rts @@ -130,6 +133,10 @@ fw_VSyncWithTask: bgt fw_VSync IF FW_LMB_EXIT_SUPPORT + IFEQ FW_LMB_EXIT_SUPPORT-2 + tst.w fw_DisableLMBExit(a6) + bne.s .noabort + ENDC btst #6,$bfe001 beq .abortdemo .noabort @@ -246,7 +253,7 @@ fw_RemTask: tst.l ft_USP(a1) bne.s .remove rts -.remove PUTMSG 10,<"%d: Removing still running task %p (%s)">, +.remove PUTMSG 10,<"%d: Removing still running task %p (%s)">,fw_FrameCounter-2(a6),a1,LN_NAME(a1) clr.l ft_USP(a1) REMOVE rts @@ -309,9 +316,10 @@ fw_backgroundtask_restore_irq: addq.w #1,fw_FrameCounter(a6) IF (FW_MUSIC_SUPPORT&FW_VBL_MUSIC_IRQ) - tst.w fw_MusicEnabled(a6) + move.l fw_MusicTickRoutine(a6),d0 beq.s .skipmus - bsr fw_MusicPlay + move.l d0,a0 + jsr (a0) ; IRQ must maintain d4-d7/a4 .skipmus ENDC @@ -388,7 +396,7 @@ fw_AddAndRunBlitterTask: ENABLE_INTS rts .irqcleanup - PUTMSG 30,<"%d: blitter task finished">,fw_FrameCounterLong(a6) + PUTMSG 30,<"%d: blitter task finished">,fw_FrameCounter-2(a6) move.l fw_VBR(a6),a0 move.l fw_DefaultIRQ(a6),$6c(a0) clr.l fw_BackgroundTask(a6) ; make sure we don't have a stray pointer diff --git a/source/framework/framework_trackloader.asm b/source/framework/framework_trackloader.asm index 840f305..f121542 100644 --- a/source/framework/framework_trackloader.asm +++ b/source/framework/framework_trackloader.asm @@ -371,7 +371,7 @@ fw_TrackloaderLoadAndDecrunchLZ4Delta8: ;-------------------------------------------------------------------- ; Waits for a diskchange (disk is removed and inserted again) -; +; fw_TrackloaderWaitForDiskChange: PUSHM a4 lea $bfd100,a4 @@ -394,7 +394,7 @@ fw_TrackloaderWaitForDiskChange: ; d1.l - bytes to read (may be odd, but one extra byte will be written then) ; returns a1 end of buffer written fw_LoadMFM: - PUTMSG 10,<"%d: LoadMFM of %ld bytes at offset %ld to %p">,fw_FrameCounterLong(a6),d1,d0,a0 + PUTMSG 10,<"%d: LoadMFM of %ld bytes at offset %ld to %p">,fw_FrameCounter-2(a6),d1,d0,a0 IF FW_MULTITASKING_SUPPORT .retry subq.w #1,fw_TrackloaderIdle(a6) @@ -474,7 +474,7 @@ fw_LoadMFM: .finished move.l a3,a1 POPM - PUTMSG 10,<"%d: Data load finished">,fw_FrameCounterLong(a6) + PUTMSG 10,<"%d: Data load finished">,fw_FrameCounter-2(a6) IF FW_MULTITASKING_SUPPORT addq.w #1,fw_TrackloaderIdle(a6) ENDC @@ -483,7 +483,7 @@ fw_LoadMFM: ; Prefetch the next track to be loaded (but not decoded) into MFM buffer fw_PreparePrefetchOfNextTrack: - PUTMSG 20,<"%d: PreparePrefetchOfNextTrack %d+1 (%d:%d)">,fw_FrameCounterLong(a6),fw_LastMfmTrack-2(a6),fw_CurrentCylinder-2(a6),fw_CurrentHead-2(a6) + PUTMSG 20,<"%d: PreparePrefetchOfNextTrack %d+1 (%d:%d)">,fw_FrameCounter-2(a6),fw_LastMfmTrack-2(a6),fw_CurrentCylinder-2(a6),fw_CurrentHead-2(a6) PUSHM d6 clr.w fw_MfmDoPrefetch(a6) tst.w fw_MfmReadingTriggered(a6) @@ -696,7 +696,7 @@ fw_FindRightFloppyDriveUnit: ; turn the floppy motor on and wait until the motor is running fw_MotorOn: - PUTMSG 10,<"%d: Motor on">,fw_FrameCounterLong(a6) + PUTMSG 10,<"%d: Motor on">,fw_FrameCounter-2(a6) move.w fw_CurrentDrive(a6),d0 addq.w #CIAB_DSKSEL0,d0 or.b #CIAF_DSKSEL0|CIAF_DSKSEL1|CIAF_DSKSEL2|CIAF_DSKSEL3,(a4) @@ -720,7 +720,7 @@ fw_MotorOff: .retry tst.w fw_MfmReadingTriggered(a6) beq.s .noreadinginprogress - PUTMSG 10,<"%d: Waiting for read to finish before turning off motor">,fw_FrameCounterLong(a6) + PUTMSG 10,<"%d: Waiting for read to finish before turning off motor">,fw_FrameCounter-2(a6) bsr fw_WaitForTrackDmaDone .noreadinginprogress IF FW_MULTITASKING_SUPPORT @@ -730,7 +730,7 @@ fw_MotorOff: bra.s .retry ENDC .nowait - PUTMSG 10,<"%d: Motor Off">,fw_FrameCounterLong(a6) + PUTMSG 10,<"%d: Motor Off">,fw_FrameCounter-2(a6) move.w fw_CurrentDrive(a6),d0 addq.w #CIAB_DSKSEL0,d0 bset d0,(a4) @@ -752,7 +752,7 @@ fw_TriggerReadTrack: PUTMSG 30,<"MfmTrack already read %d">,d0 rts .cont - PUTMSG 20,<"%d: Triggered reading of track %d">,fw_FrameCounterLong(a6),d0 + PUTMSG 20,<"%d: Triggered reading of track %d">,fw_FrameCounter-2(a6),d0 clr.w fw_MfmReadingDone(a6) move.w d0,fw_LastMfmTrack(a6) @@ -779,7 +779,7 @@ fw_WaitForTrackDmaDone: rts .waitdma .rereadwaitdma - PUTMSG 40,<"%d: MFM Wait">,fw_FrameCounterLong(a6) + PUTMSG 40,<"%d: MFM Wait">,fw_FrameCounter-2(a6) IF FW_MULTITASKING_SUPPORT bra.s .firstskipyield ENDC @@ -788,7 +788,7 @@ fw_WaitForTrackDmaDone: .firstskipyield btst #INTB_DSKBLK,intreqr+1(a5) ; wait until data read beq.s .waitdmadone - PUTMSG 20,<"%d: MFM Done">,fw_FrameCounterLong(a6) + PUTMSG 20,<"%d: MFM Done">,fw_FrameCounter-2(a6) st fw_MfmReadingDone(a6) clr.w fw_MfmReadingTriggered(a6) rts @@ -799,7 +799,7 @@ fw_DecodeMfmTrack: .rereadwaitdma bsr fw_WaitForTrackDmaDone - PUTMSG 20,<"%d: Decoding Track %d">,fw_FrameCounterLong(a6),fw_LastMfmTrack-2(a6) + PUTMSG 20,<"%d: Decoding Track %d">,fw_FrameCounter-2(a6),fw_LastMfmTrack-2(a6) move.w #-1,fw_LastTrack(a6) ; mark last track buffer as invalid in case of error move.l #$55555555,d3 ; and-const @@ -881,7 +881,7 @@ fw_DecodeMfmTrack: move.w fw_LastMfmTrack(a6),fw_LastTrack(a6) move.w fw_LastMfmTrack(a6),d0 ext.l d0 - PUTMSG 10,<"%d: Decoded Track %d">,fw_FrameCounterLong(a6),d0 + PUTMSG 10,<"%d: Decoded Track %d">,fw_FrameCounter-2(a6),d0 POPM rts diff --git a/source/framework/musicplayers/lightspeedplayer.asm b/source/framework/musicplayers/lightspeedplayer.asm index 7258958..8ce8b16 100644 --- a/source/framework/musicplayers/lightspeedplayer.asm +++ b/source/framework/musicplayers/lightspeedplayer.asm @@ -186,16 +186,15 @@ LSP_MusicInit: move.w (a0)+,d0 ; codes table size move.l a0,fw_LspCodeTableAddr(a6) ; code table add.w d0,d0 - add.w d0,a0 + adda.w d0,a0 ; read sequence timing infos (if any) move.w (a0)+,d0 move.w d0,(a3)+ ; fw_LspSeqCount move.l a0,(a3)+ ; fw_LspSeqTable clr.w (a3)+ ; fw_LspCurrentSeq - move.w d0,d1 - lsl.w #3,d1 ; 8 bytes per entry - adda.w d1,a0 + lsl.w #3,d0 ; 8 bytes per entry + adda.w d0,a0 movem.l (a0)+,d0/d1/d2 ; word stream size/byte stream loop point/word stream loop point move.l a0,(a3)+ ; fw_LspStreamBase diff --git a/source/framework/musicplayers/lightspeedplayer_cia.asm b/source/framework/musicplayers/lightspeedplayer_cia.asm index e0f66e0..9bb055f 100644 --- a/source/framework/musicplayers/lightspeedplayer_cia.asm +++ b/source/framework/musicplayers/lightspeedplayer_cia.asm @@ -53,6 +53,8 @@ LSP_MusicDriver_CIA_Start: ; d1: PAL(0) or NTSC(1) .LSP_IrqInstall move.w #INTF_EXTER,intena(a5) ; disable CIA interrupt + lea LSP_MusicPlayTick(pc),a0 + move.l a0,fw_MusicTickRoutine(a6) lea .LSP_MainIrq(pc),a0 move.l fw_VBR(a6),a2 move.l a0,$78(a2) @@ -92,7 +94,8 @@ LSP_MusicDriver_CIA_Start: ; call player tick lea $dff000,a5 move.l fw_BasePtr(pc),a6 - bsr LSP_MusicPlayTick ; LSP main music driver tick + move.l fw_MusicTickRoutine(a6),a0 + jsr (a0) ; LSP main music driver tick ; check if BMP changed in the middle of the music lea $bfd000,a4 diff --git a/source/framework/musicplayers/lightspeedplayer_micro.asm b/source/framework/musicplayers/lightspeedplayer_micro.asm new file mode 100644 index 0000000..a78ac62 --- /dev/null +++ b/source/framework/musicplayers/lightspeedplayer_micro.asm @@ -0,0 +1,158 @@ +;***************************************************************** +; +; Light Speed Player v1.20 +; Fastest Amiga MOD player ever :) +; Written By Arnaud Carré (aka Leonard / OXYGENE) +; Adapted to demo framework (and optimized) by platon42. +; https://github.com/arnaud-carre/LSPlayer +; twitter: @leonard_coder +; +; "micro mode" player version ( average time: 1.5 scanline ) +; This mode focus on music data compression ratio. Suited for 4KiB or small intros +; Do not support various BPM, music getPos/setPos and sample without a note +; +; You can also use classic "standard" player to support all features +; Or you can use generated "ultra fast" player code for half scanline replayer ("-insane" option) +; +; LSP_MusicInitMicro Initialize a LSP driver + relocate score&bank music data +; LSP_MusicPlayTickMicro Play a LSP music (call it per frame) +; +;***************************************************************** + +;------------------------------------------------------------------ +; +; LSP_MusicInitMicro +; +; In: a0: LSP music data(any memory) +; a1: LSP sound bank(chip memory) +; +;------------------------------------------------------------------ +;LSP_dataError: illegal + +LSP_MusicInitMicro: + IF 0 + cmpi.l #'LSPm',(a0)+ ; LSP "micro" mode signature + bne.s LSP_dataError + cmpi.w #$0118,(a0)+ ; this play routine supports v1.24 as minimal version of LPConvert.exe + blt.s LSP_dataError + ELSE + addq.l #6,a0 + ENDC + lea fw_LspLastDmaCon(a6),a2 + clr.w (a2)+ ; fw_LspLastDmaCon + move.w (a0)+,(a2)+ ; fw_LspCurrentBpm, default song BPM + move.w (a0)+,d7 ; instrument count + move.l a0,(a2)+ ; fw_LspInstruments, instrument tab addr + move.l a1,d1 + subq.w #1,d7 +.relocloop + add.l d1,(a0) + addq.l #6,a0 + add.l d1,(a0) + addq.l #6,a0 + dbra d7,.relocloop + ;lea fw_LspStreams(a6),a2 + lea 16*4(a0),a1 + ; do not stress about this rept, your exe packer will enjoy it + REPT 16 + move.l (a0)+,d1 + add.l a1,d1 + move.l d1,fw_LspLoopStreams-fw_LspStreams(a2) ; set loopStreams at 0 by default + move.l d1,(a2)+ + ENDR + bset.b #1,$bfe001 ; disabling this fucking Low pass filter!! + rts + +;------------------------------------------------------------------ +; +; LSP_MusicPlayTickMicro +; +; In: a5: should be $dff000 +; Out:None +; +;------------------------------------------------------------------ +LSP_MusicPlayTickMicro: + move.w fw_LspLastDmaCon(a6),d0 + beq.s .skip + lea fw_LspResetv(a6),a3 + lea aud+4*ac_SIZEOF(a5),a2 + moveq.l #4-1,d7 +.rloop lea -ac_SIZEOF(a2),a2 + btst d7,d0 + beq.s .norst + move.l (a3)+,ac_ptr(a2) + move.w (a3)+,ac_len(a2) +.norst dbra d7,.rloop + +.skip lea fw_LspStreams(a6),a1 + moveq.l #0,d3 + lea fw_LspResetv(a6),a3 + lea aud+4*ac_SIZEOF(a5),a2 + moveq.l #4-1,d7 +.vloop lea -ac_SIZEOF(a2),a2 + moveq.l #16,d4 + move.l a1,a4 + move.l (a4),a0 + move.b (a0)+,d0 ; cmd for current voice + move.l a0,(a1)+ ; update cmd stream ptr + adda.w d4,a4 + add.b d0,d0 + bcc.s .novol + move.l (a4),a0 + move.b (a0)+,ac_vol+1(a2) + move.l a0,(a4) +.novol adda.w d4,a4 + add.b d0,d0 + bcc.s .noper + move.l (a4),a0 + move.w (a0)+,ac_per(a2) + move.l a0,(a4) +.noper adda.w d4,a4 + add.b d0,d0 + bcc.s .noinstr + move.l (a4),a0 + moveq.l #0,d1 + move.b (a0)+,d1 + move.l a0,(a4) + + ; prepare instrument + IF 1 + mulu #12,d1 + ELSE + move.w d1,d2 + lsl.w #2,d1 ; x*4 + lsl.w #3,d2 ; x*8 + add.w d2,d1 ; x*(4+8) + ENDIF + move.l fw_LspInstruments(a6),a0 + adda.w d1,a0 + bset d7,d3 + move.l (a0)+,ac_ptr(a2) + move.w (a0)+,ac_len(a2) + move.l (a0)+,(a3)+ + move.w (a0)+,(a3)+ + +.noinstr + dbra d7,.vloop + + move.w d3,dmacon(a5) + move.w d3,fw_LspLastDmaCon(a6) + move.l fw_LspDmaConPatch(a6),a0 + move.b d3,(a0) + + add.b d0,d0 + bcc.s .noloopcmd + + ; backup or restore current song position + lea fw_LspStreams(a6),a0 + lea fw_LspLoopStreams(a6),a1 + add.b d0,d0 + bcc.s .skiprestore + exg a0,a1 +.skiprestore + ; do not stress about this rept, your exe packer will enjoy it + REPT 16 + move.l (a0)+,(a1)+ + ENDR +.noloopcmd + rts diff --git a/source/framework/musicplayers/lightspeedplayer_nano.asm b/source/framework/musicplayers/lightspeedplayer_nano.asm new file mode 100644 index 0000000..3f912a5 --- /dev/null +++ b/source/framework/musicplayers/lightspeedplayer_nano.asm @@ -0,0 +1,170 @@ +;***************************************************************** +; +; Light Speed Player v1.20 +; Fastest Amiga MOD player ever :) +; Written By Arnaud Carré (aka Leonard / OXYGENE) +; Adapted to demo framework (and optimized) by platon42. +; https://github.com/arnaud-carre/LSPlayer +; twitter: @leonard_coder +; +; "nano mode" player version (average time: 1-2 scanlines) +; This mode focus on music data compression ratio. Suited for 4KiB or small intros +; Only supports VBL timing, 32 KB max stream data, no portamentos/slides, +; no support for music getPos/setPos and sample without a note +; +; You can also use classic "standard" player to support all features +; Or you can use generated "ultra fast" player code for half scanline replayer ("-insane" option) +; +; LSP_MusicInitNano Initialize a LSP driver + relocate score&bank music data +; LSP_MusicPlayTickNano Play a LSP music (call it per frame) +; +;***************************************************************** + +;------------------------------------------------------------------ +; +; LSP_MusicInitNano +; +; In: a0: LSP music data(any memory) +; a1: LSP sound bank(chip memory) +; +;------------------------------------------------------------------ + +LSP_MusicInitNano: + lea fw_LspPeriodTable(a6),a2 + IF 0 + move.w #$e2b3,d0 + move.l #$0fc0fd20,d2 + moveq.l #0,d3 + moveq.l #36-1,d7 +.ploop mulu #61865,d0 + swap d0 + move.w d0,d1 + lsr.w #6,d1 + add.l d2,d2 + subx.w d3,d1 + move.w d1,(a2)+ + dbra d7,.ploop + ELSE + move.w #$e2b3,d0 + moveq.l #36-1,d7 +.ploop mulu #61865,d0 + swap.w d0 + move.w d0,d1 + lsr.w #6,d1 + move.w d1,(a2)+ + dbra d7,.ploop + ENDC + + clr.w (a2)+ ; fw_LspLastDmaCon + move.w (a0)+,d7 ; instrument count-1 + move.l a0,(a2)+ ; fw_LspInstruments, instrument tab addr + move.l a1,d0 +.relocloop + add.l d0,(a0) + addq.l #6,a0 + add.l d0,(a0) + addq.l #6,a0 + dbra d7,.relocloop + + ; do not stress about this rept, your exe packer will enjoy it + REPT 16 + move.l a0,a1 + adda.w (a0)+,a1 + move.l a1,fw_LspLoopStreams-fw_LspStreams(a2) ; set loopStreams at 0 by default + move.l a1,(a2)+ + ENDR + bset.b #1,$bfe001 ; disabling this fucking Low pass filter!! + + rts + +;------------------------------------------------------------------ +; +; LSP_MusicPlayTickNano +; +; In: a5: should be $dff000 +; Out:None +; +;------------------------------------------------------------------ +LSP_MusicPlayTickNano: + move.w fw_LspLastDmaCon(a6),d0 + beq.s .skip + lea fw_LspResetv(a6),a3 + lea aud+4*ac_SIZEOF(a5),a2 + moveq.l #4-1,d7 +.rloop lea -ac_SIZEOF(a2),a2 + btst d7,d0 + beq.s .norst + move.l (a3)+,ac_ptr(a2) + move.w (a3)+,ac_len(a2) +.norst dbra d7,.rloop + +.skip lea fw_LspStreams(a6),a1 + moveq.l #0,d3 + lea fw_LspPeriodTable(a6),a4 + lea fw_LspResetv(a6),a3 + lea aud+4*ac_SIZEOF(a5),a2 + moveq.l #4-1,d7 +.vloop lea -ac_SIZEOF(a2),a2 + move.l (a1),a0 + move.b (a0)+,d1 ; cmd for current voice + move.l a0,(a1) ; update cmd stream ptr + move.w d1,d0 + addq.l #4,a1 + add.b d0,d0 + bcc.s .novol + move.l (a1),a0 + moveq.l #0,d1 + move.b (a0)+,d1 + move.l a0,(a1) + move.w d1,ac_vol(a2) +.novol addq.l #4,a1 + add.b d0,d0 + bcc.s .noper + move.l (a1),a0 + moveq.l #0,d1 + move.b (a0)+,d1 + move.l a0,(a1) + move.w (a4,d1.w),ac_per(a2) +.noper addq.l #4,a1 + add.b d0,d0 + bcc.s .noinstr + move.l (a1),a0 + moveq.l #0,d1 + move.b (a0)+,d1 + move.l a0,(a1) + + ; prepare instrument + move.l fw_LspInstruments(a6),a0 + mulu #12,d1 + adda.w d1,a0 + bset d7,d3 + move.l (a0)+,ac_ptr(a2) + move.w (a0)+,ac_len(a2) + move.l (a0)+,(a3)+ + move.w (a0)+,(a3)+ + +.noinstr + addq.l #4,a1 + dbra d7,.vloop + + move.w d3,dmacon(a5) + move.w d3,fw_LspLastDmaCon(a6) + move.l fw_LspDmaConPatch(a6),a0 + move.b d3,(a0) + + add.b d0,d0 + bcc.s .noloopcmd + + ; backup or restore current song position + lea fw_LspStreams(a6),a0 + lea fw_LspLoopStreams(a6),a1 + add.b d0,d0 + bcc.s .skiprestore + exg a0,a1 +.skiprestore + ; do not stress about this rept, your exe packer will enjoy it + REPT 16 + move.l (a0)+,(a1)+ + ENDR +.noloopcmd + rts diff --git a/source/framework/musicplayers/player_lsp_cia.asm b/source/framework/musicplayers/player_lsp_cia.asm index 29a8b6f..de8a900 100644 --- a/source/framework/musicplayers/player_lsp_cia.asm +++ b/source/framework/musicplayers/player_lsp_cia.asm @@ -28,9 +28,12 @@ fw_MusicStop: ;-------------------------------------------------------------------- ; sets the position if supported ; d0.w = new position + IFNE DEBUG_DETAIL +fw_MusicSetPosition EQU LSP_MusicSetPos + ELSE fw_MusicSetPosition: - bra LSP_MusicSetPos + rts + ENDC - - include "../framework/musicplayers/lightspeedplayer_cia.asm" - include "../framework/musicplayers/lightspeedplayer.asm" \ No newline at end of file + include "musicplayers/lightspeedplayer_cia.asm" + include "musicplayers/lightspeedplayer.asm" \ No newline at end of file diff --git a/source/framework/musicplayers/player_lsp_vbl.asm b/source/framework/musicplayers/player_lsp_vbl.asm index bd43cca..60000c6 100644 --- a/source/framework/musicplayers/player_lsp_vbl.asm +++ b/source/framework/musicplayers/player_lsp_vbl.asm @@ -7,6 +7,8 @@ fw_MusicInit: bsr.s LSP_MusicInit moveq.l #-1,d0 move.w d0,fw_MusicFrameCount(a6) + lea fw_MusicPlay(pc),a0 + move.l a0,fw_MusicTickRoutine(a6) PUTMSG 10,<"Music-Init done"> rts @@ -17,6 +19,7 @@ fw_MusicPlay: rts fw_MusicStop: + clr.l fw_MusicTickRoutine(a6) move.w #DMAF_AUDIO,dmacon(a5) ; unsupported right now rts @@ -24,7 +27,11 @@ fw_MusicStop: ;-------------------------------------------------------------------- ; sets the position if supported ; d0.w = new position + IFNE DEBUG_DETAIL +fw_MusicSetPosition EQU LSP_MusicSetPos + ELSE fw_MusicSetPosition: - bra LSP_MusicSetPos + rts + ENDC - include "../framework/musicplayers/lightspeedplayer.asm" + include "musicplayers/lightspeedplayer.asm" diff --git a/source/framework/musicplayers/player_none.asm b/source/framework/musicplayers/player_none.asm index ba69bae..d54e280 100644 --- a/source/framework/musicplayers/player_none.asm +++ b/source/framework/musicplayers/player_none.asm @@ -1,5 +1,4 @@ fw_MusicInit: fw_MusicStop: -fw_MusicPlay: fw_MusicSetPosition: rts diff --git a/source/framework/musicplayers/player_pretracker_std.asm b/source/framework/musicplayers/player_pretracker_std.asm index c32d2ec..80e9e6f 100644 --- a/source/framework/musicplayers/player_pretracker_std.asm +++ b/source/framework/musicplayers/player_pretracker_std.asm @@ -15,7 +15,7 @@ fw_MusicAlloc: rts fw_MusicInit: - PUTMSG 10,<"%d: Pretracker song init %p %p">,fw_FrameCounterLong(a6),a0,a1 + PUTMSG 10,<"%d: Pretracker song init %p %p">,fw_FrameCounter-2(a6),a0,a1 move.l a0,a2 PUSHM d7/a1 move.l fw_PretrackerMyPlayer(a6),a0 @@ -34,7 +34,7 @@ fw_MusicInit: move.l a0,a1 .noalloc - PUTMSG 10,<"%d: Pretracker player init">,fw_FrameCounterLong(a6) + PUTMSG 10,<"%d: Pretracker player init">,fw_FrameCounter-2(a6) move.l fw_PretrackerMyPlayer(a6),a0 move.l fw_PretrackerMySong(a6),a2 @@ -42,17 +42,19 @@ fw_MusicInit: adda.w 6(a3),a3 jsr (a3) ; playerInit - PUTMSG 10,<"%d: Pretracker init done">,fw_FrameCounterLong(a6) + lea fw_MusicPlay(pc),a0 + move.l a0,fw_MusicTickRoutine(a6) + PUTMSG 10,<"%d: Pretracker init done">,fw_FrameCounter-2(a6) rts fw_MusicPlay: move.l fw_PretrackerMyPlayer(a6),a0 lea fw_PretrackerReplayer(pc),a3 adda.w 10(a3),a3 - jsr (a3) ; playerTick - rts + jmp (a3) ; playerTick fw_MusicStop: + clr.l fw_MusicTickRoutine(a6) move.w #DMAF_AUDIO,dmacon(a5) ; unsupported right now rts @@ -60,5 +62,5 @@ fw_MusicStop: ;-------------------------------------------------------------------- fw_PretrackerReplayer: - ;include "../framework/musicplayers/pretracker_replayer_resourced.asm" - incbin "../framework/musicplayers/pretracker_replayer_binary_blob.bin" + ;include "musicplayers/pretracker_replayer_resourced.asm" + incbin "musicplayers/pretracker_replayer_binary_blob.bin" diff --git a/source/framework/musicplayers/player_raspberry_casket.asm b/source/framework/musicplayers/player_raspberry_casket.asm index 7acf314..9348e46 100644 --- a/source/framework/musicplayers/player_raspberry_casket.asm +++ b/source/framework/musicplayers/player_raspberry_casket.asm @@ -5,16 +5,38 @@ fail "FW_DYNAMIC_MEMORY_SUPPORT must be enabled" ENDC + IF (FW_MUSIC_PLAYER_CHOICE==6) + IFND FW_PRETRACKER_JITTER_BUFFER_SIZE +FW_PRETRACKER_JITTER_BUFFER_SIZE = 38*4 ; default is 37 insts + end of copperlist + ENDC + IFND FW_PRETRACKER_NUM_JITTER_BUFFERS +FW_PRETRACKER_NUM_JITTER_BUFFERS = 50 + ENDC + ENDC + fw_MusicAlloc: move.l #pv_SIZEOF+sv_SIZEOF,d0 bsr fw_AllocFast move.l a0,fw_PretrackerMyPlayer(a6) lea pv_SIZEOF(a0),a0 move.l a0,fw_PretrackerMySong(a6) + IF (FW_MUSIC_PLAYER_CHOICE==6) + move.l #FW_PRETRACKER_NUM_JITTER_BUFFERS*FW_PRETRACKER_JITTER_BUFFER_SIZE,d0 + bsr fw_AllocChip + move.l a0,fw_PretrackerCopperlistStart(a6) + move.l a0,fw_PretrackerCopperWritePtr(a6) + lea (FW_PRETRACKER_NUM_JITTER_BUFFERS-1)*FW_PRETRACKER_JITTER_BUFFER_SIZE(a0),a0 + move.l a0,fw_PretrackerCopperReadPtr(a6) + lea FW_PRETRACKER_JITTER_BUFFER_SIZE(a0),a0 + move.l a0,fw_PretrackerCopperlistEnd(a6) + move.l #ft_SIZEOF,d0 + bsr fw_AllocFast + move.l a0,fw_PretrackerBgTask(a6) + ENDC rts fw_MusicInit: - PUTMSG 10,<"%d: Pretracker song init %p %p">,fw_FrameCounterLong(a6),a0,a1 + PUTMSG 10,<"%d: Pretracker song init %p %p">,fw_FrameCounter-2(a6),a0,a1 move.l a0,a2 PUSHM d4-d7/a1/a4-a6 ;move.l fw_PretrackerMyPlayer(a6),a0 ; unused @@ -31,7 +53,7 @@ fw_MusicInit: move.l a0,a1 .noalloc - PUTMSG 10,<"%d: Pretracker player init">,fw_FrameCounterLong(a6) + PUTMSG 10,<"%d: Pretracker player init">,fw_FrameCounter-2(a6) move.l fw_PretrackerMyPlayer(a6),a0 move.l fw_PretrackerMySong(a6),a2 lea fw_PretrackerProgress(a6),a3 @@ -41,31 +63,92 @@ fw_MusicInit: bsr pre_PlayerInit POPM - PUTMSG 10,<"%d: Pretracker init done">,fw_FrameCounterLong(a6) + IF (FW_MUSIC_PLAYER_CHOICE==6) + move.l fw_PretrackerBgTask(a6),a1 + move.b #20,LN_PRI(a1) + lea fw_PretrackerAheadTask(pc),a0 + bsr fw_AddTask + ENDC + + lea fw_MusicPlay(pc),a0 + move.l a0,fw_MusicTickRoutine(a6) + + PUTMSG 10,<"%d: Pretracker init done">,fw_FrameCounter-2(a6) rts + IF (FW_MUSIC_PLAYER_CHOICE==6) +fw_PretrackerAheadTask: + move.l fw_PretrackerCopperWritePtr(a6),a1 +.loop + move.l a1,fw_PretrackerCopperWritePtr(a6) + move.l fw_PretrackerMyPlayer(a6),a0 + PUSHM a1/a5/a6 + bsr pre_PlayerTick + POPM + lea FW_PRETRACKER_JITTER_BUFFER_SIZE(a1),a1 + cmp.l fw_PretrackerCopperlistEnd(a6),a1 + bne.s .nowrap + move.l fw_PretrackerCopperlistStart(a6),a1 +.nowrap +.retry + cmp.l fw_PretrackerCopperReadPtr(a6),a1 + bne.s .loop + bsr fw_Yield + bra.s .retry + +fw_MusicPlay: + move.l fw_PretrackerCopperReadPtr(a6),a1 + lea FW_PRETRACKER_JITTER_BUFFER_SIZE(a1),a1 + cmp.l fw_PretrackerCopperlistEnd(a6),a1 + bne.s .nowrap + move.l fw_PretrackerCopperlistStart(a6),a1 +.nowrap + move.l a1,fw_PretrackerCopperlist(a6) + + cmp.l fw_PretrackerCopperWritePtr(a6),a1 + bne.s .good + PUTMSG 10,<"Pretracker buffer underflow"> + rts +.good move.l a1,fw_PretrackerCopperReadPtr(a6) + rts + +fw_MusicStop: + move.l fw_PretrackerBgTask(a6),a1 + bsr fw_RemTask + clr.l fw_MusicTickRoutine(a6) + move.w #DMAF_AUDIO,dmacon(a5) + ; unsupported right now + rts + + ELSE + fw_MusicPlay: PUSHM d4-d7/a4-a6 move.l fw_PretrackerMyPlayer(a6),a0 + IF (FW_MUSIC_PLAYER_CHOICE>=5) move.l fw_PretrackerCopperlist(a6),a1 + ENDC bsr.s pre_PlayerTick POPM rts fw_MusicStop: + clr.l fw_MusicTickRoutine(a6) move.w #DMAF_AUDIO,dmacon(a5) ; unsupported right now rts + ENDC ;-------------------------------------------------------------------- ; sets the position if supported ; d0.w = new position fw_MusicSetPosition: - move.w d0,fw_PretrackerMySong+sv_curr_pat_pos_w(a6) + move.l fw_PretrackerMyPlayer(a6),a0 + move.w d0,pv_curr_pat_pos_w(a0) rts ;-------------------------------------------------------------------- PRETRACKER_COPPER_OUTPUT = FW_MUSIC_PLAYER_CHOICE-4 PRETRACKER_DONT_TRASH_REGS = 0 - include "../framework/musicplayers/raspberry_casket.asm" + include "musicplayers/raspberry_casket.asm" diff --git a/source/framework/musicplayers/raspberry_casket.asm b/source/framework/musicplayers/raspberry_casket.asm index 2af2525..2398e35 100755 --- a/source/framework/musicplayers/raspberry_casket.asm +++ b/source/framework/musicplayers/raspberry_casket.asm @@ -1,10 +1,10 @@ ;-------------------------------------------------------------------- -; Raspberry Casket Player V1.1 (28-Dec-2022) +; Raspberry Casket Player V2.x (24-Aug-2023) ; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; ; Provided by Chris 'platon42' Hodges ; -; Latest: https://github.com/chrisly42/PretrackerRaspberryCasket +; Latest: https://git.platon42.de/chrisly42/PretrackerRaspberryCasket ; ; Rewritten by platon42/Desire based on a resourced, binary identical ; version of the original Pretracker V1.0 replayer binary provided @@ -16,24 +16,33 @@ ; optimizing the code where possible. This resulted in both reduced ; size of the replayer, faster sample calculation and speeding the ; tick routine up significantly. +; Bugs from the original replayer were fixed. ; ; I also added a few optional features that come in handy, such as ; song-end detection and precalc progress support. ; -; It took me more than a month and it was not fun. -; -; Also: Open source. It's 2022, keeping the code closed is just not +; Also: Open source. It's 2023, keeping the code closed is just not ; part of the demoscene spirit (anymore?), at least for a replayer. ; -; Also note that this is not the final state of the source code. -; I could go over many places still and try to rework them. -; But I wanted the code to be out in public. +; This player is still being optimized and worked on since its +; first release in late 2022. ; ; Verification ; ~~~~~~~~~~~~ -; The replayer has been verified on about 60 Pretracker tunes to -; create an identical internal state for each tick and identical -; samples (if certain optimizations switches are disabled). +; The first versions of the replayer had been verified against about +; 60 Pretracker tunes to create an identical internal state for each tick +; and identical samples (if certain optimizations switches are disabled). +; +; During the process this identical state and identical samples promise +; had to be dropped due to bugs in the original player and optimizations. +; This is especially the case for the track delay feature of Pretracker +; that could in some cases cause odd behaviour and unwanted muting that +; has been fixed in Raspberry Casket. So the verification is now heavily +; reduced to about 20 songs that still are identical. +; +; I do, however, now also have an emulated Paula output verification +; that compares the generated sound between the original code and +; Raspberry Casket. Divergences are manually checked from time to time. ; ; I might have introduced bugs though. If you find some problems, ; please let me know under chrisly@platon42.de. Thank you. @@ -80,27 +89,42 @@ ; Size ; ~~~~ ; The original C compiled code was... just bad. The new binary is -; about 1/3 of the original one. +; less than 1/3rd of the original one. ; ; The code has been also optimized in a way that it compresses better. ; The original code compressed with Blueberry's Shrinkler goes from ; 18052 bytes down to 9023 bytes. ; ; Raspberry Casket, depending on the features compiled in, is about -; 6216 bytes and goes down to ~4348 bytes (in isolation). +; 5716 bytes and shrinkles down to ~4071 bytes (in isolation). ; ; So this means that the optimization is not just "on the outside". ; +; About 2.4 KB of the code (and data) are spent for the sample generation, +; the remaining code for playback. +; ; Timing ; ~~~~~~ -; Sample generation is a bit faster (I guess around 10-15%), but most -; of the time is spent on muls operations, so this is the limiting -; factor. +; +; 1. Sample precalculation +; +; Sample generation is faster than the original 1.0 player and also +; faster than the 1.5 player, which got a slightly better performance +; than the 1.0 one (compiler change?). +; +; According to my measurements on my set of Pretracker tunes, +; Raspberry Casket needs between 10% to 20% less instructions. +; Of these instructions, about 5% are `muls` operations and the new +; player is only able to shave off between 3% and 8% percent of those, +; so this is probably the limiting factor. +; +; 2. Playback ; ; Raspberry Casket is about twice as fast as the old replayer for playback. ; ; Unfortunately, the replayer is still pretty slow and has high ; jitter compared to other standard music replayers. +; ; This means it may take up to 32 raster lines (13-18 on average) ; which is significant more than a standard Protracker replayer ; (the original one could take about 60 raster lines worst case and @@ -109,7 +133,7 @@ ; Watch out for Presto, the LightSpeedPlayer variant that should ; solve this problem. ; -; Changelog see https://github.com/chrisly42/PretrackerRaspberryCasket#Changelog +; Changelog see https://git.platon42.de/chrisly42/PretrackerRaspberryCasket#Changelog ;-------------------------------------------------------------------- ; Here come the various options for you to configure. @@ -162,7 +186,11 @@ PRETRACKER_PARANOIA_MODE = 0 ; I guess this might add some phasing to the sound (which would be ; only audible in a mono mix, I would think), but it comes with an ; extra multiplication per channel. -; If you really want that, enable this switch. +; Moreover, I traced down that this may reduce the Amiga period +; value lower than the minimum allowed value of 124. This may cause +; distortions (like playing a note in Protracker with pitch B-3) +; on the delayed track. +; If you really want (to risk) that, enable this switch. IFND PRETRACKER_DUBIOUS_PITCH_SHIFT_FOR_DELAYED_TRACK PRETRACKER_DUBIOUS_PITCH_SHIFT_FOR_DELAYED_TRACK = 0 ENDC @@ -185,7 +213,7 @@ PRETRACKER_SONG_END_DETECTION = 0 ENDC ; Do you want to have information on the sample generation progress -; during the call to pre_PlayerInit? Then enable this and call w +; during the call to pre_PlayerInit? Then enable this and call ; pre_PlayerInit with a pointer to a longword in a3. ; Please make sure yourself that the initial value is zero. ; It will be incremented by the number of samples (in bytes) @@ -254,398 +282,22 @@ PRETRACKER_DONT_TRASH_REGS = 1 PRETRACKER_COPPER_OUTPUT = 0 ; 0 = standard CPU wait, 1 = Copperlist ENDC -; Pretracker song format description: -; -; $0000 4: PRT ($19 (V0.x), $1b (V1.0), $1e (V1.5)) -; $0004 4: File offset to position data (POSD) -; $0008 4: File offset to pattern data (PATT) -; $000C 4: File offset to instruments (INST) -; $0010 4: File offset to waves (WAVE) -; $0014 20: Songname -; $0028 20: Author -; $003C 1: Restart position for song (<=V1.0) -; $003D 1: Number of patterns (<=V1.0) -; $003E 1: Songlength in patterns (<=V1.0) -; $003F 1: Number of steps per pattern (<=V1.0) -; $0040 1: Number of instruments (<=V1.0), $40 for V1.5 -; $0041 1: Number of waves -; $0042 24: Wave generation ordering (>=V1.0) -; $005a 1: Number of subsongs (>=V1.5) -; [...] -; Position data (POSD): -; - Per subsong (>=V1.5) -; - 1: Restart pos -; - 1: #patterns -; - 1: #numsteps -; - 1: songlength -; - 4: relative pattern offset in pattern data -; - Positions x 4 x [Pattern number (byte), pitch shift (signed byte)] -; -; Pattern data (PATT): -; Each pattern line consists of three bytes: -; - 1 Bit : Bit 4 of Inst Number -; - 1 Bit : ARP instead of effect -; - 6 Bits: Pitch ($01 is C-0, $3d is NOTE OFF) -; -; - 4 Bits: Bit 0-3 of Inst Number -; - 4 Bits: Effect command -; - 8 Bits: Effect data -; - Patterns x steps x 3 bytes -; -; Unknown data after pattern data: (12 10 00 00 00 00) -; -; Instrument definitions (INST): -; - 32 (!) x Null terminated string (or 23 chars max) (for V1.5 this is 64 strings) -; - For each instrument: Instrument Info (ININ) -; - $00 1: Vibrato Delay -; - $01 1: Vibrato Depth -; - $02 1: Vibrato Speed (-1) -; - $03 1: ADSR Attack -; - $04 1: ADSR Decay -; - $05 1: ADSR Sustain -; - $06 1: ADSR Release -; - $07 1: Number of Inst Pattern steps -; -; - For each instrument: -; - 1 Byte: number of steps -; - 3 Bytes x number of steps: Inst Pattern (IPTT) -; -; Inst pattern data (IPTT): -; Each pattern line consists of three bytes: -; - 1 Bit : Next note stitched to this one -; - 1 Bit : Fixed Pitch Note -; - 6 Bits : Pitch ($01 is C-0) -; - 4 Bits : unused? -; - 12 Bits: Effect -; - Patterns x steps x 3 bytes -; -; Wave definitions (WAVE): -; - 24 (!) x Null terminated string (or 23 chars max) -; - Optional padding to even address, if necessary -; - For each wave: -; - 42 Bytes: Wave info structure (see definition below) - -; ---------------------------------------- -; Some constants for clarity - -MAX_VOLUME = $40 -MAX_SPEED = $2f -MAX_WAVES = 24 -MAX_INSTRUMENTS = 32 -MAX_TRACK_DELAY = 32 -NOTE_OFF_PITCH = $3d -NOTES_IN_OCTAVE = 12 -NUM_CHANNELS = 4 ; yes, you can reduce the number of channels if you want - -; ---------------------------------------- -; Pretracker file structures - -; Pattern data (PATT and IPTT) -pdb_pitch_ctrl = 0 -pdb_inst_effect = 1 ; for normal pattern data -pdb_effect_cmd = 1 ; for inst pattern -pdb_effect_data = 2 - -; Pattern pos data (POSD) -ppd_pat_num = 0 -ppd_pat_shift = 1 - -; Instrument Info (ININ) -ii_vibrato_delay = 0 -ii_vibrato_depth = 1 -ii_vibrato_speed = 2 -ii_adsr_attack = 3 -ii_adsr_decay = 4 -ii_adsr_sustain = 5 -ii_adsr_release = 6 -ii_pattern_steps = 7 -ii_SIZEOF = 8 - -; Wave Info (WAVE) -wi_loop_start_w = $00 -wi_loop_end_w = $02 -wi_subloop_len_w = $04 -wi_allow_9xx_b = $06 -wi_subloop_wait_b = $07 -wi_subloop_step_w = $08 -wi_chipram_w = $0a -wi_loop_offset_w = $0c -wi_chord_note1_b = $0e -wi_chord_note2_b = $0f -wi_chord_note3_b = $10 -wi_chord_shift_b = $11 -wi_osc_unknown_b = $12 ; always $00? (unused in code?) -wi_osc_phase_spd_b = $13 -wi_flags_b = $14 ; bit 0/1: osc type, bit 2: needs extra octaves, bit 3: boost, bit 4: pitch linear, bit 5: vol fast -wi_osc_phase_min_b = $15 -wi_osc_phase_max_b = $16 -wi_osc_basenote_b = $17 -wi_osc_gain_b = $18 -wi_sam_len_b = $19 ; in multiples of 128, zero-based (0 == 128) -wi_mix_wave_b = $1a -wi_vol_attack_b = $1b -wi_vol_delay_b = $1c -wi_vol_decay_b = $1d -wi_vol_sustain_b = $1e -wi_flt_type_b = $1f ; 1=lowpass, 2=highpass, 3=bandpass, 4=notch -wi_flt_resonance_b = $20 -wi_pitch_ramp_b = $21 -wi_flt_start_b = $22 -wi_flt_min_b = $23 -wi_flt_max_b = $24 -wi_flt_speed_b = $25 -wi_mod_params_l = $26 -wi_mod_wetness_b = $26 -wi_mod_length_b = $27 -wi_mod_predelay_b = $28 -wi_mod_density_b = $29 ; (1-7), unisono (bits 3/4) and post bit 5 -wi_SIZEOF = $2a - -; ---------------------------------------- -; Unpacked Instrument Info (addition to player for faster processing) - rsreset -uii_vibrato_delay rs.w 1 -uii_vibrato_depth rs.w 1 -uii_vibrato_speed rs.w 1 -uii_adsr_release rs.b 1 - rs.b 1 ; dummy -uii_adsr_attack rs.w 1 -uii_adsr_decay rs.w 1 -uii_adsr_sustain rs.w 1 -uii_pattern_steps rs.b 1 - rs.b 1 ; padding -uii_SIZEOF rs.b 0 - -; ---------------------------------------- -; MySong offsets - rsreset -sv_waveinfo_table rs.l MAX_WAVES ; 24 pointers to wave infos to avoid mulu -sv_inst_patterns_table rs.l MAX_INSTRUMENTS ; 32 pointers to pattern data - ; --- 127 byte displacement limit --- -sv_wavelength_table rs.l MAX_WAVES ; 24 longwords to sample lengths (standard octave) (NEW) -sv_wavetotal_table rs.l MAX_WAVES ; 24 longwords to sample lengths for all octaves (NEW) -sv_wavegen_order_table rs.b MAX_WAVES ; 24 bytes -sv_num_waves_b rs.b 1 -sv_num_steps_b rs.b 1 -sv_patterns_ptr rs.l 1 -sv_curr_pat_pos_w rs.w 1 ; only byte used FIXME why is this part of MySong? Should be in Player -sv_pat_pos_len_w rs.w 1 ; only byte used -sv_pat_restart_pos_w rs.w 1 ; only byte used -sv_pos_data_adr rs.l 1 -sv_waveinfo_ptr rs.l 1 ; base pointer of wave info -sv_pattern_table rs.l 256 -sv_inst_infos_table rs.b MAX_INSTRUMENTS*uii_SIZEOF -sv_SIZEOF rs.b 0 - -; ---------------------------------------- -; channel output data (part of pcd structure below) - rsreset -ocd_sam_ptr rs.l 1 ; 0 -ocd_length rs.w 1 ; 4 -ocd_loop_offset rs.w 1 ; 6 -ocd_period rs.w 1 ; 8 -ocd_volume rs.b 1 ; 10 -ocd_trigger rs.b 1 ; 11 needs to be after volume -ocd_unused rs.l 1 ; 12 unused, but makes the structure an even 16 bytes -ocd_SIZEOF rs.b 0 - -; channel structure (part of pv structure) - rsreset -; DO NOT CHANGE ORDER -- OPTIMIZED CLEARING -pcd_pat_portamento_dest_w rs.w 1 ; portamento destination pitch -pcd_pat_pitch_slide_w rs.w 1 - -pcd_pat_vol_ramp_speed_b rs.b 1 -pcd_pat_2nd_inst_num4_b rs.b 1 -pcd_pat_2nd_inst_delay_b rs.b 1 -pcd_wave_offset_b rs.b 1 - -pcd_inst_pitch_slide_w rs.w 1 -pcd_inst_sel_arp_note_w rs.w 1 - -pcd_inst_note_pitch_w rs.w 1 -pcd_inst_curr_port_pitch_w rs.w 1 - -pcd_inst_line_ticks_b rs.b 1 -pcd_inst_pitch_pinned_b rs.b 1 -pcd_inst_vol_slide_b rs.b 1 -pcd_inst_step_pos_b rs.b 1 - -pcd_inst_wave_num_w rs.w 1 ; current wave number (1 based) (lower byte used) - -pcd_track_delay_offset_b rs.b 1 ; $ff = no track delay -pcd_inst_speed_stop_b rs.b 1 ; speed byte, $ff stops processing -pcd_inst_pitch_w rs.w 1 - -pcd_inst_vol_w rs.w 1 -pcd_loaded_inst_vol_b rs.b 1 -pcd_pat_vol_b rs.b 1 ; Multiplied with volume of instrument. -; DO NOT CHANGE ORDER -- OPTIMIZED CLEARING END - -pcd_arp_notes_l rs.b 0 -pcd_arp_note_1_b rs.b 1 -pcd_arp_note_2_b rs.b 1 -pcd_arp_note_3_b rs.b 1 - rs.b 1 ; gets cleared - -pcd_last_trigger_pos_w rs.w 1 ; I think this makes sure that we don't retrigger the note on same pos - -pcd_pat_portamento_speed_b rs.b 1 -pcd_pat_adsr_rel_delay_b rs.b 1 ; counts down until adsr release. Seems unused? -pcd_note_off_delay_b rs.b 1 ; time before note is released ($ff = disabled) -pcd_inst_pattern_steps_b rs.b 1 ; number of steps in instrument pattern - -pcd_note_delay_b rs.b 1 ; $ff = no note delay -pcd_track_delay_steps_b rs.b 1 ; $00 = no track delay, $ff = stop track delay (this is for the next channel!) -pcd_track_delay_vol16_b rs.b 1 -pcd_track_init_delay_b rs.b 1 ; number of frames to ignore the delay - -pcd_inst_num4_w rs.w 1 ; current instrument number * 4 -;pcd_inst_new_step_w rs.w 1 ; seems to be unused -pcd_inst_subloop_wait_w rs.w 1 -pcd_inst_loop_offset_w rs.w 1 -pcd_inst_info_ptr rs.l 1 ; pointer to currently active instrument - -pcd_waveinfo_ptr rs.l 1 ; pointer to currently active waveinfo -pcd_channel_mask_b rs.b 1 -pcd_channel_num_b rs.b 1 -pcd_adsr_phase_w rs.w 1 ; 0=attack, 1=decay, 2=sustain, 3=release ! do not change order -pcd_adsr_volume_w rs.w 1 ; 0 for restart / $400 (word only) ! do not change order -pcd_adsr_phase_speed_b rs.b 1 -pcd_inst_ping_pong_dir_b rs.b 1 ; direction of ping-pong (-1 == $00 / +1 = $ff) -pcd_adsr_pos_w rs.w 1 ; pos in adsr curve -pcd_adsr_vol64_w rs.w 1 ; some adsr volume - -pcd_new_inst_num_b rs.b 1 ; load new instrument (number) ! do not change order - rs.b 1 ; gets cleared -pcd_vibrato_pos_w rs.w 1 ; -pcd_vibrato_delay_w rs.w 1 ; is a byte value ! do not change order -pcd_vibrato_depth_w rs.w 1 ; is a byte value ! do not change order -pcd_vibrato_speed_w rs.w 1 ; is a byte value ! do not change order -pcd_adsr_release_b rs.b 1 ; is a byte value ! do not change order - rs.b 1 ; padding will be overwritten! - -pcd_out_base rs.b ocd_SIZEOF -pcd_track_delay_buffer rs.b MAX_TRACK_DELAY*ocd_SIZEOF -pcd_SIZEOF rs.b 0 - -pcd_out_ptr_l = pcd_out_base+ocd_sam_ptr -pcd_out_len_w = pcd_out_base+ocd_length -pcd_out_lof_w = pcd_out_base+ocd_loop_offset -pcd_out_per_w = pcd_out_base+ocd_period -pcd_out_vol_b = pcd_out_base+ocd_volume -pcd_out_trg_b = pcd_out_base+ocd_trigger -pcd_out_unused_l = pcd_out_base+ocd_unused ; copied for track delay, but not used? - - rsreset -owb_saw_waves rs.b 128 -owb_sqr_waves rs.b 128 -owb_tri_waves rs.b 128 -owb_wave_length rs.b 1 -owb_SIZEOF rs.b 0 - -; ---------------------------------------- -; MyPlayer global variables (not bound to channel) - rsreset -; DO NOT CHANGE ORDER -- OPTIMIZED INIT -pv_pat_curr_row_b rs.b 1 ; current step -pv_next_pat_row_b rs.b 1 -pv_next_pat_pos_b rs.b 1 -pv_pat_speed_even_b rs.b 1 ; even shuffle speed - -pv_pat_speed_odd_b rs.b 1 ; odd shuffle speed -pv_pat_line_ticks_b rs.b 1 -pv_pat_stopped_b rs.b 1 ; 0 = stop, $ff = run -pv_songend_detected_b rs.b 1 -; DO NOT CHANGE ORDER -- OPTIMIZED INIT END - -pv_loop_pattern_b rs.b 1 ; repeat current pattern, do not advance - rs.b 1 ; padding - -pv_trigger_mask_w rs.w 1 - -pv_my_song rs.l 1 -pv_sample_buffer_ptr rs.l 1 ; pointer to start of sample buffer -pv_copperlist_ptr rs.l 1 -pv_wave_sample_table rs.l MAX_WAVES ; 24 pointers to sample starts -pv_period_table rs.w 16*NOTES_IN_OCTAVE*3 - ; --- 127 byte displacement limit --- -pv_channeldata rs.b NUM_CHANNELS*pcd_SIZEOF - - IFNE PRETRACKER_VOLUME_TABLE -pv_osc_buffers rs.b 0 ; reuse space of volume_table, which is bigger than NOTES_IN_OCTAVE*owb_SIZEOF -pv_volume_table rs.b (MAX_VOLUME+1)*MAX_VOLUME*2 - ELSE -pv_osc_buffers rs.b NOTES_IN_OCTAVE*owb_SIZEOF - ENDC - -pv_precalc_sample_size rs.l 1 -pv_precalc_progress_ptr rs.l 1 -pv_wg_wave_ord_num_w rs.w 1 - IFNE PRETRACKER_PARANOIA_MODE ; same wave for mixing cannot be selected in Pretracker -pv_wg_curr_wave_num_b rs.b 1 - rs.b 1 - ENDC -pv_wg_curr_sample_ptr rs.l 1 -pv_wg_curr_samend_ptr rs.l 1 -pv_wg_curr_sample_len_w rs.w 1 -pv_wg_chord_note_num_b rs.b 1 ; don't change order -pv_wg_unisono_run_b rs.b 1 ; don't change order -pv_wg_chord_flag_w rs.w 1 -pv_wg_chord_pitches rs.l 1 -pv_wg_osc_speed_l rs.l 1 -pv_wg_flt_taps rs.w 4 -pv_SIZEOF rs.b 0 - ;-------------------------------------------------------------------- - include "../includes/hardware/custom.i" - include "../includes/hardware/dmabits.i" - -CLIPTO8BIT MACRO - cmpi.w #-$80,\1 - bge.s .nominclip\@ - moveq.l #-$80,\1 -.nominclip\@ - cmpi.w #$7F,\1 - ble.s .nomaxclip\@ - moveq.l #$7F,\1 -.nomaxclip\@ - ENDM - -CLIPORTRUNC8BIT MACRO - beq.s .unboosted\@ - asr.l #6,\1 - cmpi.w #-$80,\1 - bge.s .nominclip\@ - moveq.l #-$80,\1 -.nominclip\@ - cmpi.w #$7F,\1 - ble.s .nomaxclip\@ - moveq.l #$7F,\1 - bra.s .nomaxclip\@ -.unboosted\@ - asr.l #8,\1 -.nomaxclip\@ - ENDM - -CLIPTO8BITAFTERADD MACRO - bvc.s .noclip\@ - spl \1 - eor.b #$7f,\1 -.noclip\@ - ENDM + include "raspberry_casket.i" + include "hardware/custom.i" + include "hardware/dmabits.i" ;-------------------------------------------------------------------- ; Code starts here IFNE PRETRACKER_KEEP_JUMP_TABLE -pre_FuncTable - dc.l pre_SongInit-pre_FuncTable - dc.l pre_PlayerInit-pre_FuncTable - dc.l pre_PlayerTick-pre_FuncTable +pre_FuncTable: + dc.l pre_SongInit-pre_FuncTable + dc.l pre_PlayerInit-pre_FuncTable + dc.l pre_PlayerTick-pre_FuncTable ENDC - ;dc.b '$VER: Raspberry Casket 1.1',0 + ;dc.b '$VER: Raspberry Casket 1.1',0 ;even IFNE PRETRACKER_COPPER_OUTPUT @@ -722,27 +374,27 @@ pre_PrepareCopperlist: ;******************************************************************** pre_SongInit: IFNE PRETRACKER_DONT_TRASH_REGS - movem.l d2/d7/a2-a5,-(sp) + movem.l d2-d7/a2-a5,-(sp) ENDC moveq.l #0,d0 - move.l $0000(a2),d1 + movem.l (a2),d1/d3-d6 ; song offsets $0000/$0004/$0008/$000c/$0010 move.b d1,d2 - clr.b d1 - cmpi.l #$50525400,d1 ; "PRE"-Text + move.b d0,d1 + cmp.l #$50525400,d1 ; "PRE"-Text bne .error moveq.l #MAX_INSTRUMENTS-1,d7 ; notice there's one extra name (available in 1.5, but not usable)! IFNE PRETRACKER_SUPPORT_V1_5 - cmpi.b #$1e,d2 + cmp.b #$1e,d2 bgt .error bne.s .nopatchv15 move.l $005c(a2),d0 ; make song backward compatible ror.w #8,d0 move.l d0,$003c(a2) - addq.l #8,$0004(a2) ; skip over first pattern data + addq.l #8,d3 ; skip over first pattern data (offset $0004) moveq.l #2*MAX_INSTRUMENTS-1,d7 ; v1.5 has 32 slots (the other ones used for sfx) .nopatchv15 ELSE - cmpi.b #$1b,d2 + cmp.b #$1b,d2 bgt .error ENDC @@ -750,22 +402,48 @@ pre_SongInit: move.w #sv_SIZEOF,d0 bsr pre_MemClr - move.b $003c(a2),sv_pat_restart_pos_w+1(a1) ; song restart pos - move.b $003e(a2),sv_pat_pos_len_w+1(a1) ; songlength in pattern positions - move.b $003f(a2),sv_num_steps_b(a1) ; number of steps! - move.b $0041(a2),sv_num_waves_b(a1) ; number of instruments + add.l a2,d3 ; add to offset $0004 + move.l d3,sv_pos_data_adr(a1) ; address to position data (POSD) + lea (a2,d4.l),a4 ; add to offset $0008 - move.l $0004(a2),d0 - add.l a2,d0 - move.l d0,sv_pos_data_adr(a1) ; address to position data (POSD) + moveq.l #0,d0 + moveq.l #0,d4 + lea $003c(a2),a0 + move.b (a0)+,sv_pat_restart_pos_w+1(a1) ; $003c song restart pos + move.b (a0)+,d1 ; $003d number of patterns + move.b (a0)+,sv_pat_pos_len_w+1(a1) ; $003e songlength in pattern positions + move.b (a0)+,d0 ; $003f number of steps! + move.b (a0)+,d4 ; $0040 number of instruments + move.b (a0)+,sv_num_waves_b(a1) ; $0041 number of waves - move.l $0008(a2),d0 - add.l a2,d0 - move.l d0,sv_patterns_ptr(a1) ; address to pattern data (PATT) + move.b d0,sv_num_steps_b(a1) - move.l $000c(a2),d0 ; offset into instrument names - lea (a2,d0.l),a0 ; instrument names + lea sv_wavegen_order_table+MAX_WAVES(a1),a3 + moveq.l #MAX_WAVES-1,d3 ; fill 24 bytes with default order of waves? +.fillcount + move.b d3,-(a3) + dbra d3,.fillcount + cmp.b #$19,d2 ; check if version is higher than 19 + bls.s .hasnowaveordering + + moveq.l #MAX_WAVES-1,d3 +.waveorderloop + move.b (a0)+,(a3)+ ; $0042 wave generation ordering + dbra d3,.waveorderloop + +.hasnowaveordering + + lea sv_pattern_table(a1),a0 +.pattableloop + move.l a4,(a0)+ + add.w d0,a4 ; *3 bytes per pattern line + add.w d0,a4 + add.w d0,a4 + subq.b #1,d1 + bne.s .pattableloop + + lea (a2,d5.l),a0 ; offset (from $000c) into instrument names .instrnamesloop moveq.l #23-1,d0 ; max 23 chars .inststrloop @@ -773,23 +451,21 @@ pre_SongInit: dbeq d0,.inststrloop dbra d7,.instrnamesloop - moveq.l #0,d7 - move.b $0040(a2),d7 ; number of instruments + move.l d4,d0 IFNE PRETRACKER_PARANOIA_MODE beq.s .noinstsskip ENDC - move.l d7,d0 lsl.w #3,d0 add.l a0,d0 ; skip 8 bytes of info per instrument (ININ) lea sv_inst_patterns_table(a1),a3 lea sv_inst_infos_table(a1),a4 IFNE PRETRACKER_SUPPORT_V1_5 - cmp.w #MAX_INSTRUMENTS,d7 + cmp.w #MAX_INSTRUMENTS,d4 ble.s .notruncto32 - moveq.l #MAX_INSTRUMENTS,d7 + moveq.l #MAX_INSTRUMENTS,d4 .notruncto32 ENDC - subq.w #1,d7 + subq.w #1,d4 .instinfoloop move.l d0,(a3)+ @@ -839,11 +515,10 @@ pre_SongInit: add.l d1,d0 add.l d1,d0 ; calc next start address lea uii_SIZEOF(a4),a4 - dbra d7,.instinfoloop + dbra d4,.instinfoloop .noinstsskip - move.l $0010(a2),d0 ; offset into wave names - lea (a2,d0.l),a0 + lea (a2,d6.l),a0 ; offset (from $0010) into wave names moveq.l #MAX_WAVES-1,d7 .wavenamesloop moveq.l #23-1,d0 ; max 23 chars @@ -859,26 +534,6 @@ pre_SongInit: .addressiseven move.l a0,sv_waveinfo_ptr(a1) - lea sv_wavegen_order_table(a1),a0 - cmpi.b #$19,d2 ; check if version is higher than 19 - bhi.s .haswaveorderinfo - - moveq.l #0,d0 ; fill 24 bytes with default order of waves? - moveq.l #MAX_WAVES-1,d7 -.fillcount - move.b d0,(a0)+ - addq.b #1,d0 - dbra d7,.fillcount - bra.s .contafterworkaround - -.haswaveorderinfo - moveq.l #(MAX_WAVES/4)-1,d7 - lea $0042(a2),a2 ; offset into wave ordering -.memcpyloop - move.l (a2)+,(a0)+ - dbra d7,.memcpyloop - -.contafterworkaround moveq.l #2,d0 ; at least empty sample moveq.l #0,d7 move.b sv_num_waves_b(a1),d7 ; has instruments? @@ -909,7 +564,7 @@ pre_SongInit: .error .exit IFNE PRETRACKER_DONT_TRASH_REGS - movem.l (sp)+,d2/d7/a2-a5 + movem.l (sp)+,d2-d7/a2-a5 ENDC rts @@ -933,6 +588,8 @@ pre_PlayerInit: move.w #pv_SIZEOF,d0 bsr pre_MemClr ; keeps a1 unchanged! + move.l a6,pv_my_song(a4) + ; ---------------------------------------- ; proposed register assignment: ; a0 = sample output / scratch @@ -941,7 +598,6 @@ pre_PlayerInit: ; a4 = MyPlayer ; a6 = MySong - move.l a2,pv_my_song(a4) IFNE PRETRACKER_PROGRESS_SUPPORT move.l a3,pv_precalc_progress_ptr(a4) ENDC @@ -951,9 +607,10 @@ pre_PlayerInit: beq.s .hasnosamplebuffer ; PARANOIA ENDC - clr.w (a1)+ ; empty sample moveq.l #0,d7 + move.w d7,(a1)+ ; empty sample move.b sv_num_waves_b(a6),d7 + move.w d7,pv_wg_wave_counter_w(a4) IFNE PRETRACKER_PARANOIA_MODE beq.s .hasnosamplebuffer ; PARANOIA ENDC @@ -969,1203 +626,75 @@ pre_PlayerInit: ; ---------------------------------------- - lea pre_period_table(pc),a0 + lea pre_delta_period_table(pc),a0 lea pv_period_table(a4),a1 .calcperiodtable ; fill the missing entries in the period table by interpolating + move.w (a0)+,d2 moveq.l #3*NOTES_IN_OCTAVE-1,d7 .periodtableloop - move.w (a0)+,d0 - move.w (a0),d1 - sub.w d0,d1 - swap d0 - clr.w d0 + moveq.l #0,d0 + moveq.l #0,d1 + move.b (a0)+,d1 + move.w d2,d0 + sub.w d1,d2 swap d1 - clr.w d1 - asr.l #4,d1 + lsr.l #4,d1 moveq.l #16-1,d6 .perfineipolloop - swap d0 move.w d0,(a1)+ swap d0 - add.l d1,d0 + sub.l d1,d0 + swap d0 dbra d6,.perfineipolloop dbra d7,.periodtableloop -; ---------------------------------------- - - moveq.l #0,d0 - move.b sv_num_steps_b(a6),d0 - move.w d0,d1 - add.w d0,d0 - add.w d1,d0 ; *3 bytes per pattern line - - move.l sv_patterns_ptr(a6),a3 - lea sv_pattern_table(a6),a0 - move.w #255-1,d7 ; FIXME we should use the number of patterns instead? -.pattableloop - move.l a3,(a0)+ - add.w d0,a3 - dbra d7,.pattableloop - ; ---------------------------------------- move.l #$00ffff06,pv_pat_curr_row_b(a4) ; pattern frame = 0, line = $ff, pattern pos = $ff, speed_even = 0 move.l #$06060100,pv_pat_speed_odd_b(a4) ; and pv_pat_line_ticks_b, pv_pat_stopped_b, pv_songend_detected_b + addq.w #2,pv_stop_len_lof(a4) + move.w #$007b,pv_stop_per_vol_trg(a4) - move.l sv_waveinfo_ptr(a6),a1 lea pv_channeldata(a4),a0 moveq.l #NUM_CHANNELS-1,d7 moveq.l #0,d0 .chaninitloop2 move.b #MAX_VOLUME,pcd_pat_vol_b(a0) st pcd_track_delay_offset_b(a0) - move.l a1,pcd_waveinfo_ptr(a0) - move.w #3,pcd_adsr_phase_w(a0) + IFEQ PRETRACKER_BUGFIX_CODE + move.l sv_waveinfo_ptr(a6),pcd_waveinfo_ptr(a0) ; we should actually have no wave selected + ENDC + addq.w #3,pcd_adsr_phase_w(a0) + + lea pv_sample_buffer_ptr(a4),a1 + lea pcd_out_base(a0),a2 + move.l (a1)+,(a2)+ ; pv_sample_buffer_ptr -> pcd_out_ptr_l + move.l (a1)+,(a2)+ ; pv_stop_len_lof -> pcd_out_len_w / pcd_out_lof_w + move.l (a1)+,(a2)+ ; pv_stop_per_vol_trg -> pcd_out_per_w / pcd_out_vol_b / pcd_out_trg_b - move.l pv_sample_buffer_ptr(a4),pcd_out_ptr_l(a0) - move.w #2,pcd_out_len_w(a0) - move.w #$7B,pcd_out_per_w(a0) move.b d0,pcd_channel_num_b(a0) bset d0,pcd_channel_mask_b(a0) addq.b #1,d0 lea pcd_SIZEOF(a0),a0 dbra d7,.chaninitloop2 -; ---------------------------------------- - - lea pre_log12_table(pc),a0 ; 128, 121, 114, 107, 102, 96, 90, 85, 80, 76, 72, 67 - lea pv_osc_buffers+owb_sqr_waves(a4),a1 - moveq.l #NOTES_IN_OCTAVE-1,d7 -.noteloop - moveq.l #0,d6 - move.l d6,a3 ; tabpos - move.b (a0)+,d6 ; period - move.b d6,owb_wave_length-owb_sqr_waves(a1) - - move.l #$ff00,d5 - divu d6,d5 ; frac increment - - move.w d6,d4 - lsr.w #1,d4 ; half-period - move.w d4,d3 - lsr.w #1,d3 ; quarter-period - - moveq.l #0,d0 ; acc - lea (a1,d6.w),a2 - lea owb_tri_waves-owb_sqr_waves(a2),a2 - suba.w d3,a2 -.notewaveloop - move.w d0,d2 - lsr.w #8,d2 - - moveq.l #$7f,d1 - sub.b d2,d1 - move.b d1,owb_saw_waves-owb_sqr_waves(a1,a3.w) - - add.b d2,d2 - cmp.w a3,d3 ; tabpos == negquarter - bne.s .nowrapback - suba.w d6,a2 ; go back to start of period -.nowrapback - cmp.w d0,a3 - ble.s .otherhalf - moveq.l #$7f,d1 - sub.b d2,d1 - move.b d1,(a2)+ - bra.s .clip80 - -.otherhalf - add.b #$80,d2 - move.b d2,(a2)+ - moveq.l #$7f,d2 - cmp.w a3,d4 - bne.s .noclip80 -.clip80 moveq.l #-$80,d2 -.noclip80 - move.b d2,owb_sqr_waves-owb_sqr_waves(a1,a3.w) - - add.w d5,d0 ; increment acc by frac - addq.w #1,a3 ; increment pos - - cmp.w a3,d6 - bne.s .notewaveloop - - lea owb_SIZEOF(a1),a1 - dbra d7,.noteloop - ; ---------------------------------------- .audioinit + IFND PRESTO_CONV_MODE bset #1,$BFE001 ; filter off + ENDC IFNE PRETRACKER_PARANOIA_MODE tst.b sv_num_waves_b(a6) beq .earlyexit ; PARANOIA ENDC -; ---------------------------------------- -; proposed register assignment: -; a0 = sample output -; a1 = scratch -; a3 = songinfo -; a4 = MyPlayer -; a6 = MySong / waveinfo - -.wavegenloop - ;movea.l pv_my_song(a4),a6 lea sv_wavegen_order_table(a6),a1 - move.w pv_wg_wave_ord_num_w(a4),d0 ; counter through all 24 waves - moveq.l #0,d1 - move.b (a1,d0.w),d1 ; apply wave order redirection - IFNE PRETRACKER_PARANOIA_MODE ; same wave for mixing cannot be selected in Pretracker - move.b d1,pv_wg_curr_wave_num_b(a4) - ENDC - lsl.w #2,d1 - move.l pv_wave_sample_table(a4,d1.w),a0 - move.l a0,pv_wg_curr_sample_ptr(a4) - - add.w #sv_wavelength_table,d1 - adda.w d1,a6 - move.l sv_wavelength_table-sv_wavelength_table(a6),d0 - move.w d0,pv_wg_curr_sample_len_w(a4) - IFNE PRETRACKER_PROGRESS_SUPPORT - move.l sv_wavetotal_table-sv_wavelength_table(a6),pv_precalc_sample_size(a4) - ENDC - move.l sv_waveinfo_table-sv_wavelength_table(a6),a3 - - ; clear sample data (a0 and d0 from above) - bsr pre_MemClr - move.l a0,pv_wg_curr_samend_ptr(a4) - - ; read out chord information - lea wi_chord_note1_b(a3),a1 - move.b (a1)+,d1 - move.b (a1)+,d2 - move.b (a1)+,d3 - - moveq.l #0,d4 - move.b d1,d4 - or.b d2,d4 - or.b d3,d4 - seq d4 - neg.b d4 - move.w d4,pv_wg_chord_flag_w(a4) ; has chord flag (0/1) - - move.b wi_osc_basenote_b(a3),d0 - add.b d0,d1 - add.b d0,d2 - add.b d0,d3 - lea pv_wg_chord_pitches(a4),a1 - move.b d0,(a1)+ - move.b d1,(a1)+ - move.b d2,(a1)+ - move.b d3,(a1)+ - - suba.l a5,a5 - clr.w pv_wg_chord_note_num_b(a4) ; and pv_wg_chord_note_num_b - -.wavegen_chordloop - lea pv_wg_chord_pitches(a4),a1 - moveq.l #0,d1 - move.b pv_wg_chord_note_num_b(a4),d1 ; chord note counter - move.b (a1,d1.w),d0 ; get chord note - ext.w d0 - - tst.w d1 - beq.s .base_note_is_never_skipped ; is base note? - cmp.b wi_osc_basenote_b(a3),d0 - beq .wave_gen_tone_done ; skip chord notes that are same as base note -.base_note_is_never_skipped - moveq.l #0,d1 - moveq.l #NOTES_IN_OCTAVE,d2 - move.w d0,d1 - move.w d0,a2 ; save base note, used later (much later, noise generator)! - add.w #NOTES_IN_OCTAVE*NOTES_IN_OCTAVE,d1 ; make sure we don't run into negative modulo - divu d2,d1 - swap d1 - move.w d1,d0 ; note within octave - swap d1 - sub.w d2,d1 ; restore octave - - mulu #owb_SIZEOF,d0 - lea (a4,d0.w),a1 - - lea pv_osc_buffers+owb_saw_waves(a1),a6 - moveq.l #3,d0 - and.b wi_flags_b(a3),d0 - beq.s .osc_selected - lea owb_tri_waves-owb_saw_waves(a6),a6 - subq.b #1,d0 - beq.s .osc_selected - lea owb_sqr_waves-owb_tri_waves(a6),a6 - subq.b #1,d0 - beq.s .osc_selected - suba.l a6,a6 ; noise selected -.osc_selected - - move.l #$8000,d6 - move.w d1,d0 ; check octave shift - bgt.s .shiftleft - beq.s .contshift -;.shiftright - move.w d0,d3 - neg.w d3 - asr.l d3,d6 - bra.s .contshift -.shiftleft - lsl.l d0,d6 -.contshift - -; ---------------------------------------- -; pitch ramp - move.b wi_pitch_ramp_b(a3),d3 - ext.w d3 - ext.l d3 - btst #4,wi_flags_b(a3) ; pitch linear flag - beq.s .pitch_not_linear - tst.b d3 - bgt.s .pitch_ramp_positive - - lsl.l d0,d3 - add.l d3,d3 - bra.s .pitch_ramp_cont - -.pitch_not_linear - tst.b d3 - ble.s .pitch_ramp_cont -.pitch_ramp_positive - muls d3,d3 -.pitch_ramp_cont - move.l d3,d2 - lsl.l #8,d2 - lsl.l #2,d2 - - moveq.l #0,d7 - move.b pv_osc_buffers+owb_wave_length(a1),d7 ; get period - moveq.l #15,d5 - lsl.l d5,d7 - - sub.w d0,d5 ; 15-octave - lsl.w #3,d5 - - moveq.l #0,d3 - move.b wi_osc_phase_min_b(a3),d3 - - mulu d5,d3 - lsl.l #6,d3 - - moveq.l #0,d0 - move.b wi_osc_phase_max_b(a3),d0 - mulu d5,d0 - lsl.l #6,d0 - move.l d0,a5 - - moveq.l #0,d5 - move.b wi_osc_phase_spd_b(a3),d5 - lsl.l #8,d5 - lsl.l #3,d5 - - cmp.l d3,d0 - bge.s .osc_with_positive_phase_speed - neg.l d5 - - movea.l d3,a5 - bra.s .osc_continue -.osc_with_positive_phase_speed - move.l d3,d0 - -.osc_continue - move.l d0,pv_wg_osc_speed_l(a4) - - ; d0 = d6 * chord_shift * chordnum + d6 * phase_min = d6 * (chord_shift * chordnum + phase_min) - - moveq.l #0,d4 - move.b wi_chord_shift_b(a3),d4 - move.w pv_wg_chord_flag_w(a4),d0 - add.b pv_wg_chord_note_num_b(a4),d0 - mulu d0,d4 - moveq.l #0,d0 - move.b wi_osc_phase_min_b(a3),d0 - add.w d0,d4 - move.l d6,d0 - lsr.l #4,d0 - lsl.l #4,d4 - mulu d4,d0 - - cmp.l d7,d0 - ble.s .lbC002516 -.lbC002510 - sub.l d7,d0 - cmp.l d7,d0 - bgt.s .lbC002510 -.lbC002516 - move.l a6,d4 - bne .no_noise - -; ---------------------------------------- -; d1 = octave -; d5 = osc phase speed -; a2 = base note -.gen_noise - IFNE PRETRACKER_PARANOIA_MODE - tst.w pv_wg_curr_sample_len_w(a4) - beq .wave_gen_tone_done - ENDC - - move.l #$8000,d5 - move.l d5,a5 - tst.w d1 - bge.s .gen_noise_positive_octave - -.gen_noise_negative_octave - moveq.l #NOTES_IN_OCTAVE,d1 - move.l a2,d3 - neg.l d3 - move.l d3,d0 - divu d1,d0 - IFNE PRETRACKER_PARANOIA_MODE - bvs.s .divisionoverflow - ENDC - addq.w #1,d0 - lsr.w d0,d5 - moveq.l #0,d0 - move.w d5,d0 - divu d1,d0 - moveq.l #0,d4 - move.w d0,d4 - IFNE PRETRACKER_PARANOIA_MODE - bra.s .returnfromoverflow -.divisionoverflow - move.l #$AAA,d4 ; some dummy value, I would expect -.returnfromoverflow - ENDC - moveq.l #0,d0 - move.w d3,d0 -.cheap_mod12 - sub.w d1,d0 - bpl.s .cheap_mod12 - neg.w d0 - mulu d4,d0 - add.l d0,d5 - -.gen_noise_positive_octave - moveq.l #0,d0 - move.b wi_osc_phase_min_b(a3),d0 - moveq.l #0,d1 - move.b wi_chord_shift_b(a3),d1 - add.w d1,d0 - addq.w #1,d0 - - movea.l d5,a1 - movea.l pv_wg_curr_sample_ptr(a4),a0 - moveq.l #0,d1 - moveq.l #0,d6 - moveq.l #0,d3 - move.b wi_osc_gain_b(a3),d3 - -.gen_noise_outerloop - move.w d0,d1 ; random noise generator - lsl.w #8,d1 - lsl.w #5,d1 - eor.w d1,d0 - - move.w d0,d1 - lsr.w #8,d1 - lsr.w #1,d1 - eor.w d1,d0 - - move.w d0,d1 - lsl.w #7,d1 - eor.w d1,d0 - - cmpa.l #$8000,a5 ; if symmetrical - beq.s .gen_noise_centered - ; what does this do? (a5 - $8000) (a5 +$7fff)&$8000 - move.l a5,d4 - addi.l #$FFFF8000,d4 - move.l a5,d1 - addi.l #$FFFF7FFF,d1 - andi.w #$8000,d1 - movea.l d4,a5 - suba.l d1,a5 -.gen_noise_centered - - move.b d0,d1 - ext.w d1 - move.w d3,d4 - muls d1,d4 - move.l d4,d1 - asr.l #7,d1 - CLIPTO8BIT d1 - add.b (a0),d1 - -.gen_noise_innerloop - move.b d1,(a0)+ - adda.l a1,a5 - tst.l d2 - beq.s .lbC002BAC - add.l d2,d6 - move.l d6,d4 - asr.l #8,d4 - asr.l #2,d4 - add.l d5,d4 - movea.l d4,a1 - - btst #4,wi_flags_b(a3) ; pitch linear flag - beq.s .noise_nonlinear_pitch - move.l d2,d4 - asr.l #7,d4 - sub.l d4,d2 -.noise_nonlinear_pitch - - cmpa.w #$1FF,a1 - bgt.s .lbC002BAC - moveq.l #0,d2 - move.l d2,a5 - ;suba.l a5,a5 - movea.w #$200,a1 -.lbC002BAC - cmpa.l pv_wg_curr_samend_ptr(a4),a0 - beq .wave_gen_tone_done - cmpa.w #$7FFF,a5 - ble.s .gen_noise_innerloop - bra .gen_noise_outerloop - -.no_noise - move.l d6,d1 - tst.b pv_wg_unisono_run_b(a4) - beq.s .is_not_in_unisono - - moveq.l #3<<3,d1 - and.b wi_mod_density_b(a3),d1 - lsr.b #3,d1 - moveq.l #9,d4 - sub.b d1,d4 - - move.l d6,d1 - asr.l d4,d1 - add.l d6,d1 -.is_not_in_unisono - - IFNE PRETRACKER_PARANOIA_MODE - tst.w pv_wg_curr_sample_len_w(a4) - beq .wave_gen_tone_done - ENDC - -; ---------------------------------------- -; chord gen -; in: d0/d1/d2/d3/d5/d7 -; in: a0 - move.l d3,a1 - movea.l pv_wg_curr_sample_ptr(a4),a0 - suba.l a2,a2 - -.chordtoneloop - move.l d0,d4 - sub.l a1,d4 - bpl.s .noclip_osc_phase - moveq.l #0,d4 -.noclip_osc_phase - asr.l #8,d4 - asr.l #7,d4 - move.b (a6,d4.w),d4 ; fetch precalced sample - ext.w d4 - - moveq.l #0,d3 - move.b wi_osc_gain_b(a3),d3 - muls d4,d3 - asr.w #7,d3 - - move.b (a0),d4 - ext.w d4 - add.w d3,d4 - CLIPTO8BIT d4 - move.b d4,(a0)+ - - add.l d1,d0 - cmp.l d7,d0 - blt.s .lbC0025A2 - sub.l d7,d0 - add.l d5,a1 - cmp.l a5,a1 - blt.s .lbC00259A - neg.l d5 - move.l a5,a1 -.lbC00259A - cmp.l pv_wg_osc_speed_l(a4),a1 - bgt.s .lbC0025A2 - neg.l d5 - move.l pv_wg_osc_speed_l(a4),a1 -.lbC0025A2 - tst.l d2 - beq.s .chordtone_done - adda.l d2,a2 - move.l a2,d1 - asr.l #8,d1 - asr.l #2,d1 - add.l d6,d1 - - btst #4,wi_flags_b(a3) ; pitch linear flag - beq.s .no_linear_pitch - move.l d2,d4 - asr.l #7,d4 - sub.l d4,d2 -.no_linear_pitch - cmp.l d7,d1 - bcs.s .chordtone_done - moveq.l #0,d2 - moveq.l #0,d1 -.chordtone_done - cmpa.l pv_wg_curr_samend_ptr(a4),a0 - bne.s .chordtoneloop - -.wave_gen_tone_done - addq.b #1,pv_wg_chord_note_num_b(a4) - cmp.b #4,pv_wg_chord_note_num_b(a4) - bne .wavegen_chordloop - - moveq.l #3<<3,d0 - and.b wi_mod_density_b(a3),d0 ; unisono - beq.s .chords_done - move.l a6,d1 - beq.s .chords_done - tst.b pv_wg_unisono_run_b(a4) - bne.s .chords_done - move.w #$0001,pv_wg_chord_note_num_b(a4) ; sets also pv_wg_unisono_run_b - bra .wavegen_chordloop - -.chords_done -; ---------------------------------------- -; filters -; proposed register assignment: -; a0 = sample output -; a1 = end of filter chunk -; a2 = filter func -; d7/a6 = filter start -; a4 = MyPlayer -; a5 = unused -; a3 = waveinfo -; d3/d4/d5/d6 = filter taps -; d0/d1/d7 = scratch - - moveq.l #0,d0 - move.b wi_flt_type_b(a3),d0 - beq .filter_done - - IFNE PRETRACKER_PARANOIA_MODE - tst.w pv_wg_curr_sample_len_w(a4) - beq .filter_done - ENDC - - add.w d0,d0 - lea .filterfunc_jmptable(pc),a2 - add.w -1*2(a2,d0.w),a2 - - moveq.l #0,d4 ; filter tap values - moveq.l #0,d5 ; filter tap values - movem.l d4-d5,pv_wg_flt_taps(a4) - - lea wi_flt_start_b(a3),a0 - moveq.l #0,d0 - move.b (a0)+,d0 ; wi_flt_start_b - lsl.w #8,d0 - - move.b (a0)+,d4 ; wi_flt_min_b - lsl.w #8,d4 ; flt_min*256 - - move.b (a0)+,d5 ; wi_flt_max_b - lsl.w #8,d5 ; flt_max*256 - - move.b (a0)+,d3 ; wi_flt_speed_b - ext.w d3 - ext.l d3 ; flt_speed*128 - lsl.l #7,d3 - - movea.l pv_wg_curr_sample_ptr(a4),a0 - -.entry_to_filter_loop - move.l d0,a6 - move.l d3,d1 ; flt_speed_b*128 - adda.l d1,a6 ; suppress M68kUnexpectedConditionalInstruction - bgt.s .filter_speed_pos - -.filter_speed_neg - move.l d4,d1 ; flt_min*256 - cmp.l d1,d0 - blt.s .lbC002790 - cmp.l d1,a6 - bgt.s .lbC002936 - move.l d1,a6 - cmp.l d5,d1 ; flt_max*256 - beq.s .filter_load_min - neg.l d3 ; flt_speed_b*128 - bra.s .filter_load_min - -.filterfunc_jmptable - dc.w .lowpassfilter-.filterfunc_jmptable - dc.w .highpassfilter-.filterfunc_jmptable - dc.w .bandpassfilter-.filterfunc_jmptable - dc.w .notchfilter-.filterfunc_jmptable - -.lbC002790 - tst.l d0 - blt.s .lbC002936 - move.l a6,d7 - bgt.s .lbC002936 - neg.l d3 ; flt_speed_b*128 - move.w #$FF,d2 - move.w d2,d1 - sub.l a6,a6 - bra.s .filter_cont - -.filter_speed_pos - cmp.l d5,d0 ; flt_max*256 - bgt.s .lbC002D2A - cmp.l d5,a6 ; flt_max*256 - blt.s .lbC002936 - move.l d4,d2 ; flt_min*256 - cmp.l d5,d2 ; flt_max*256 - beq.s .filter_load_max_no_flip - neg.l d3 ; flt_speed_b*128 - move.l d5,a6 ; flt_max*256 - bra.s .filter_load_max - -.lbC002D2A - cmpi.l #$FF00,d0 - bgt.s .lbC002936 - cmp.l #$FEFF,a6 - ble.s .lbC002936 - neg.l d3 ; flt_speed_b*128 - moveq.l #0,d2 - move.l #$FF00,a6 - bra.s .filter_cont - -.lbC002936 - move.w a6,d2 - lsr.w #8,d2 - not.b d2 - bra.s .filter_cont - -.filter_load_max_no_flip - movea.l d2,a6 -.filter_load_max - moveq.l #0,d2 - move.b wi_flt_max_b(a3),d2 - not.b d2 - bra.s .filter_cont - -.filter_load_min - moveq.l #0,d2 - move.b wi_flt_min_b(a3),d2 - not.b d2 - -.filter_cont - btst #0,wi_flt_type_b(a3) - bne.s .not_notch_or_highpass -.highpass_or_notch ; entered for 2 or 4 - not.b d2 -.not_notch_or_highpass ; entered for 1 or 3 - move.w d2,d0 - add.w d0,d0 - - moveq.l #0,d7 - move.b wi_flt_resonance_b(a3),d7 - beq.s .filter_no_resonance - move.w d2,d1 - ext.l d1 - lsl.l #8,d1 - - moveq.l #$B6/2,d0 - sub.w d7,d0 - add.w d0,d0 - - cmpi.w #$36,d0 - bge.s .filter_no_clip_resonance - moveq.l #$36,d0 -.filter_no_clip_resonance - divu d0,d1 - move.w d2,d0 - add.w d1,d0 -.filter_no_resonance - lea $40(a0),a1 ; end of sample chunk - - movem.l d3-d5,-(sp) - movem.w pv_wg_flt_taps(a4),d3-d6 - - ; d0/d2 relevant for inner loop -.filter_innerloop - move.b (a0),d1 - ext.w d1 - - move.w d4,d7 - sub.w d5,d7 - muls d0,d7 - asr.l #8,d7 - sub.w d4,d7 - - add.w d1,d7 - muls d2,d7 - asr.l #8,d7 - add.w d7,d4 - move.w d4,d7 - - sub.w d5,d7 - muls d2,d7 - asr.l #8,d7 - add.w d7,d5 - move.w d5,d7 - - sub.w d6,d7 - muls d2,d7 - asr.l #8,d7 - add.w d7,d6 - move.w d6,d7 - - sub.w d3,d7 - muls d2,d7 - asr.l #8,d7 - add.w d7,d3 - move.w d3,d7 - - jmp (a2) - -.highpassfilter - sub.w d1,d7 - bra.s .filterclipresult - -.bandpassfilter - sub.w d4,d7 - sub.w d5,d7 - sub.w d6,d7 - asr.w #1,d7 - bra.s .filterclipresult - -.notchfilter - sub.w d4,d7 - neg.w d7 - -.lowpassfilter -.filterclipresult - CLIPTO8BIT d7 -.filter_outputbyte - move.b d7,(a0)+ - cmpa.l a0,a1 - bne.s .filter_innerloop - -.filterloop_end_test - movem.w d3-d6,pv_wg_flt_taps(a4) - movem.l (sp)+,d3-d5 - - cmpa.l pv_wg_curr_samend_ptr(a4),a0 - bhs.s .filter_done - move.l a6,d0 - bra .entry_to_filter_loop - -.filter_done -; ---------------------------------------- -; Optional Pre-Modulator - btst #5,wi_mod_density_b(a3) ; post bit - bne.s .nopremodulator - bsr pre_Modulator -.nopremodulator - -; ---------------------------------------- -; start with volume envelope -; a0 = output sample buffer -; d0 = scratch (e.g. sample) -; d1 = increment for attack phase -; d3 = current volume for attack and decay phases -; d4 = remaining sample length - 1 -; a3 = wave info - -.vol_do_envelope - movea.l pv_wg_curr_sample_ptr(a4),a0 ; load buffer pointer - move.w pv_wg_curr_sample_len_w(a4),d4 ; load length - IFNE PRETRACKER_PARANOIA_MODE - beq .vol_envelope_finished ; paranoia - ENDC - subq.w #1,d4 ; we use length-1, <0 is end - - moveq.l #2,d1 ; turns into $20000 through swap - moveq.l #0,d0 - move.b wi_vol_attack_b(a3),d0 - bne.s .has_attack_volume - cmpi.b #$FF,wi_vol_sustain_b(a3) - beq .vol_envelope_finished - ; no attack but not full sustain -> go to delay - ;move.l #$100<<16,d3 - bra.s .vol_skip_attack - -.vol_avoid_overflow_with_1 - moveq.l #1,d1 - bra.s .cont_vol_envelope -.has_attack_volume - moveq.l #0,d3 - cmp.w #1,d0 - beq.s .cont_vol_envelope - cmp.w #2,d0 - beq.s .vol_avoid_overflow_with_1 - swap d1 ; turn into $20000 - divu d0,d1 - swap d1 - clr.w d1 - ; swap is done below -.cont_vol_envelope - swap d1 ; move to high word (should be max $20000 then) - btst #5,wi_flags_b(a3) ; vol fast flag - beq.s .vol_no_fast - lsl.l #4,d1 ; multiply speed by 16 -.vol_no_fast - add.l d1,d3 ; increase volume - cmpi.l #$FFFFFF,d3 - ble.s .vol_do_attack ; first step overshooting? -.vol_skip_attack - btst #3,wi_flags_b(a3) ; boost flag - bne.s .vol_delay_boosted - bra.s .vol_delay_normal - -.vol_do_attack - btst #3,wi_flags_b(a3) ; boost flag - bne.s .vol_attack_boosted - -; ---------------------------------------- -; attack phase with volume boosted -.vol_attack_normal -.vol_attack_normal_loop - move.b (a0),d0 - ext.w d0 - swap d3 - muls d3,d0 - swap d3 - asr.w #8,d0 - move.b d0,(a0)+ - - subq.w #1,d4 - bmi .vol_envelope_finished - add.l d1,d3 ; increase volume - cmpi.l #$FFFFFF,d3 - ble.s .vol_attack_normal_loop - -; ---------------------------------------- -; delay phase (normal) - -.vol_delay_normal ; moved this label two inst up, didn't make sense there - moveq.l #0,d0 - move.b wi_vol_delay_b(a3),d0 - lsl.w #4,d0 - - IFNE PRETRACKER_FASTER_CODE - ; skip the delay -- we don't change the volume for this section - addq.w #1,d0 - sub.w d0,d4 - bmi .vol_envelope_finished - lea 1(a0,d0.w),a0 - ELSE - lea 2(a0,d0.w),a1 - - move.w #$FF,d3 ; FIXME I don't think that this is quite right. Shouldn't the max volume NOT change the value? -.vol_delay_normal_loop - move.b (a0),d0 - IFNE 1 - ext.w d0 - muls d3,d0 - asr.w #8,d0 - ELSE - ; this should be the same as above (*(256-1)) - spl d3 - add.b d3,d0 - ENDC - move.b d0,(a0)+ - - cmpa.l a1,a0 - dbeq d4,.vol_delay_normal_loop - bne .vol_envelope_finished - ENDC - - bra.s .vol_delay_end_reached - -; ---------------------------------------- -; attack with volume boosted - -.vol_attack_boosted -.vol_attack_boosted_loop - move.b (a0),d0 - ext.w d0 - swap d3 - muls d3,d0 - swap d3 - asr.w #6,d0 - CLIPTO8BIT d0 - move.b d0,(a0)+ - - subq.w #1,d4 - bmi .vol_envelope_finished - add.l d1,d3 - cmpi.l #$FFFFFF,d3 - ble.s .vol_attack_boosted_loop - -; ---------------------------------------- -; delay with max volume boosted - -.vol_delay_boosted - moveq.l #0,d0 - move.b wi_vol_delay_b(a3),d0 - lsl.w #4,d0 - - lea 2(a0,d0.w),a1 - - IFNE PRETRACKER_FASTER_CODE -.vol_delay_boosted_loop - move.b (a0),d0 - add.b d0,d0 - CLIPTO8BITAFTERADD d0 - add.b d0,d0 - CLIPTO8BITAFTERADD d0 - ELSE - move.w #$FF,d3 ; FIXME I don't think that this is quite right. It should be $100 to boost by full volume -.vol_delay_boosted_loop - move.b (a0),d0 - ext.w d0 - muls d3,d0 - asr.w #6,d0 - CLIPTO8BIT d0 - ENDC - move.b d0,(a0)+ - - cmpa.l a1,a0 - dbeq d4,.vol_delay_boosted_loop - bne .vol_envelope_finished - -.vol_delay_end_reached - subq.w #1,d4 - -; ---------------------------------------- -; decay phase -; d0 = scratch -; d1 = current volume decrement -; d2 = table index boundary -; d3 = 16:16 decay pos -; d4 = sample length counter -; d5 = volume -; d6 = scratch -; d7 = decay increment -; a0 = sample pointer -; a1 = (current) roll off table pointer (points to upper bound) -; a2 = lower bound - -.vol_do_decay - moveq.l #0,d3 - move.b wi_vol_decay_b(a3),d3 - beq .vol_do_sustain - move.w d3,d7 - mulu d7,d7 - lsr.w #2,d7 - add.w d3,d7 ; d7 = (d3^2)/4+d3 (<= 16511) - - btst #5,wi_flags_b(a3) ; vol fast flag - beq.s .vol_decay_not_fast - moveq.l #0,d3 ; will cause a5=$400,a2=$200,d2=0, decay value has no effect on the ramp used -.vol_decay_not_fast - lsl.w #8,d3 - lsl.l #4,d3 - move.l d3,d2 - swap d2 - lea pre_roll_off_table(pc),a1 - add.w d2,d2 - adda.w d2,a1 - move.w (a1)+,a2 ; first index in table - lsr.w #1,d2 ; update next boundary - - moveq.l #0,d1 ; current volume decrement - moveq.l #0,d5 - not.w d5 ; set maximum volume -.vol_decay_normal_loop - add.l d7,d3 ; increment position in decay - swap d3 - - cmp.w #$8e,d3 ; pos in table where it makes no sense to do lerp anymore - bhi.s .vol_keep_voldec - cmp.w d2,d3 - bls.s .vol_do_lerp - -.vol_lerp_next_section - move.w (a1),a2 - IFNE PRETRACKER_BUGFIX_CODE - lea pre_roll_off_table+2(pc),a1 ; Take the right boundary value - ELSE - lea pre_roll_off_table(pc),a1 ; This will set a wrong boundary and thus plateau the slope decay speed - ENDC - add.w d3,a1 - add.w d3,a1 - - move.w d3,d2 ; update next boundary - -.vol_do_lerp ; ((lowerbound-upperbound)*(d3<<8))>>8 + upperbound - move.w a2,d1 - move.w (a1),d0 - sub.w d1,d0 ; delta between lower and upper bound (negative value) - beq.s .vol_skip_lerp - - swap d3 - move.w d3,d1 - lsr.w #8,d1 - muls d0,d1 - asr.l #8,d1 - add.w a2,d1 - swap d3 - -.vol_keep_voldec -.vol_skip_lerp - swap d3 - sub.w d1,d5 - bls.s .vol_do_sustain - - move.w d5,d6 - lsr.w #8,d6 - - cmp.b wi_vol_sustain_b(a3),d6 - bls.s .vol_do_sustain - - move.b (a0),d0 - ext.w d0 - muls d6,d0 - btst #3,wi_flags_b(a3) ; boost flag - CLIPORTRUNC8BIT d0 - move.b d0,(a0)+ - - dbra d4,.vol_decay_normal_loop - bra.s .vol_envelope_finished - -; ---------------------------------------- -; sustain phase -.vol_do_sustain - moveq.l #0,d3 - move.b wi_vol_sustain_b(a3),d3 - beq.s .vol_sustain_silence - - btst #3,wi_flags_b(a3) ; boost flag - beq.s .vol_sustain_normal -.vol_sustain_boosted -.vol_sustain_boosted_loop - move.b (a0),d0 - ext.w d0 - muls d3,d0 - asr.w #6,d0 - - CLIPTO8BIT d0 - move.b d0,(a0)+ - dbra d4,.vol_sustain_boosted_loop - bra.s .vol_envelope_finished - -.vol_sustain_silence - moveq.l #0,d0 -.vol_sustain_silence_loop - move.b d0,(a0)+ - dbra d4,.vol_sustain_silence_loop - bra.s .vol_envelope_finished - -.vol_sustain_normal - IFNE PRETRACKER_FASTER_CODE - cmp.b #$ff,d3 - beq.s .vol_envelope_finished - ENDC - -.vol_sustain_normal_loop - move.b (a0),d0 - ext.w d0 - muls d3,d0 - asr.w #8,d0 - move.b d0,(a0)+ - dbra d4,.vol_sustain_normal_loop - -.vol_envelope_finished - -; ---------------------------------------- -; Optional Post-Modulator - - btst #5,wi_mod_density_b(a3) ; post bit - beq.s .nopostmodulator - bsr pre_Modulator -.nopostmodulator - -; ---------------------------------------- -; wave mixing (removed some code here that was doing nothing as result -; because below higher octaves code would overwrite it anyway). - movea.l pv_my_song(a4),a6 - - moveq.l #0,d0 - move.b wi_mix_wave_b(a3),d0 - beq.s .mix_no_wave_mixing ; no mixing selected - subq.b #1,d0 - IFNE PRETRACKER_PARANOIA_MODE ; same wave for mixing cannot be selected in Pretracker - cmp.b pv_wg_curr_wave_num_b(a4),d0 - beq .mix_no_wave_mixing ; same wave number! - ENDC - - lsl.w #2,d0 - move.l pv_wave_sample_table(a4,d0.w),a1 - add.w #sv_wavelength_table,d0 - move.l (a6,d0.w),d3 - - move.w pv_wg_curr_sample_len_w(a4),d4 ; length of the sample to mix to - cmp.w d3,d4 - ble.s .mix_picked_shorter - move.w d3,d4 -.mix_picked_shorter - - move.l pv_wg_curr_sample_ptr(a4),a0 - - subq.w #1,d4 -.mix_mixloop - move.b (a0),d0 - add.b (a1)+,d0 - CLIPTO8BITAFTERADD d0 - move.b d0,(a0)+ - dbra d4,.mix_mixloop -.mix_no_wave_mixing - -; ---------------------------------------- -; create higher octaves (this has been massively shortened) - - btst #2,wi_flags_b(a3) - beq.s .oct_has_no_extra_octaves - - moveq.l #0,d4 - move.b wi_sam_len_b(a3),d4 ; length of the sample - IFNE PRETRACKER_PARANOIA_MODE - beq.s .oct_has_no_extra_octaves - ENDC - addq.w #1,d4 - lsl.w #7,d4 - - movea.l pv_wg_curr_sample_ptr(a4),a1 - lea (a1,d4.l),a0 ; needs to be .l due to 32678 max length - - mulu #7,d4 - lsr.l #3,d4 ; * 0.875 - subq.w #1,d4 -.oct_downsample_loop - move.b (a1),(a0)+ - addq.l #2,a1 - dbra d4,.oct_downsample_loop - -.oct_has_no_extra_octaves -; ---------------------------------------- - IFNE PRETRACKER_PROGRESS_SUPPORT - move.l pv_precalc_progress_ptr(a4),d0 - beq.s .no_progress_out - move.l d0,a0 - move.l pv_precalc_sample_size(a4),d0 - add.l d0,(a0) -.no_progress_out - ENDC - move.b sv_num_waves_b(a6),d0 - addq.b #1,pv_wg_wave_ord_num_w+1(a4) - cmp.b pv_wg_wave_ord_num_w+1(a4),d0 - bgt .wavegenloop + bsr.s pre_WaveGen ; ---------------------------------------- IFNE PRETRACKER_VOLUME_TABLE @@ -2192,109 +721,7 @@ pre_PlayerInit: ENDC rts -;-------------------------------------------------------------------- -; a3: waveinfo -; -; d6: wetness (word) -; uses all data registers and a0-a2 (a3 unchanged) -pre_Modulator: - tst.b wi_mod_wetness_b(a3) - beq.s .earlyexit - moveq.l #7,d0 - and.b wi_mod_density_b(a3),d0 - bne.s .has_density -.earlyexit - rts -.has_density - move.l pv_wg_curr_sample_ptr(a4),a0 - move.w pv_wg_curr_sample_len_w(a4),d4 - IFNE PRETRACKER_PARANOIA_MODE - bne.s .not_zero - rts -.not_zero - ENDC - moveq.l #0,d6 - move.b wi_mod_wetness_b(a3),d6 - - moveq.l #0,d7 - - lea pre_modulator_ramp_8(pc),a1 - lea pre_ramp_up_down_32(pc),a2 -.loop moveq.l #0,d5 - move.b wi_mod_length_b(a3),d5 - mulu (a1)+,d5 ; result is a long value - - moveq.l #0,d1 - move.b wi_mod_predelay_b(a3),d1 - - btst #5,wi_mod_density_b(a3) ; post-modulator? - bne.s .factor1_256 - ; factor 1/4 and 64 - lsr.l #2,d5 - lsl.l #6,d1 - bra.s .cont - -.factor1_256 - lsl.w #8,d1 -.cont add.l d1,d5 ; sum up length and predelay - - moveq.l #0,d2 - moveq.l #0,d3 - -.innerloop - add.w d7,d3 - addq.w #8,d3 - moveq.l #0,d1 - move.w d3,d1 - lsr.w #8,d1 - lsr.w #3,d1 - add.w d1,d1 - move.w (a2,d1.w),d1 ; 4 bit value - add.l d5,d1 - lsr.l #6,d1 - - move.w d2,d0 - sub.w d1,d0 - bmi.s .isneg - - move.b (a0,d0.w),d1 - ext.w d1 - btst #0,d7 - beq.s .keep_dc - neg.w d1 -.keep_dc - - muls d6,d1 - asr.w #8,d1 - add.b (a0,d2.w),d1 - - CLIPTO8BITAFTERADD d1 - move.b d1,(a0,d2.w) -.isneg - addq.w #1,d2 - cmp.w d4,d2 - bcs.s .innerloop - -.restartloop - addq.w #1,d7 - moveq.l #7,d0 - and.b wi_mod_density_b(a3),d0 - cmp.w d0,d7 - bcs.s .loop - rts - -;-------------------------------------------------------------------- - -pre_MemClr - lsr.w #1,d0 - subq.w #1,d0 - bmi.s .skipmemclr - moveq.l #0,d1 -.fillmemloop - move.w d1,(a0)+ - dbra d0,.fillmemloop -.skipmemclr - rts + include "raspberry_casket_wavegen.asm" ;******************************************************************** ;-------------------------------------------------------------------- @@ -2342,10 +769,9 @@ pre_PlayerTick: ; Nothing sets pcd_pat_adsr_rel_delay_b from inside the player. ; It is used as a counter to release a note (ADSR) after a given time. ; It's not the same as the instrument ADSR release (see pcd_note_off_delay_b) - move.b pcd_pat_adsr_rel_delay_b(a5),d1 + tst.b pcd_pat_adsr_rel_delay_b(a5) ble.s .handle_2nd_instrument - subq.b #1,d1 - move.b d1,pcd_pat_adsr_rel_delay_b(a5) + subq.b #1,pcd_pat_adsr_rel_delay_b(a5) bne.s .handle_2nd_instrument move.w pcd_adsr_volume_w(a5),d3 @@ -2366,10 +792,9 @@ pre_PlayerTick: move.b pcd_pat_2nd_inst_num4_b(a5),d1 beq.s .handle_current_instrument - move.b pcd_pat_2nd_inst_delay_b(a5),d3 + tst.b pcd_pat_2nd_inst_delay_b(a5) beq.s .trigger_2nd_instrument - subq.b #1,d3 - move.b d3,pcd_pat_2nd_inst_delay_b(a5) + subq.b #1,pcd_pat_2nd_inst_delay_b(a5) bra.s .handle_current_instrument .trigger_2nd_instrument @@ -2388,12 +813,12 @@ pre_PlayerTick: move.l d1,(a1)+ ; pcd_pat_vol_ramp_speed_b, pcd_pat_2nd_inst_num4_b, pcd_pat_2nd_inst_delay_b, pcd_wave_offset_b move.l d1,(a1)+ ; pcd_inst_pitch_slide_w and pcd_inst_sel_arp_note_w move.w d1,(a1)+ ; pcd_inst_note_pitch_w - addq.w #2,a1 + addq.l #2,a1 move.l d1,(a1)+ ; pcd_inst_line_ticks_b, pcd_inst_pitch_pinned_b, pcd_inst_vol_slide_b, pcd_inst_step_pos_b subq.b #1,d1 - move.w d1,(a1)+ ; pcd_inst_wave_num_w + move.w d1,(a1)+ ; pcd_inst_wave_num4_w move.l #$ff010010,(a1)+ ; pcd_track_delay_offset_b, pcd_inst_speed_stop_b, pcd_inst_pitch_w move.l #(MAX_VOLUME<<16)|(MAX_VOLUME<<8)|MAX_VOLUME,(a1)+ ; pcd_inst_vol_w / pcd_loaded_inst_vol_b / pcd_pat_vol_b @@ -2437,7 +862,7 @@ pre_PlayerTick: bpl.s .noclip_pat_vol_min moveq.l #0,d1 .noclip_pat_vol_min - cmpi.b #MAX_VOLUME,d1 + cmp.b #MAX_VOLUME,d1 ble.s .noclip_pat_vol_max moveq.l #MAX_VOLUME,d1 .noclip_pat_vol_max @@ -2457,18 +882,14 @@ pre_PlayerTick: beq.s .note_delay_end_reached move.b d4,pcd_note_delay_b(a5) ; note still delayed - IFNE PRETRACKER_BUGFIX_CODE bra .pat_play_cont ; I believe that with activated track delay, we must jump here - ELSE - bra .pat_channels_loop_test - ENDC .note_delay_end_reached st pcd_note_delay_b(a5) ; release note delay .no_note_delay moveq.l #0,d5 move.b pcd_channel_num_b(a5),d5 - move.w sv_curr_pat_pos_w(a6),d2 + move.w pv_curr_pat_pos_w(a4),d2 add.w d2,d2 add.w d2,d2 ; *4 add.w d5,d2 @@ -2501,15 +922,15 @@ pre_PlayerTick: add.w d2,d2 add.w d2,a0 ; pattern data - moveq.l #15,d2 move.b pdb_inst_effect(a0),d4 ; instrument and command byte + moveq.l #15,d2 and.w d4,d2 lsr.w #4,d4 ; instrument nr bits 0-4 moveq.l #0,d5 move.b pdb_effect_data(a0),d5 - cmpi.b #$e,d2 + cmp.b #$e,d2 bne.s .pat_exy_cmd_cont ; handle $exy commands tst.b pcd_note_delay_b(a5) @@ -2526,11 +947,7 @@ pre_PlayerTick: beq.s .pat_exy_cmd_cont ENDC move.b d1,pcd_note_delay_b(a5) - IFNE PRETRACKER_BUGFIX_CODE bra .pat_play_cont ; I believe that with activated track delay, we must jump here - ELSE - bra .pat_channels_loop_test - ENDC .pat_is_not_ed_cmd addq.b #$d-$a,d3 @@ -2545,6 +962,8 @@ pre_PlayerTick: ; read out pattern editor data moveq.l #0,d6 ; clear arp flag + move.b d6,pcd_pat_vol_ramp_speed_b(a5) + move.w d6,pcd_pat_pitch_slide_w(a5) move.b pdb_pitch_ctrl(a0),d3 ; pitch and control byte bpl.s .noselinst16plus add.w #16,d4 ; add high bit of instrument number @@ -2571,49 +990,39 @@ pre_PlayerTick: ; d2 = effect cmd, d3 = pitch_ctrl, d4 = inst number, d5 = effect data, d7 = pitch - andi.b #$40,d3 ; ARP bit - bne.s .has_arp_note -.no_arp_note + and.w #$40,d3 ; ARP bit + bne.s .is_an_arp_note ; d3 is zero in this case, no no 2nd inst number + + ; d3.l must be 0 in this case + ; normal note, not an ARP node tst.b d2 bne.s .arp_processing_done + + ; d2.l is guaranteed to be zero + ; 0xx: play second instrument tst.b d5 beq.s .no_effect - moveq.l #15,d1 ; FIXME seems like it only supports the lower 15 instruments - and.b d5,d1 - add.w d1,d1 - add.w d1,d1 + + move.w d4,d3 ; 1st instrument num + + moveq.l #15,d4 ; FIXME seems like it only supports the lower 15 instruments + and.w d5,d4 + add.w d4,d4 + add.w d4,d4 ; 2nd instrument from pattern effect tst.b d7 - bne.s .play_2nd_inst_without_trigger + bne.s .arp_processing_done -.play_2nd_inst_with_no_pitch + ; play 2nd inst without (new) pitch addq.w #1,d0 ; pattern pitch shift lsl.w #4,d0 + bra.s .check_for_2nd_instrument - tst.b d1 - beq.s .clear_note_arp - - moveq.l #0,d2 - move.w d4,d3 - move.w d1,d4 - bra.s .trigger_new_instrument - -.play_2nd_inst_without_trigger - move.w d4,d3 ; 1st instrument num - move.w d1,d4 ; 2nd instrument num - bra.s .arp_processing_done - -.clear_note_arp - clr.l pcd_arp_notes_l(a5) - move.b d7,d2 - move.b d4,d3 - bra .clear_portamento - -.has_arp_note +.is_an_arp_note move.b d2,d3 or.b d5,d3 - beq.s .all_arp_notes_zero ; if we go there, d3 MUST be 0 already + beq.s .all_arp_notes_zero ; if we branch there, both d2 and d3 MUST be 0 already move.b d2,pcd_arp_note_1_b(a5) @@ -2625,40 +1034,32 @@ pre_PlayerTick: and.b d5,d2 move.b d2,pcd_arp_note_3_b(a5) -.all_arp_notes_zero - moveq.l #1,d6 -.no_effect moveq.l #0,d2 ; make sure we don't get a random command here + +.all_arp_notes_zero + moveq.l #1,d6 ; set ARP flag +.no_effect moveq.l #0,d3 ; ---------------------------------------- ; d2 = effect cmd, d3 = alt inst number (or 0), d4 = inst number, d5 = effect cmd, d6 = ARP flag, d7 = pitch .arp_processing_done - cmpi.b #NOTE_OFF_PITCH,d7 - bne.s .has_no_note_off + cmp.b #NOTE_OFF_PITCH,d7 + beq.s .release_note -.release_note - ; release note - ; FIXME we have the identical code (different regs) three times (one is inactive) - move.w pcd_adsr_volume_w(a5),d4 - asr.w #6,d4 - move.w d4,pcd_adsr_vol64_w(a5) - moveq.l #16,d7 - move.w d7,pcd_adsr_pos_w(a5) - sub.w d4,d7 - lsr.w #1,d7 - add.b pcd_adsr_release_b(a5),d7 - move.b d7,pcd_adsr_phase_speed_b(a5) - move.w #3,pcd_adsr_phase_w(a5) - bra .start_patt_effect_handling + tst.b d7 + beq .start_patt_effect_handling -.has_inst_number - add.w d7,d0 ; pattern pitch shift? + add.w d7,d0 ; pattern pitch shift lsl.w #4,d0 - cmpi.b #3,d2 ; is command portamento? - beq.s .pat_set_portamento + cmp.b #3,d2 ; is command portamento? + beq.s .cont_after_inst_trigger + +.check_for_2nd_instrument + tst.b d4 + beq.s .cont_after_inst_trigger .trigger_new_instrument move.w d4,d1 @@ -2682,39 +1083,39 @@ pre_PlayerTick: move.l d1,(a1)+ ; pcd_inst_line_ticks_b, pcd_inst_pitch_pinned_b, pcd_inst_vol_slide_b, pcd_inst_step_pos_b subq.b #1,d1 - move.w d1,(a1)+ ; pcd_inst_wave_num_w + move.w d1,(a1)+ ; pcd_inst_wave_num4_w move.l #$ff010010,(a1)+ ; pcd_track_delay_offset_b, pcd_inst_speed_stop_b, pcd_inst_pitch_w move.l #(MAX_VOLUME<<16)|(MAX_VOLUME<<8)|MAX_VOLUME,(a1)+ ; pcd_inst_vol_w / pcd_loaded_inst_vol_b / pcd_pat_vol_b bra.s .cont_after_inst_trigger -.has_no_note_off - tst.b d7 - beq.s .start_patt_effect_handling - tst.b d4 - bne.s .has_inst_number - - add.w d7,d0 ; pattern pitch shift - lsl.w #4,d0 +.release_note + ; FIXME we have the identical code (different regs) three times (one is inactive) + move.w pcd_adsr_volume_w(a5),d4 + asr.w #6,d4 + move.w d4,pcd_adsr_vol64_w(a5) + moveq.l #16,d7 + move.w d7,pcd_adsr_pos_w(a5) + sub.w d4,d7 + lsr.w #1,d7 + add.b pcd_adsr_release_b(a5),d7 + move.b d7,pcd_adsr_phase_speed_b(a5) + move.w #3,pcd_adsr_phase_w(a5) + bra.s .start_patt_effect_handling .cont_after_inst_trigger tst.b d6 ; has ARP? - bne.s .lbC001852 - bra.s .lbC00193C + bne.s .has_arp_check_portamento -.pat_set_portamento - tst.b d6 - bne.s .pat_new_portamento -.lbC00193C - clr.l pcd_arp_notes_l(a5) - moveq.l #0,d6 +.clear_arp_notes + move.l d6,pcd_arp_notes_l(a5) ; the whole ARP flag in d6 must be 0 -.lbC001852 - cmpi.b #3,d2 ; is command portamento? +.has_arp_check_portamento + cmp.b #3,d2 ; is command portamento? beq.s .pat_new_portamento -.clear_portamento + ; clear portamento move.w #$10,pcd_inst_pitch_w(a5) move.w d0,pcd_inst_curr_port_pitch_w(a5) clr.w pcd_pat_portamento_dest_w(a5) @@ -2728,9 +1129,10 @@ pre_PlayerTick: add.w d1,pcd_inst_curr_port_pitch_w(a5) clr.w pcd_inst_pitch_w(a5) tst.b d5 - beq.s .pat_keep_old_portamento + beq.s .execute_pattern_command move.b d5,pcd_pat_portamento_speed_b(a5) .pat_keep_old_portamento + bra.s .execute_pattern_command ; ---------------------------------------- .start_patt_effect_handling @@ -2743,10 +1145,9 @@ pre_PlayerTick: move.b d3,pcd_pat_2nd_inst_delay_b(a5) .has_no_second_inst - clr.b pcd_pat_vol_ramp_speed_b(a5) - clr.w pcd_pat_pitch_slide_w(a5) - tst.b d6 + tst.b d6 ; ARP bit is set, cannot have a command bne .pat_play_cont +.execute_pattern_command add.w d2,d2 move.w .pattern_command_jmptable(pc,d2.w),d2 jmp .pattern_command_jmptable(pc,d2.w) @@ -2755,7 +1156,7 @@ pre_PlayerTick: dc.w .pat_play_nop-.pattern_command_jmptable dc.w .pat_slide_up-.pattern_command_jmptable dc.w .pat_slide_down-.pattern_command_jmptable - dc.w .pat_play_nop-.pattern_command_jmptable + dc.w .pat_play_nop-.pattern_command_jmptable ; portamento is handled above dc.w .pat_set_vibrato-.pattern_command_jmptable dc.w .pat_set_track_delay-.pattern_command_jmptable dc.w .pat_play_nop-.pattern_command_jmptable @@ -2773,7 +1174,7 @@ pre_PlayerTick: ; ---------------------------------------- .pat_set_speed lea pv_pat_speed_even_b(a4),a1 - cmpi.b #MAX_SPEED,d5 + cmp.b #MAX_SPEED,d5 bhs.s .pat_set_speed_shuffle move.b d5,(a1)+ ; pv_pat_speed_even_b move.b d5,(a1)+ ; pv_pat_speed_odd_b @@ -2817,17 +1218,30 @@ pre_PlayerTick: cmp.b #NUM_CHANNELS-1,pcd_channel_num_b(a5) beq.s .pat_play_cont ; we are at channel 3 -- track delay not available here - lea pcd_SIZEOF+pcd_track_delay_buffer+ocd_volume(a5),a1 - moveq.l #MAX_TRACK_DELAY-1,d2 -.clr_track_delay_buffer_loop - clr.b (a1) ; ocd_volume - lea ocd_SIZEOF(a1),a1 - dbra d2,.clr_track_delay_buffer_loop - tst.b d5 bne.s .pat_track_delay_set - st pcd_track_delay_steps_b(a5) - bra.s .handle_track_delay + IFNE PRETRACKER_BUGFIX_CODE ; clearing track delay when it already was cleared will overwrite the note needlessly + tst.b pcd_track_delay_steps_b(a5) + beq.s .pat_play_cont + ENDC + move.b d5,pcd_SIZEOF+pcd_pat_vol_b(a5) + move.b d5,pcd_track_delay_steps_b(a5) + bra.s .pat_play_cont + +.pat_track_delay_set + moveq.l #15,d2 + and.b d5,d2 + add.b d2,d2 + IFNE PRETRACKER_BUGFIX_CODE + cmp.b pcd_track_delay_steps_b(a5),d2 + beq.s .pat_track_set_only_vol + ENDC + move.b d2,pcd_track_delay_steps_b(a5) + move.b d2,pcd_SIZEOF+pcd_track_init_delay_b(a5) +.pat_track_set_only_vol + lsr.b #4,d5 + move.b d5,pcd_track_delay_vol16_b(a5) + bra.s .pat_play_cont ; ---------------------------------------- .pat_volume_ramp @@ -2847,17 +1261,6 @@ pre_PlayerTick: move.b d5,pcd_pat_vol_ramp_speed_b(a5) bra.s .pat_play_cont -.pat_track_delay_set - moveq.l #15,d2 - and.b d5,d2 - add.b d2,d2 - move.b d2,pcd_track_delay_steps_b(a5) -; subq.b #1,d2 -; move.b d2,pcd_SIZEOF+pcd_track_init_delay_b(a5) - lsr.b #4,d5 - move.b d5,pcd_track_delay_vol16_b(a5) - bra.s .pat_play_cont - ; ---------------------------------------- .pat_slide_down neg.w d5 @@ -2882,7 +1285,7 @@ pre_PlayerTick: ; ---------------------------------------- .pat_set_volume - cmpi.b #MAX_VOLUME,d5 + cmp.b #MAX_VOLUME,d5 bls.s .pat_set_volume_nomax moveq.l #MAX_VOLUME,d5 .pat_set_volume_nomax @@ -2892,18 +1295,15 @@ pre_PlayerTick: .pat_play_nop .pat_play_cont - move.b pcd_track_delay_steps_b(a5),d2 ; FIXME this is a mess - beq.s .pat_channels_loop_test + cmp.b #NUM_CHANNELS-1,pcd_channel_num_b(a5) + beq.s .pat_channels_loop_end -.handle_track_delay lea pcd_SIZEOF(a5),a5 - cmp.b #NUM_CHANNELS-2,pcd_channel_num_b-pcd_SIZEOF(a5) ; FIXME find out why we need this - bge.s .pat_channels_loop_end -.pat_channels_loop_test - lea pcd_SIZEOF(a5),a5 - cmp.b #NUM_CHANNELS-1,pcd_channel_num_b-pcd_SIZEOF(a5) - bne .pre_pat_chan_loop + tst.b pcd_track_delay_steps_b-pcd_SIZEOF(a5) ; check if the next channel has track delay + bne.s .pat_play_cont ; skip channel that has track delay enabled + bra .pre_pat_chan_loop + .pat_channels_loop_end ; end of pattern loop @@ -2912,7 +1312,7 @@ pre_PlayerTick: ; Pattern advancing and pattern break and jump handling. Song looping and song-end detection. .pattern_advancing subq.b #1,pv_pat_line_ticks_b(a4) - bne .no_pattern_advance + bne.s .no_pattern_advance ; clear note delay info moveq.l #0,d0 @@ -2925,7 +1325,7 @@ pre_PlayerTick: move.b pv_pat_curr_row_b(a4),d0 addq.b #1,d0 ; normal step increment - move.w sv_curr_pat_pos_w(a6),d3 ; current song position + move.w pv_curr_pat_pos_w(a4),d3 ; current song position move.b pv_next_pat_row_b(a4),d2 ; $ff means no pattern break bmi.s .no_pattern_break @@ -2956,8 +1356,8 @@ pre_PlayerTick: bmi.s .no_new_position ; has a new pattern position st pv_next_pat_pos_b(a4) IFNE PRETRACKER_SONG_END_DETECTION - cmp.b d4,d3 - bgt.s .no_backjump + cmp.b d3,d4 + bhi.s .no_backjump st pv_songend_detected_b(a4) ; detect jumping back .no_backjump ENDC @@ -2971,14 +1371,14 @@ pre_PlayerTick: .no_new_position cmp.w sv_pat_pos_len_w(a6),d3 - blt.s .no_restart_song + blo.s .no_restart_song move.w sv_pat_restart_pos_w(a6),d3 IFNE PRETRACKER_SONG_END_DETECTION st pv_songend_detected_b(a4) ENDC .no_restart_song move.b d0,pv_pat_curr_row_b(a4) - move.w d3,sv_curr_pat_pos_w(a6) + move.w d3,pv_curr_pat_pos_w(a4) move.b pv_pat_speed_even_b(a4),d1 lsr.b #1,d0 @@ -3048,7 +1448,7 @@ pre_PlayerTick: ; IFNE PRETRACKER_PARANOIA_MODE ; new step is never written ; move.w pcd_inst_new_step_w(a5),d1 ; blt.s .inst_no_new_step_pos -; cmpi.w #$20,d1 +; cmp.w #$20,d1 ; ble.s .inst_good_new_step_pos ; moveq.l #$20,d1 ;.inst_good_new_step_pos @@ -3076,7 +1476,6 @@ pre_PlayerTick: IFNE PRETRACKER_PARANOIA_MODE moveq.l #0,d2 ; default to not stitched move.b (a0)+,d1 ; pdb_pitch_ctrl get pitch byte - move.b d1,d6 bpl.s .inst_note_is_not_stitched ; means that note is stitched tst.w d4 @@ -3086,15 +1485,15 @@ pre_PlayerTick: moveq.l #1,d2 ; next note will be fetched immediately .inst_note_is_not_stitched ELSE - move.b (a0)+,d1 ; pdb_pitch_ctrl get pitch byte - move.b d1,d6 + move.b (a0)+,d6 ; pdb_pitch_ctrl get pitch byte smi d2 ; note stitched? ;neg.b d2 ENDC tst.b d3 bne.s .skippitchloading - andi.w #$3F,d1 + moveq.l #$3f,d1 + and.w d6,d1 beq.s .skippitchloading ; no new note subq.w #1,d1 lsl.w #4,d1 @@ -3108,9 +1507,9 @@ pre_PlayerTick: moveq.l #15,d6 and.b (a0)+,d6 ; pdb_effect_cmd command number add.w d6,d6 - moveq.l #0,d5 - move.b (a0)+,d5 ; pdb_effect_data command parameter byte move.w .inst_command_jmptable(pc,d6.w),d3 + moveq.l #0,d5 + move.b (a0)+,d5 ; pdb_effect_data command parameter byte, note that condition codes are used in inst_set_speed jmp .inst_command_jmptable(pc,d3.w) .inst_command_jmptable @@ -3134,97 +1533,123 @@ pre_PlayerTick: ; d0 = current step / next step ; d5 = command parameter data / scratch ; d2 = note stitched flag +; d1 = scratch +; d3 = scratch ; d6 = scratch ; ---------------------------------------- .inst_select_wave + IFD PRESTO_CONV_MODE + clr.b pcd_wave_nosync(a5) + ENDC + pea .inst_cmd_cont_next(pc) subq.w #1,d5 cmp.w #MAX_WAVES,d5 - bhs .inst_cmd_cont_next + bhs.s .inst_set_wave_rts add.w d5,d5 add.w d5,d5 - cmp.w pcd_inst_wave_num_w(a5),d5 - beq .inst_cmd_cont_next - move.w d5,pcd_inst_wave_num_w(a5) + cmp.w pcd_inst_wave_num4_w(a5),d5 + beq.s .inst_set_wave_rts + +.inst_select_wave_subroutine + move.w d5,pcd_inst_wave_num4_w(a5) move.l sv_waveinfo_table(a6,d5.w),a3 move.l a3,pcd_waveinfo_ptr(a5) + move.l pv_wave_sample_table(a4,d5.w),a1 + move.w wi_chipram_w(a3),d5 move.b pcd_channel_mask_b(a5),d3 - move.b d3,pcd_out_trg_b(a5) or.b d3,pv_trigger_mask_w+1(a4) - - move.l pv_wave_sample_table(a4,d5.w),a1 - tst.w d6 - bne.s .inst_select_wave_nosync + move.b d3,pcd_out_trg_b(a5) moveq.l #0,d3 - move.w wi_loop_offset_w(a3),d6 ; is unlikely 32768 - move.w wi_subloop_len_w(a3),d5 - bne.s .inst_set_wave_has_subloop - adda.w d6,a1 ; add loop offset + move.w wi_loop_offset_w(a3),d1 ; is unlikely >= 32768 -- if it is, it will be past end of sample - move.w wi_chipram_w(a3),d5 - sub.w d6,d5 - ;cmp.w #1,d5 ; not necessary as increases in steps of 2 - bhi.s .inst_set_wave_has_min_length - moveq.l #2,d5 -.inst_set_wave_has_min_length - move.w d5,pcd_out_len_w(a5) + tst.w wi_subloop_len_w(a3) + beq.s .inst_set_wave_has_no_subloop - moveq.l #-1,d3 -.inst_set_wave_has_subloop + IFEQ PRETRACKER_BUGFIX_CODE + tst.w d6 + ELSE + and.b pcd_last_wave_was_looping_b(a5),d6 ; mask out nosync if not allowed + ENDC + beq.s .inst_set_wave_has_subloop + + ; nosync version +.inst_set_wave_ns_has_subloop + IFD PRESTO_CONV_MODE + st pcd_wave_nosync(a5) + ENDC move.w d3,pcd_out_lof_w(a5) + ;move.l a1,pcd_inst_wave_ptr(a5) move.l a1,pcd_out_ptr_l(a5) - st pcd_inst_ping_pong_dir_b(a5) - moveq.l #0,d5 - move.b wi_subloop_wait_b(a3),d5 - addq.w #1,d5 - move.w d5,pcd_inst_subloop_wait_w(a5) + IFEQ PRETRACKER_BUGFIX_CODE + move.w pcd_inst_loop_offset_w(a5),d1 + cmp.w d1,d5 + ELSE + cmp.w pcd_inst_loop_offset_w(a5),d5 + ENDC + bhs.s .inst_set_wave_ns_keep_pp + st pcd_inst_ping_pong_dir_b(a5) ; force forward if before loop offset +.inst_set_wave_ns_keep_pp + IFEQ PRETRACKER_BUGFIX_CODE ; this adds an extra jump to the wave that's not desired + clr.w pcd_inst_subloop_wait_w(a5) - move.w d6,pcd_inst_loop_offset_w(a5) - bra .inst_cmd_cont_next + sub.w wi_subloop_step_w(a3),d1 + move.w d1,pcd_inst_loop_offset_w(a5) + ENDC +.inst_set_wave_rts + rts -; ---------------------------------------- -.inst_select_wave_nosync - move.w wi_chipram_w(a3),d5 - moveq.l #0,d3 - tst.w wi_subloop_len_w(a3) - bne.s .inst_set_wave_ns_has_subloop +.inst_set_wave_has_no_subloop + IFEQ PRETRACKER_BUGFIX_CODE + tst.w d6 + beq.s .inst_select_wave_nosync_no_subloop - move.w wi_loop_offset_w(a3),d6 - adda.w d6,a1 - - sub.w d6,d5 + ; note that nosync on non-looping waves doesn't effectivly do anything special + adda.w d1,a1 + sub.w d1,d5 ;cmp.w #1,d5 ; not necessary as increases in steps of 2 bhi.s .inst_set_wave_ns_has_min_length moveq.l #2,d5 .inst_set_wave_ns_has_min_length move.w d5,pcd_out_len_w(a5) + moveq.l #-1,d3 + + bra.s .inst_set_wave_ns_has_subloop + +.inst_select_wave_nosync_no_subloop + ENDC + + adda.w d1,a1 ; add loop offset (which is actually not a loop offset for one-shot samples) + sub.w d1,d5 + ;cmp.w #1,d5 ; not necessary as increases in steps of 2 + bhi.s .inst_set_wave_has_min_length + moveq.l #2,d5 + IFNE PRETRACKER_BUGFIX_CODE + move.l pv_sample_buffer_ptr(a4),a1 ; fix start address to empty sample + ENDC +.inst_set_wave_has_min_length + move.w d5,pcd_out_len_w(a5) moveq.l #-1,d3 -.inst_set_wave_ns_has_subloop move.w d3,pcd_out_lof_w(a5) +.inst_set_wave_has_subloop + ;move.l a1,pcd_inst_wave_ptr(a5) move.l a1,pcd_out_ptr_l(a5) + move.w d1,pcd_inst_loop_offset_w(a5) - move.w pcd_inst_loop_offset_w(a5),d6 - cmp.w d6,d5 - bhs.s .inst_set_wave_ns_keep_pp + IFNE PRETRACKER_BUGFIX_CODE + not.b d3 + move.b d3,pcd_last_wave_was_looping_b(a5) ; allow nosync command + ENDC st pcd_inst_ping_pong_dir_b(a5) -.inst_set_wave_ns_keep_pp moveq.l #0,d5 + move.b wi_subloop_wait_b(a3),d5 + addq.w #1,d5 move.w d5,pcd_inst_subloop_wait_w(a5) - - sub.w wi_subloop_step_w(a3),d6 - move.w d6,pcd_inst_loop_offset_w(a5) - bra .inst_cmd_cont_next - -; ---------------------------------------- -.inst_slide_down - neg.w d5 -.inst_slide_up - move.w d5,pcd_inst_pitch_slide_w(a5) - bra .inst_cmd_cont_next + rts ; ---------------------------------------- .inst_adsr @@ -3263,7 +1688,7 @@ pre_PlayerTick: bra.s .inst_cmd_cont_next .inst_vol_slide_up - lsr.b #4,d5 + lsr.w #4,d5 move.b d5,pcd_inst_vol_slide_b(a5) bra.s .inst_cmd_cont_next @@ -3290,12 +1715,12 @@ pre_PlayerTick: movea.l sv_inst_patterns_table-4(a6,d1.w),a0 add.w d5,a0 - add.w d5,d5 + add.w d5,a0 add.w d5,a0 bra.s .inst_fetch_next .inst_we_were_stitched - move.b pcd_inst_speed_stop_b(a5),d2 + moveq.l #0,d2 bra.s .inst_cont_from_nasty_double_jump ; ---------------------------------------- @@ -3335,12 +1760,17 @@ pre_PlayerTick: addq.w #1,d0 bra.s .inst_fetch_next +; ---------------------------------------- +.inst_slide_down + neg.w d5 +.inst_slide_up + move.w d5,pcd_inst_pitch_slide_w(a5) + bra.s .inst_cmd_cont_next + ; ---------------------------------------- .inst_set_speed - tst.w d5 - bne.s .inst_set_speed_nostop - st d5 -.inst_set_speed_nostop + seq d3 + or.b d3,d5 move.b d5,pcd_inst_speed_stop_b(a5) ; ---------------------------------------- @@ -3359,77 +1789,37 @@ pre_PlayerTick: .inst_pat_loop_exit st d2 .inst_pat_loop_exit2 - add.b pcd_inst_speed_stop_b(a5),d2 .inst_cont_from_nasty_double_jump + add.b pcd_inst_speed_stop_b(a5),d2 move.b d2,pcd_inst_line_ticks_b(a5) move.b d0,pcd_inst_step_pos_b(a5) ; update inst step pos .inst_still_ticking - tst.b pcd_inst_wave_num_w+1(a5) + tst.b pcd_inst_wave_num4_w+1(a5) bpl.s .inst_wave_selected -.inst_no_wave_selected - moveq.l #0,d3 - move.w d3,pcd_inst_wave_num_w(a5) ; FIXME why set to wave 0? just asking, because this is zero based - move.l sv_waveinfo_ptr(a6),a3 - move.l a3,pcd_waveinfo_ptr(a5) - - move.b pcd_channel_mask_b(a5),d0 - move.b d0,pcd_out_trg_b(a5) - or.b d0,pv_trigger_mask_w+1(a4) - - tst.w wi_subloop_len_w(a3) - bne.s .inst_nowave_has_subloop - - move.w wi_loop_offset_w(a3),d5 - move.l pv_wave_sample_table(a4),a1 - adda.w d5,a1 - move.l a1,pcd_out_ptr_l(a5) - - move.w wi_chipram_w(a3),d0 - move.w d0,d6 - subq.w #1,d6 - cmp.w d4,d6 - ble.s .lbC00118E - sub.w d5,d0 - bra.s .lbC000F48 -.lbC00118E - moveq.l #2,d0 -.lbC000F48 - move.w d0,pcd_out_len_w(a5) - subq.w #1,d3 - bra.s .inst_set_no_lof - -.inst_nowave_has_subloop - move.l pv_wave_sample_table(a4),pcd_out_ptr_l(a5) - - move.w wi_loop_offset_w(a3),d4 -.inst_set_no_lof - move.w d3,pcd_out_lof_w(a5) - moveq.l #0,d0 - move.b wi_subloop_wait_b(a3),d0 - addq.w #1,d0 - move.w d0,pcd_inst_subloop_wait_w(a5) - - move.w d4,pcd_inst_loop_offset_w(a5) - st pcd_inst_ping_pong_dir_b(a5) +.inst_no_wave_selected ; FIXME this code is dubious at best -- it selects wave 0 if no wave was selected before + moveq.l #0,d5 + moveq.l #0,d6 + bsr .inst_select_wave_subroutine .inst_wave_selected - cmpi.b #$FF,d2 + cmp.b #$ff,d2 beq.s .inst_pat_loop_exit3 - subq.b #1,d2 - move.b d2,pcd_inst_line_ticks_b(a5) + subq.b #1,pcd_inst_line_ticks_b(a5) -.inst_no_inst_active .inst_pat_loop_exit3 +.inst_no_inst_active ; ---------------------------------------- - -; expects d2 = inst num ; a5 = channel move.w pcd_inst_vol_w(a5),d1 tst.b pcd_new_inst_num_b(a5) bne.s .load_instrument + IFNE PRETRACKER_BUGFIX_CODE + move.l a3,d3 + beq.s .no_inst_selected + ENDC .dont_load_instrument move.w pcd_adsr_volume_w(a5),d2 @@ -3452,8 +1842,9 @@ pre_PlayerTick: ; same code for both release and decay .adsr_decay_and_release moveq.l #0,d4 + moveq.l #-$71,d5 ; same as $8f, we only need the byte move.b pcd_adsr_phase_speed_b(a5),d4 - cmpi.b #$8f,d4 + cmp.b d5,d4 bhs.s .adsr_absurd_slow_release move.b d4,d5 addq.b #1,d5 @@ -3464,7 +1855,6 @@ pre_PlayerTick: .adsr_absurd_slow_release moveq.l #2,d4 ; FIXME I guess this should be 1, if I look at the roll-off table - moveq.l #-$71,d5 ; same as $8f, we only need the byte .adsr_release_cont move.b d5,pcd_adsr_phase_speed_b(a5) @@ -3505,7 +1895,7 @@ pre_PlayerTick: .adsr_attack add.w uii_adsr_attack(a2),d2 - cmpi.w #MAX_VOLUME<<4,d2 + cmp.w #MAX_VOLUME<<4,d2 blt.s .adsr_done .adsr_do_decay @@ -3519,10 +1909,9 @@ pre_PlayerTick: move.w d2,pcd_adsr_volume_w(a5) ; handle note cut-off command (EAx command) - move.b pcd_note_off_delay_b(a5),d4 + tst.b pcd_note_off_delay_b(a5) beq.s .dont_release_note - subq.b #1,d4 - move.b d4,pcd_note_off_delay_b(a5) + subq.b #1,pcd_note_off_delay_b(a5) bne.s .dont_release_note ; cut off note clr.w pcd_adsr_volume_w(a5) @@ -3557,15 +1946,19 @@ pre_PlayerTick: ; ---------------------------------------- ; wave loop pos advancing and pattern wave offset command handling + moveq.l #0,d1 + tst.b wi_allow_9xx_b(a3) + sne d1 + and.b pcd_wave_offset_b(a5),d1 + move.w wi_subloop_len_w(a3),d3 beq .wave_has_no_subloop move.w d3,pcd_out_len_w(a5) ; FIXME can we move this to wave loading? + move.w pcd_inst_subloop_wait_w(a5),d5 + move.b pcd_inst_ping_pong_dir_b(a5),d4 move.w wi_subloop_step_w(a3),d2 - moveq.l #0,d1 - move.b pcd_wave_offset_b(a5),d1 - beq.s .wave_with_subloop_but_no_wave_offset - tst.b wi_allow_9xx_b(a3) + tst.w d1 beq.s .wave_with_subloop_but_no_wave_offset ; update loop offset from pattern @@ -3574,8 +1967,8 @@ pre_PlayerTick: clr.b pcd_wave_offset_b(a5) ; keep current direction of ping-pong unchanged - move.b pcd_inst_ping_pong_dir_b(a5),d4 - bpl.s .wave_move_one_step_ahead + tst.b d4 + beq.s .wave_move_one_step_ahead sub.w d2,d1 ; go in reverse direction one step? bra.s .wave_submove_cont .wave_move_one_step_ahead @@ -3583,24 +1976,30 @@ pre_PlayerTick: bra.s .wave_submove_cont .wave_with_subloop_but_no_wave_offset - subq.w #1,pcd_inst_subloop_wait_w(a5) + move.w pcd_inst_loop_offset_w(a5),d1 + subq.w #1,d5 bgt.s .wave_subloop_wait ; subloop moves! - move.b pcd_inst_ping_pong_dir_b(a5),d4 - move.w pcd_inst_loop_offset_w(a5),d1 .wave_submove_cont ; reset subloop wait moveq.l #0,d5 - move.b wi_subloop_wait_b(a3),d5 ; FIXME why is this not increased by one here? - move.w d5,pcd_inst_subloop_wait_w(a5) + move.b wi_subloop_wait_b(a3),d5 tst.b d4 - bpl.s .wave_is_moving_backwards + bne.s .loop_is_moving_forwards + sub.w d2,d1 ; decrement offset in backward direction one step + + move.w wi_loop_start_w(a3),d2 + sub.w d1,d2 ; calc how many bytes we are past front + bmi.s .wave_new_loop_pos_fits + bra.s .wave_loop_dir_changed + +.loop_is_moving_forwards add.w d2,d1 ; increment offset in forward direction one step move.w d1,d4 - add.w d3,d4 ; calculate next start of loop (curr start) + add.w d3,d4 ; calculate new end position of loop sample move.w wi_loop_end_w(a3),d2 cmp.w d1,d2 @@ -3610,64 +2009,41 @@ pre_PlayerTick: sub.w d4,d2 ; space left = (max(loop end, sample end) - curr start) bhi.s .wave_new_loop_pos_fits ; max(loop end, sample end) > curr start? - add.w d2,d1 ; place offset at last possible place (loop_end - loop size) - - clr.b pcd_inst_ping_pong_dir_b(a5) ; mark going backwards - bra.s .wave_loop_dir_changed - -.wave_is_moving_backwards - sub.w d2,d1 ; decrement offset in backward direction one step - - move.w wi_loop_start_w(a3),d4 - - move.w d4,d2 - sub.w d1,d2 ; calc how many bytes we are part front - bmi.s .wave_new_loop_pos_fits - -.wave_hit_front_of_loop - move.w d4,d1 - st pcd_inst_ping_pong_dir_b(a5) - .wave_loop_dir_changed + add.w d2,d1 ; fix front of loop + not.b pcd_inst_ping_pong_dir_b(a5) + IFEQ PRETRACKER_FASTER_CODE ; this extra code doesn't seem to be justified tst.w d2 bne.s .wave_new_loop_pos_fits ; perfect fit for last loop - ; partial fit only - subq.w #1,pcd_inst_subloop_wait_w(a5) ; why, oh why? - + subq.w #1,d5 ; why, oh why? + ENDC .wave_new_loop_pos_fits - move.w d1,d4 - move.w d4,pcd_inst_loop_offset_w(a5) - bra.s .done_lof_calc + move.w d1,pcd_inst_loop_offset_w(a5) .wave_subloop_wait - move.w pcd_inst_loop_offset_w(a5),d4 -.done_lof_calc - move.w d4,pcd_out_lof_w(a5) + move.w d5,pcd_inst_subloop_wait_w(a5) + move.w d1,pcd_out_lof_w(a5) - move.w pcd_inst_wave_num_w(a5),d1 ; FIXME can we move this to wave loading? - move.l pv_wave_sample_table(a4,d1.w),pcd_out_ptr_l(a5) - bra.s .loop_handling_done + moveq.l #0,d1 + bra.s .wave_load_sample_offset .wave_has_no_subloop - move.b pcd_wave_offset_b(a5),d1 - beq.s .loop_handling_done - tst.b wi_allow_9xx_b(a3) - beq.s .loop_handling_done + tst.w d1 + beq.s .wave_loop_handling_done ; apply offset from pattern for sample without subloop - lsl.w #8,d1 ; clear upper byte - lsr.w #1,d1 + lsl.w #7,d1 clr.b pcd_wave_offset_b(a5) move.b pcd_channel_mask_b(a5),d2 ; trigger output - move.b d2,pcd_out_trg_b(a5) or.b d2,pv_trigger_mask_w+1(a4) + move.b d2,pcd_out_trg_b(a5) move.w wi_chipram_w(a3),d2 sub.w d1,d2 - bgt.s .waveoffset_is_not_past_end + bhi.s .waveoffset_is_not_past_end moveq.l #2,d2 IFNE PRETRACKER_BUGFIX_CODE ; FIXME actually we should set the start address to the empty sample @@ -3676,13 +2052,13 @@ pre_PlayerTick: ENDC .waveoffset_is_not_past_end move.w d2,pcd_out_len_w(a5) - - move.w pcd_inst_wave_num_w(a5),d2 +.wave_load_sample_offset + move.w pcd_inst_wave_num4_w(a5),d2 add.l pv_wave_sample_table(a4,d2.w),d1 + move.l d1,pcd_inst_wave_ptr(a5) move.l d1,pcd_out_ptr_l(a5) - ;move.w #$FFFF,pcd_out_lof_w(a5) ; this is already set to -1, no need to set it again -.loop_handling_done +.wave_loop_handling_done ; ---------------------------------------- ; pitch handling @@ -3699,10 +2075,9 @@ pre_PlayerTick: ; ---------------------------------------- ; vibrato processing - move.b pcd_vibrato_delay_w+1(a5),d1 + tst.b pcd_vibrato_delay_w+1(a5) beq.s .vibrato_already_active - subq.b #1,d1 - move.b d1,pcd_vibrato_delay_w+1(a5) + subq.b #1,pcd_vibrato_delay_w+1(a5) bne.s .vibrato_still_delayed .vibrato_already_active @@ -3731,173 +2106,172 @@ pre_PlayerTick: ; ---------------------------------------- ; select right sample corresponding to current pitch + move.l pcd_out_ptr_l(a5),d4 move.w pcd_out_len_w(a5),d3 - cmpi.w #$219,d0 - ble .noclippitchhigh - move.w #$231,d6 ; That's probably B-3+1, mapping to period $71 (although $7c is the last safe value) - btst #2,wi_flags_b(a3) - beq .noclippitchlow2 - - ; select high pitch version of the sample - moveq.l #0,d2 - move.w wi_chipram_w(a3),d2 move.w d0,d5 sub.w #$219,d5 - lsr.w #6,d5 - lea pre_octave_select_table(pc),a1 - moveq.l #0,d1 - move.b (a1,d5.w),d1 + ble .is_normal_octave + btst #2,wi_flags_b(a3) + beq .check_for_pitch_high_clipping + + ; select high pitch version of the sample + move.w #NOTES_IN_OCTAVE*16,d2 + moveq.l #1,d1 + sub.w d2,d0 + sub.w d2,d5 + blt.s .oct1 + addq.w #1,d1 + sub.w d2,d0 + sub.w d2,d5 + blt.s .oct2 + addq.w #1,d1 + sub.w d2,d0 +.oct1 +.oct2 + moveq.l #0,d2 + move.w wi_chipram_w(a3),d2 + move.w pcd_out_lof_w(a5),d7 addq.w #1,d7 ; compare to $ffff - beq.s .has_no_loop_offset + beq.s .high_oct_oneshot_wave subq.w #1,d7 - lsr.w d1,d7 + lsr.w d1,d7 ; halve/quarter/eighth loop offset + lsr.w d1,d3 ; halve/quarter/eighth loop length move.w d7,pcd_out_lof_w(a5) - lsr.w d1,d3 - move.w d3,pcd_out_len_w(a5) - bra.s .lbC0005C0 + bra.s .cont_after_loop_fix -.has_no_loop_offset +.high_oct_oneshot_wave tst.b pcd_out_trg_b(a5) beq.s .no_retrigger_new - move.w pcd_inst_wave_num_w(a5),d7 + move.w pcd_inst_wave_num4_w(a5),d7 movea.l pv_wave_sample_table(a4,d7.w),a3 - move.l pcd_out_ptr_l(a5),d4 - sub.l a3,d4 + sub.l a3,d4 ; calc whatever original offset into sample move.w d3,d6 add.w d4,d6 move.w d2,d7 - sub.w d6,d7 - cmp.w d7,d3 - bcc.s .fix_sample_loop + sub.w d6,d7 ; calculate (remaining) one-shot length + IFNE PRETRACKER_PARANOIA_MODE + cmp.w d7,d3 ; I think this case was already catered for in loading + bcc.s .sam_length_okay moveq.l #2,d3 - bra.s .cont_after_one_shot - -.fix_sample_loop + bra.s .cont_after_no_sample_left +.sam_length_okay + ENDC add.w d6,d3 sub.w d2,d3 lsr.w d1,d3 -.cont_after_one_shot - move.w d3,pcd_out_len_w(a5) - +.cont_after_no_sample_left lsr.w d1,d4 add.l a3,d4 - move.l d4,pcd_out_ptr_l(a5) -.lbC0005C0 - subq.b #1,d1 - bmi.s .is_normal_octave +.cont_after_loop_fix + move.w d3,pcd_out_len_w(a5) + subq.w #1,d1 + ;bmi.s .is_normal_octave ; this should never happen -- d1 is at least 1 ; find offset in sample buffer for the right octave - moveq.l #0,d4 .movetoloopposloop add.l d2,d4 lsr.w #1,d2 dbra d1,.movetoloopposloop - add.l d4,pcd_out_ptr_l(a5) .no_retrigger_new -.is_normal_octave - moveq.l #0,d1 - move.b pre_octave_note_offset_table-pre_octave_select_table(a1,d5.w),d1 - add.w d1,d1 - add.w d1,d1 - sub.w d1,d0 - cmpi.w #$231,d0 +.check_for_pitch_high_clipping + cmp.w #$231,d0 ble.s .noclippitchhigh - move.w #$231,d0 + move.w #$231,d0 ; That's probably B-3+1, mapping to period $71 (although $7c is the last safe value) .noclippitchhigh - tst.w d0 +.is_normal_octave + add.w d0,d0 bge.s .noclippitchlow moveq.l #0,d0 .noclippitchlow - move.w d0,d6 -.noclippitchlow2 + move.w pv_period_table(a4,d0.w),pcd_out_per_w(a5) + tst.b pcd_out_trg_b(a5) beq.s .wasnottriggered + ; this code seems to move the sample start to "loop offset" for first trigger moveq.l #0,d0 move.w pcd_out_lof_w(a5),d0 addq.w #1,d0 ; compare to $ffff beq.s .hasnoloop2 subq.w #1,d0 - add.l d0,pcd_out_ptr_l(a5) + add.l d0,d4 clr.w pcd_out_lof_w(a5) .wasnottriggered .hasnoloop2 - cmp.w pcd_last_trigger_pos_w(a5),d3 - beq.s .hassamesampos - move.w d3,pcd_last_trigger_pos_w(a5) + move.l d4,pcd_out_ptr_l(a5) + + ; this code is probably here to ensure triggering the wave when the octave sample changes + cmp.w pcd_last_trigger_length_w(a5),d3 + beq.s .hassamesamlen + move.w d3,pcd_last_trigger_length_w(a5) move.b pcd_channel_mask_b(a5),d3 - move.b d3,pcd_out_trg_b(a5) + IFND PRESTO_CONV_MODE or.b d3,pv_trigger_mask_w+1(a4) -.hassamesampos - add.w d6,d6 - move.w pv_period_table(a4,d6.w),pcd_out_per_w(a5) + ELSE + cmp.b pcd_out_trg_b(a5),d3 + beq.s .hassamesamlen + or.b d3,pv_trigger_mask_w+1(a4) + ; we need to mark the first length loading, without trigger that is actually not a real trigger, so we can filter it + ; also this is used to detect changes triggers only related to change of octaves + tas d3 + ENDC + move.b d3,pcd_out_trg_b(a5) +.hassamesamlen + +.no_inst_selected ; ---------------------------------------- ; track delay handling +.check_next_channel + cmp.b #NUM_CHANNELS-1,pcd_channel_num_b(a5) + beq .updatechannels - move.b pcd_track_delay_steps_b(a5),d3 - beq .incrementchannel ; no track delay + lea pcd_SIZEOF(a5),a5 - cmp.b #NUM_CHANNELS-1,pcd_channel_num_b(a5) ; last channel processed? - beq .updatechannels ; no track delay for last channel + move.b pcd_track_delay_steps_b-pcd_SIZEOF(a5),d3 + beq .inst_chan_loop ; no track delay moveq.l #MAX_TRACK_DELAY-1,d0 ; load from last buffer - ; handle track delay - cmpi.b #$FF,d3 - beq.s .clear_track_delay - ; advance and wrap offset - move.b pcd_SIZEOF+pcd_track_delay_offset_b(a5),d1 - addq.b #1,d1 + move.b pcd_track_delay_offset_b(a5),d1 + addq.w #1,d1 and.w d0,d1 - move.b d1,pcd_SIZEOF+pcd_track_delay_offset_b(a5) + move.b d1,pcd_track_delay_offset_b(a5) + ; write previous channel data to this channel's buffer move.w d1,d2 - lea pcd_SIZEOF(a5),a3 lsl.w #4,d2 - lea pcd_track_delay_buffer(a3,d2.w),a3 - lea pcd_out_base(a5),a1 + lea pcd_track_delay_buffer(a5,d2.w),a3 + lea pcd_out_base-pcd_SIZEOF(a5),a1 move.l (a1)+,(a3)+ ; ocd_sam_ptr move.l (a1)+,(a3)+ ; ocd_length/ocd_loop_offset move.l (a1)+,(a3)+ ; ocd_period/ocd_volume/ocd_trigger - ;move.l (a1)+,(a3)+ ; this is never used - move.b -(a3),d2 - add.b d2,d2 ; increment channel - bne.s .copy_trigger_for_delayed_channel - tst.b pcd_SIZEOF+pcd_track_delay_steps_b(a5) - bne.s .dont_trigger_track_delay_first_note - move.b d2,(a3) ; trigger note (ocd_trigger) -.copy_trigger_for_delayed_channel - or.b d2,pv_trigger_mask_w+1(a4) -.dont_trigger_track_delay_first_note + moveq.l #0,d5 + tst.b pcd_track_init_delay_b(a5) + bmi.s .track_delay_ready - IFNE PRETRACKER_VOLUME_TABLE - lea pv_volume_table(a4),a1 - move.b pcd_track_delay_vol16_b(a5),-(sp) - move.w (sp)+,d4 - clr.b d4 - add.w d4,d4 - move.b -(a3),d4 ; ocd_volume - move.b (a1,d4.w),(a3)+ - ELSE - moveq.l #0,d4 - move.b -(a3),d4 ; ocd_volume - move.b pcd_track_delay_vol16_b(a5),d2 - ext.w d2 - mulu d4,d2 ; apply track delay volume - lsr.w #4,d2 - move.b d2,(a3)+ ; fix volume - ENDC + subq.b #1,pcd_track_init_delay_b(a5) + bmi.s .track_delay_trigger_first - move.b d3,pcd_SIZEOF+pcd_track_delay_steps_b(a5) + lea pcd_out_base(a5),a3 + lea pv_sample_buffer_ptr(a4),a1 + move.l (a1)+,(a3)+ ; ocd_sam_ptr + move.l (a1)+,(a3)+ ; ocd_length/ocd_loop_offset + move.l (a1)+,(a3)+ ; ocd_period/ocd_volume/ocd_trigger + bra.s .check_next_channel + +.track_delay_trigger_first + move.b pcd_channel_mask_b(a5),d5 + +.track_delay_ready sub.b d3,d1 and.w d1,d0 @@ -3908,48 +2282,55 @@ pre_PlayerTick: move.b (a1,d1.w),d1 ext.w d1 ENDC - bra.s .load_track_data_from_buffer -.clear_track_delay - moveq.l #0,d1 - move.b d1,pcd_track_delay_steps_b(a5) - move.b d1,pcd_SIZEOF+pcd_pat_vol_b(a5) - move.b d1,pcd_SIZEOF+pcd_track_delay_steps_b(a5) - st pcd_SIZEOF+pcd_track_delay_offset_b(a5) - -.load_track_data_from_buffer - lea pcd_SIZEOF(a5),a5 ; skip the channel we applied track delay to lsl.w #4,d0 lea pcd_track_delay_buffer(a5,d0.w),a1 lea pcd_out_base(a5),a3 move.l (a1)+,(a3)+ ; ocd_sam_ptr move.l (a1)+,(a3)+ ; ocd_length/ocd_loop_offset - move.l (a1)+,(a3)+ ; ocd_period/ocd_volume/ocd_trigger - ;move.l (a1)+,(a3)+ ; this is never used - - ;clr.b ocd_volume-ocd_unused(a1) ; does not seem to bother IFNE PRETRACKER_DUBIOUS_PITCH_SHIFT_FOR_DELAYED_TRACK ; FIXME this seems odd! Why modulate the period by the distance? - move.w pcd_out_base+ocd_period(a5),d2 - move.w d1,d0 - muls d2,d0 - lsl.l #4,d0 - swap d0 - add.w d0,d2 - move.w d2,pcd_out_base+ocd_period(a5) + move.w (a1)+,d0 ; ocd_period + muls d0,d1 + swap d1 + add.w d1,d0 + move.w d0,(a3)+ ; ocd_period + ELSE + move.w (a1)+,(a3)+ ; ocd_period ENDC -.incrementchannel - lea pcd_SIZEOF(a5),a5 - cmp.b #NUM_CHANNELS-1,pcd_channel_num_b-pcd_SIZEOF(a5) - bne .inst_chan_loop + IFNE PRETRACKER_VOLUME_TABLE + move.w pcd_track_delay_vol16_b-pcd_SIZEOF(a5),d4 + clr.b d4 + add.w d4,d4 + move.b (a1)+,d4 ; ocd_volume + move.b (a1)+,d2 ; ocd_trigger + lea pv_volume_table(a4),a1 + move.b (a1,d4.w),(a3)+ ; ocd_volume (this track) + ELSE + moveq.l #0,d4 + move.b (a1)+,d4 ; ocd_volume + move.b pcd_track_delay_vol16_b-pcd_SIZEOF(a5),d2 + ext.w d2 + mulu d4,d2 ; apply track delay volume + lsr.w #4,d2 + move.b d2,(a3)+ ; fix volume + move.b (a1)+,d2 ; ocd_trigger + ENDC + + add.b d2,d2 ; change mask to next channel + or.b d5,d2 + move.b d2,(a3)+ ; ocd_trigger (this track) + or.b d2,pv_trigger_mask_w+1(a4) + bra .check_next_channel ; ---------------------------------------- .updatechannels ; so this changed a lot from the original routine move.w pv_trigger_mask_w(a4),d2 + IFND PRESTO_CONV_MODE IFNE PRETRACKER_COPPER_OUTPUT move.l pv_copperlist_ptr(a4),d0 beq .skipcopperlist @@ -3989,8 +2370,8 @@ pre_PlayerTick: .is_looping_sample move.l ocd_sam_ptr(a0),d0 - add.l d2,d0 - move.l d0,d6 + add.l d2,d0 ; add loop offset to sample start + move.l d0,d6 ; make a copy for loop start move.w ocd_length(a0),d4 lsr.w #1,d4 @@ -3998,7 +2379,7 @@ pre_PlayerTick: tst.b ocd_trigger(a0) beq.s .setptrvolper move.b d5,ocd_trigger(a0) - sub.l d2,d6 + sub.l d2,d0 ; if triggered, deduct loop offset so we are back at sample start .setptrvolper move.w d0,1*4(a1) ; ac_ptr (lo) swap d0 @@ -4099,6 +2480,7 @@ pre_PlayerTick: .skiprasterwait ENDC + ENDC IFNE PRETRACKER_DONT_TRASH_REGS movem.l (sp)+,d2-d7/a2-a6 @@ -4106,12 +2488,21 @@ pre_PlayerTick: rts ;-------------------------------------------------------------------- -; table data currently about 594 bytes +; table data currently about 450 bytes + ; Tables used by WaveGen +pre_roll_off_table: ; used by WaveGen + dc.w $400,$200,$180,$140,$100,$C0,$A0,$80,$78,$74,$6E + dc.w $69,$64,$5A,$46,$40,$38,$30,$28,$20,$1F,$1E,$1D + dc.w $1C,$1B,$1A,$19,$18,$17,$16,$15,$14,$13,$12,$11 + dc.w $10,15,14,13,13,12,12,11,11,10,10,9,9,8,8,8,8,7,7 + dc.w 7,7,6,6,6,6,5,5,5,5,4,4,4,4,4,4,4,4,4,4,3,4,4,3,4 + dc.w 4,3,4,3,4,3,4,3,4,3,3,3,3,3,3,3,3,3,2,3,3,3,2,3,3 + dc.w 2,3,3,2,3,3,2,3,2,3,2,3,2,3,2,3,2,2,2,2,2,2,2,2,1 + dc.w 2,1,2,1,2,1,2,1,1,2,1,1,1,2,1 -; I assume this is a log table for freq distances within an octave -pre_log12_table: - dc.b $400000/$8000,$400000/$871D,$400000/$8F2F,$400000/$97B7,$400000/$9FC4,$400000/$A9DE - dc.b $400000/$B505,$400000/$BF49,$400000/$CB31,$400000/$D645,$400000/$E215,$400000/$F1A0 +pre_modulator_ramp_8: ; used by WaveGen + ;dc.w 77,293,539,1079,1337,1877,2431,3031 ; the 1079 value is strange (938 better?) + dc.w $4D,$125,$21B,$437,$539,$755,$96D,$BD7 ; linear then steep quadratic slope pre_vib_speed_table: @@ -4129,67 +2520,17 @@ pre_ramp_up_16: dc.b 0,1,3,6,7,9,10,11,12,13,14,16,19,35,55,143 pre_fast_roll_off_16: - dc.w $400,$200,$80,$64,$50,$40,$30,$20,$10,14,12,10,8 - dc.w 4,2,1 - -pre_roll_off_table: - dc.w $400,$200,$180,$140,$100,$C0,$A0,$80,$78,$74,$6E - dc.w $69,$64,$5A,$46,$40,$38,$30,$28,$20,$1F,$1E,$1D - dc.w $1C,$1B,$1A,$19,$18,$17,$16,$15,$14,$13,$12,$11 - dc.w $10,15,14,13,13,12,12,11,11,10,10,9,9,8,8,8,8,7,7 - dc.w 7,7,6,6,6,6,5,5,5,5,4,4,4,4,4,4,4,4,4,4,3,4,4,3,4 - dc.w 4,3,4,3,4,3,4,3,4,3,3,3,3,3,3,3,3,3,2,3,3,3,2,3,3 - dc.w 2,3,3,2,3,3,2,3,2,3,2,3,2,3,2,3,2,2,2,2,2,2,2,2,1 - dc.w 2,1,2,1,2,1,2,1,1,2,1,1,1,2,1 - -pre_octave_note_offset_table: - dc.b 1*NOTES_IN_OCTAVE*4,1*NOTES_IN_OCTAVE*4,1*NOTES_IN_OCTAVE*4 - dc.b 2*NOTES_IN_OCTAVE*4,2*NOTES_IN_OCTAVE*4,2*NOTES_IN_OCTAVE*4 - dc.b 3*NOTES_IN_OCTAVE*4,3*NOTES_IN_OCTAVE*4,3*NOTES_IN_OCTAVE*4 - dc.b 3*NOTES_IN_OCTAVE*4,3*NOTES_IN_OCTAVE*4,3*NOTES_IN_OCTAVE*4 - dc.b 3*NOTES_IN_OCTAVE*4,3*NOTES_IN_OCTAVE*4,3*NOTES_IN_OCTAVE*4 - IFNE PRETRACKER_PARANOIA_MODE - dc.b 3*NOTES_IN_OCTAVE*4,3*NOTES_IN_OCTAVE*4,3*NOTES_IN_OCTAVE*4 - dc.b 3*NOTES_IN_OCTAVE*4,3*NOTES_IN_OCTAVE*4,3*NOTES_IN_OCTAVE*4 - dc.b 3*NOTES_IN_OCTAVE*4,3*NOTES_IN_OCTAVE*4,3*NOTES_IN_OCTAVE*4 - ELSE - dc.b 3*NOTES_IN_OCTAVE*4 - ENDC - even - - ; based on pitch $219 (537), covers up to pitch 0x819 (2073). - ; In practice, I was unable to get higher than $5ff -pre_octave_select_table: - dc.b 1,1,1 - dc.b 2,2,2 - dc.b 3,3,3 - dc.b 3,3,3 - dc.b 3,3,3 - dc.b 3,3,3 - IFNE PRETRACKER_PARANOIA_MODE - dc.b 3,3,3 - dc.b 3,3,3 - ELSE - dc.b 3 - ENDC - even + dc.w $400,$200,$80,$64,$50,$40,$30,$20 + dc.w 16,14,12,10,8,4,2,1 IFNE PRETRACKER_DUBIOUS_PITCH_SHIFT_FOR_DELAYED_TRACK ; -4,-3,-1,1,2,3,4,0 pre_minus4plus4_table: - dc.b $FC,$FB,$FF,1,2,3,4,0 + dc.b $c0,$b0,$f0,$10,$20,$30,$40,$00 ENDC -pre_ramp_up_down_32: - dc.w 0*32,1*32,2*32,3*32,4*32,5*32,6*32,7*32,8*32,9*32,10*32,11*32,12*32,13*32,14*32,15*32 - dc.w 15*32,14*32,13*32,12*32,11*32,10*32,9*32,8*32,7*32,6*32,5*32,4*32,3*32,2*32,1*32,0*32 - -pre_modulator_ramp_8: - ;dc.w 77,293,539,1079,1337,1877,2431,3031 ; the 1079 value is strange (938 better?) - dc.w $4D,$125,$21B,$437,$539,$755,$96D,$BD7 - -pre_period_table: - dc.w $350,$320,$2F2,$2C8,$2A0,$279,$256,$236,$216,$1F8,$1DC,$1C0 - dc.w $1A8,$190,$179,$164,$151,$13E,$12C,$11B,$10B,$FC,$EE,$E0 - dc.w $D4,$C8,$BD,$B2,$A8,$9F,$96,$8D,$86,$7E,$78,$71 - dc.w $71 +pre_delta_period_table: + dc.w $350 + dc.b $30,$2e,$2a,$28,$27,$23,$20,$20,$1e,$1c,$1c,$18,$18,$17,$15,$13 + dc.b $13,$12,$11,$10,$0f,$0e,$0e,$0c,$0c,$0b,$0b,$0a,$09,$09,$09,$07 + dc.b $08,$06,$07,$00 diff --git a/source/framework/musicplayers/raspberry_casket.i b/source/framework/musicplayers/raspberry_casket.i new file mode 100644 index 0000000..4189b38 --- /dev/null +++ b/source/framework/musicplayers/raspberry_casket.i @@ -0,0 +1,345 @@ +; Pretracker song format description: +; +; $0000 4: PRT ($19/$1a (V0.x), $1b (V1.0), $1e (V1.5)) +; $0004 4: File offset to position data (POSD) +; $0008 4: File offset to pattern data (PATT) +; $000C 4: File offset to instruments (INST) +; $0010 4: File offset to waves (WAVE) +; $0014 20: Songname +; $0028 20: Author +; $003C 1: Restart position for song (<=V1.0) +; $003D 1: Number of patterns (<=V1.0) +; $003E 1: Songlength in patterns (<=V1.0) +; $003F 1: Number of steps per pattern (<=V1.0) +; $0040 1: Number of instruments (<=V1.0), $40 for V1.5 +; $0041 1: Number of waves +; $0042 24: Wave generation ordering (>=V1.0) +; $005a 1: Number of subsongs (>=V1.5) +; [...] +; Position data (POSD): +; - Per subsong (>=V1.5) +; - 1: Restart pos +; - 1: #patterns +; - 1: #numsteps +; - 1: songlength +; - 4: relative pattern offset in pattern data +; - Positions x 4 x [Pattern number (byte), pitch shift (signed byte)] +; +; Pattern data (PATT): +; Each pattern line consists of three bytes: +; - 1 Bit : Bit 4 of Inst Number +; - 1 Bit : ARP instead of effect +; - 6 Bits: Pitch ($01 is C-0, $3d is NOTE OFF) +; +; - 4 Bits: Bit 0-3 of Inst Number +; - 4 Bits: Effect command +; - 8 Bits: Effect data +; - Patterns x steps x 3 bytes +; +; Unknown data after pattern data: (12 10 00 00 00 00) +; +; Instrument definitions (INST): +; - 32 (!) x Null terminated string (or 23 chars max) (for V1.5 this is 64 strings) +; - For each instrument: Instrument Info (ININ) +; - $00 1: Vibrato Delay +; - $01 1: Vibrato Depth +; - $02 1: Vibrato Speed (-1) +; - $03 1: ADSR Attack +; - $04 1: ADSR Decay +; - $05 1: ADSR Sustain +; - $06 1: ADSR Release +; - $07 1: Number of Inst Pattern steps +; +; - For each instrument: +; - 1 Byte: number of steps +; - 3 Bytes x number of steps: Inst Pattern (IPTT) +; +; Inst pattern data (IPTT): +; Each pattern line consists of three bytes: +; - 1 Bit : Next note stitched to this one +; - 1 Bit : Fixed Pitch Note +; - 6 Bits : Pitch ($01 is C-0) +; - 4 Bits : unused? +; - 12 Bits: Effect +; +; Wave definitions (WAVE): +; - 24 (!) x Null terminated string (or 23 chars max) +; - Optional padding to even address, if necessary +; - For each wave: +; - 42 Bytes: Wave info structure (see definition below) + +; ---------------------------------------- +; Some constants for clarity + +MAX_VOLUME = $40 +MAX_SPEED = $2f +MAX_WAVES = 24 +MAX_INSTRUMENTS = 32 +MAX_TRACK_DELAY = 32 +NOTE_OFF_PITCH = $3d +NOTES_IN_OCTAVE = 12 +NUM_CHANNELS = 4 ; yes, you can reduce the number of channels if you want + +; ---------------------------------------- +; Pretracker file structures + +; Pattern data (PATT and IPTT) +pdb_pitch_ctrl = 0 +pdb_inst_effect = 1 ; for normal pattern data +pdb_effect_cmd = 1 ; for inst pattern +pdb_effect_data = 2 + +; Pattern pos data (POSD) +ppd_pat_num = 0 +ppd_pat_shift = 1 + +; Instrument Info (ININ) +ii_vibrato_delay = 0 +ii_vibrato_depth = 1 +ii_vibrato_speed = 2 +ii_adsr_attack = 3 +ii_adsr_decay = 4 +ii_adsr_sustain = 5 +ii_adsr_release = 6 +ii_pattern_steps = 7 +ii_SIZEOF = 8 + +; Wave Info (WAVE) +wi_loop_start_w = $00 +wi_loop_end_w = $02 +wi_subloop_len_w = $04 +wi_allow_9xx_b = $06 ; 0x00 / 0x01 +wi_subloop_wait_b = $07 +wi_subloop_step_w = $08 +wi_chipram_w = $0a +wi_loop_offset_w = $0c +wi_chord_note1_b = $0e +wi_chord_note2_b = $0f +wi_chord_note3_b = $10 +wi_chord_shift_b = $11 +wi_clone_wave_b = $12 ; only used by tracker itself +wi_osc_phase_spd_b = $13 +wi_flags_b = $14 ; bit 0/1: osc type, bit 2: needs extra octaves, bit 3: boost, bit 4: pitch linear, bit 5: vol fast +wi_osc_phase_min_b = $15 +wi_osc_phase_max_b = $16 +wi_osc_basenote_b = $17 +wi_osc_gain_b = $18 +wi_sam_len_b = $19 ; in multiples of 128, zero-based (0 == 128) +wi_mix_wave_b = $1a +wi_vol_attack_b = $1b +wi_vol_delay_b = $1c +wi_vol_decay_b = $1d +wi_vol_sustain_b = $1e +wi_flt_type_b = $1f ; 1=lowpass, 2=highpass, 3=bandpass, 4=notch +wi_flt_resonance_b = $20 +wi_pitch_ramp_b = $21 +wi_flt_start_b = $22 +wi_flt_min_b = $23 +wi_flt_max_b = $24 +wi_flt_speed_b = $25 +wi_mod_params_l = $26 +wi_mod_wetness_b = $26 +wi_mod_length_b = $27 +wi_mod_predelay_b = $28 +wi_mod_density_b = $29 ; (1-7), unisono (bits 3/4) and post bit 5 +wi_SIZEOF = $2a + +; ---------------------------------------- +; Unpacked Instrument Info (addition to player for faster processing) + rsreset +uii_vibrato_delay rs.w 1 +uii_vibrato_depth rs.w 1 +uii_vibrato_speed rs.w 1 +uii_adsr_release rs.b 1 + rs.b 1 ; dummy +uii_adsr_attack rs.w 1 +uii_adsr_decay rs.w 1 +uii_adsr_sustain rs.w 1 +uii_pattern_steps rs.b 1 + rs.b 1 ; padding +uii_SIZEOF rs.b 0 + +; ---------------------------------------- +; MySong offsets + rsreset +sv_waveinfo_table rs.l MAX_WAVES ; 24 pointers to wave infos to avoid mulu +sv_inst_patterns_table rs.l MAX_INSTRUMENTS ; 32 pointers to pattern data + ; --- 127 byte displacement limit --- +sv_wavelength_table rs.l MAX_WAVES ; 24 longwords to sample lengths (standard octave) (NEW) +sv_wavetotal_table rs.l MAX_WAVES ; 24 longwords to sample lengths for all octaves (NEW) +sv_wavegen_order_table rs.b MAX_WAVES ; 24 bytes +sv_num_waves_b rs.b 1 +sv_num_steps_b rs.b 1 +sv_pat_pos_len_w rs.w 1 ; only byte used +sv_pat_restart_pos_w rs.w 1 ; only byte used +sv_pos_data_adr rs.l 1 +sv_waveinfo_ptr rs.l 1 ; base pointer of wave info +sv_inst_infos_table rs.b MAX_INSTRUMENTS*uii_SIZEOF +sv_pattern_table rs.l 256 +sv_SIZEOF rs.b 0 + +; ---------------------------------------- +; channel output data (part of pcd structure below) -- FIXED ORDER! + rsreset +ocd_sam_ptr rs.l 1 ; 0 +ocd_length rs.w 1 ; 4 +ocd_loop_offset rs.w 1 ; 6 +ocd_period rs.w 1 ; 8 +ocd_volume rs.b 1 ; 10 +ocd_trigger rs.b 1 ; 11 needs to be after volume +ocd_unused rs.l 1 ; 12 unused, but makes the structure an even 16 bytes +ocd_SIZEOF rs.b 0 + +; channel structure (part of pv structure) + rsreset +; DO NOT CHANGE ORDER -- OPTIMIZED CLEARING +pcd_pat_portamento_dest_w rs.w 1 ; portamento destination pitch +pcd_pat_pitch_slide_w rs.w 1 + +pcd_pat_vol_ramp_speed_b rs.b 1 +pcd_pat_2nd_inst_num4_b rs.b 1 +pcd_pat_2nd_inst_delay_b rs.b 1 +pcd_wave_offset_b rs.b 1 + +pcd_inst_pitch_slide_w rs.w 1 +pcd_inst_sel_arp_note_w rs.w 1 + +pcd_inst_note_pitch_w rs.w 1 +pcd_inst_curr_port_pitch_w rs.w 1 + +pcd_inst_line_ticks_b rs.b 1 +pcd_inst_pitch_pinned_b rs.b 1 +pcd_inst_vol_slide_b rs.b 1 +pcd_inst_step_pos_b rs.b 1 + +pcd_inst_wave_num4_w rs.w 1 ; current wave number (1 based, times 4) (lower byte used) + +pcd_track_delay_offset_b rs.b 1 ; $ff = no track delay +pcd_inst_speed_stop_b rs.b 1 ; speed byte, $ff stops processing +pcd_inst_pitch_w rs.w 1 + +pcd_inst_vol_w rs.w 1 +pcd_loaded_inst_vol_b rs.b 1 +pcd_pat_vol_b rs.b 1 ; Multiplied with volume of instrument. +; DO NOT CHANGE ORDER -- OPTIMIZED CLEARING END + +pcd_arp_notes_l rs.b 0 +pcd_arp_note_1_b rs.b 1 +pcd_arp_note_2_b rs.b 1 +pcd_arp_note_3_b rs.b 1 + rs.b 1 ; gets cleared + +pcd_last_trigger_length_w rs.w 1 ; I think this makes sure that we trigger the note if the length changes +pcd_last_wave_was_looping_b rs.b 1 ; -1 if the last wave was a looping one so no-sync is actually allowed +pcd_wave_nosync rs.b 1 ; For Presto (otherwise padding): Store if the wave currently uses nosync or not + +pcd_pat_portamento_speed_b rs.b 1 +pcd_pat_adsr_rel_delay_b rs.b 1 ; counts down until adsr release. Seems unused? +pcd_note_off_delay_b rs.b 1 ; time before note is released ($ff = disabled) +pcd_inst_pattern_steps_b rs.b 1 ; number of steps in instrument pattern + +pcd_note_delay_b rs.b 1 ; $ff = no note delay +pcd_track_delay_steps_b rs.b 1 ; $00 = no track delay, $xx = track delay xx (this is for the next channel!) +pcd_track_delay_vol16_b rs.b 1 ; needs to be at even address (using word access to shift << 8) +pcd_track_init_delay_b rs.b 1 ; number of frames to ignore the delay + +pcd_inst_num4_w rs.w 1 ; current instrument number * 4 +pcd_inst_wave_ptr rs.l 1 +pcd_inst_subloop_wait_w rs.w 1 +pcd_inst_loop_offset_w rs.w 1 +pcd_inst_info_ptr rs.l 1 ; pointer to currently active instrument + +pcd_waveinfo_ptr rs.l 1 ; pointer to currently active waveinfo +pcd_channel_mask_b rs.b 1 +pcd_channel_num_b rs.b 1 +pcd_adsr_phase_w rs.w 1 ; 0=attack, 1=decay, 2=sustain, 3=release ! do not change order +pcd_adsr_volume_w rs.w 1 ; 0 for restart / $400 (word only) ! do not change order +pcd_adsr_phase_speed_b rs.b 1 +pcd_inst_ping_pong_dir_b rs.b 1 ; direction of ping-pong (-1 == $00 / +1 = $ff) +pcd_adsr_pos_w rs.w 1 ; pos in adsr curve +pcd_adsr_vol64_w rs.w 1 ; some adsr volume + +pcd_new_inst_num_b rs.b 1 ; load new instrument (number) ! do not change order + rs.b 1 ; gets cleared +pcd_vibrato_pos_w rs.w 1 ; +pcd_vibrato_delay_w rs.w 1 ; is a byte value ! do not change order +pcd_vibrato_depth_w rs.w 1 ; is a byte value ! do not change order +pcd_vibrato_speed_w rs.w 1 ; is a byte value ! do not change order +pcd_adsr_release_b rs.b 1 ; is a byte value ! do not change order + rs.b 1 ; padding will be overwritten! + +pcd_out_base rs.b ocd_SIZEOF +pcd_track_delay_buffer rs.b MAX_TRACK_DELAY*ocd_SIZEOF +pcd_SIZEOF rs.b 0 + +pcd_out_ptr_l = pcd_out_base+ocd_sam_ptr +pcd_out_len_w = pcd_out_base+ocd_length +pcd_out_lof_w = pcd_out_base+ocd_loop_offset +pcd_out_per_w = pcd_out_base+ocd_period +pcd_out_vol_b = pcd_out_base+ocd_volume +pcd_out_trg_b = pcd_out_base+ocd_trigger +pcd_out_unused_l = pcd_out_base+ocd_unused ; copied for track delay, but not used? + + rsreset +owb_saw_waves rs.b 128 +owb_sqr_waves rs.b 128 +owb_tri_waves rs.b 128 +owb_SIZEOF rs.b 0 + +; ---------------------------------------- +; MyPlayer global variables (not bound to channel) + rsreset +; DO NOT CHANGE ORDER -- OPTIMIZED INIT +pv_pat_curr_row_b rs.b 1 ; current step +pv_next_pat_row_b rs.b 1 +pv_next_pat_pos_b rs.b 1 +pv_pat_speed_even_b rs.b 1 ; even shuffle speed + +pv_pat_speed_odd_b rs.b 1 ; odd shuffle speed +pv_pat_line_ticks_b rs.b 1 +pv_pat_stopped_b rs.b 1 ; 0 = stop, $ff = run +pv_songend_detected_b rs.b 1 +; DO NOT CHANGE ORDER -- OPTIMIZED INIT END + +pv_curr_pat_pos_w rs.w 1 ; only byte used +pv_loop_pattern_b rs.b 1 ; repeat current pattern, do not advance + rs.b 1 ; padding + +pv_trigger_mask_w rs.w 1 + +pv_my_song rs.l 1 +pv_copperlist_ptr rs.l 1 +pv_wave_sample_table rs.l MAX_WAVES ; 24 pointers to sample starts +pv_period_table rs.w 16*NOTES_IN_OCTAVE*3 + ; --- 127 byte displacement limit --- +pv_sample_buffer_ptr rs.l 1 ; pointer to start of sample buffer +pv_stop_len_lof rs.l 1 ; $0002 / $0000 +pv_stop_per_vol_trg rs.l 1 ; $007b / $00 / $00 +pv_channeldata rs.b NUM_CHANNELS*pcd_SIZEOF + + IFNE PRETRACKER_VOLUME_TABLE +pv_osc_buffers rs.b 0 ; reuse space of volume_table, which is bigger than NOTES_IN_OCTAVE*owb_SIZEOF +pv_volume_table rs.b (MAX_VOLUME+1)*MAX_VOLUME*2 + ELSE +pv_osc_buffers rs.b NOTES_IN_OCTAVE*owb_SIZEOF + ENDC + +pv_precalc_sample_size rs.l 1 +pv_precalc_progress_ptr rs.l 1 +pv_wg_wave_counter_w rs.w 1 + IFNE PRETRACKER_PARANOIA_MODE ; same wave for mixing cannot be selected in Pretracker +pv_wg_curr_wave_num_b rs.b 1 + rs.b 1 + ENDC +pv_wg_curr_sample_ptr rs.l 1 +pv_wg_curr_samend_ptr rs.l 1 +pv_wg_curr_sample_len_l rs.w 1 +pv_wg_curr_sample_len_w rs.w 1 +pv_wg_chord_note_num_b rs.b 1 ; don't change order +pv_wg_unisono_run_b rs.b 1 ; don't change order +pv_wg_chord_flag_w rs.w 1 +pv_wg_chord_pitches rs.l 1 +pv_wg_osc_speed_l rs.l 1 +pv_wg_flt_taps rs.w 4 +pv_SIZEOF rs.b 0 + diff --git a/source/framework/musicplayers/raspberry_casket_wavegen.asm b/source/framework/musicplayers/raspberry_casket_wavegen.asm new file mode 100644 index 0000000..f735f4d --- /dev/null +++ b/source/framework/musicplayers/raspberry_casket_wavegen.asm @@ -0,0 +1,1294 @@ + +CLIPTO8BIT MACRO + cmp.w #-$80,\1 + bge.s .nominclip\@ + moveq.l #-$80,\1 +.nominclip\@ + cmp.w #$7f,\1 + ble.s .nomaxclip\@ + moveq.l #$7f,\1 +.nomaxclip\@ + ENDM + +CLIPORTRUNC8BIT MACRO + beq.s .unboosted\@ + asr.l #6,\1 + cmp.w #-$80,\1 + bge.s .nominclip\@ + moveq.l #-$80,\1 +.nominclip\@ + cmp.w #$7f,\1 + ble.s .nomaxclip\@ + moveq.l #$7f,\1 + bra.s .nomaxclip\@ +.unboosted\@ + asr.l #8,\1 +.nomaxclip\@ + ENDM + +CLIPTO8BITAFTERADD MACRO + bvc.s .noclip\@ + spl \1 + eor.b #$7f,\1 +.noclip\@ + ENDM + +; ---------------------------------------- +; proposed register assignment: +; a1 = Wave table order +; a4 = MyPlayer +; a6 = MySong / waveinfo +pre_WaveGen: +; ---------------------------------------- + + lea .pre_log12_table(pc),a0 ; 128, 121, 114, 107, 102, 96, 90, 85, 80, 76, 72, 67 + lea pv_osc_buffers+owb_sqr_waves(a4),a3 + moveq.l #NOTES_IN_OCTAVE-1,d7 +.noteloop + swap d7 + moveq.l #0,d6 + move.w d6,d7 ; tabpos + move.b (a0)+,d6 ; period + + move.l #$ff00,d5 + divu d6,d5 ; frac increment + + move.w d6,d4 + lsr.w #1,d4 ; half-period + move.w d4,d3 + lsr.w #1,d3 ; quarter-period + + moveq.l #0,d0 ; acc + lea (a3,d6.w),a2 + lea owb_tri_waves-owb_sqr_waves(a2),a2 + suba.w d3,a2 +.notewaveloop + move.w d0,d2 + lsr.w #8,d2 + + moveq.l #$7f,d1 + sub.b d2,d1 + move.b d1,owb_saw_waves-owb_sqr_waves(a3,d7.w) + + add.b d2,d2 + cmp.w d7,d3 ; tabpos == negquarter + bne.s .nowrapback + suba.w d6,a2 ; go back to start of period +.nowrapback + cmp.w d0,d7 + ble.s .otherhalf + moveq.l #$7f,d1 + sub.b d2,d1 + move.b d1,(a2)+ + bra.s .clip80 + +.otherhalf + add.b #$80,d2 + move.b d2,(a2)+ + moveq.l #$7f,d2 + cmp.w d7,d4 + bne.s .noclip80 +.clip80 moveq.l #-$80,d2 +.noclip80 + move.b d2,owb_sqr_waves-owb_sqr_waves(a3,d7.w) + + add.w d5,d0 ; increment acc by frac + addq.w #1,d7 ; increment pos + + cmp.w d7,d6 + bne.s .notewaveloop + + swap d7 + lea owb_SIZEOF(a3),a3 + dbra d7,.noteloop + +; ---------------------------------------- +; proposed register assignment: +; a0 = sample output +; a1 = scratch +; a3 = waveinfo +; a4 = MyPlayer +; a6 = MySong / waveinfo +.wavegenloop + ;movea.l pv_my_song(a4),a6 + moveq.l #0,d1 + move.b (a1)+,d1 ; apply wave order redirection + move.l a1,-(sp) ; what used to be sv_wavegen_order_table + IFNE PRETRACKER_PARANOIA_MODE ; same wave for mixing cannot be selected in Pretracker + move.b d1,pv_wg_curr_wave_num_b(a4) + ENDC + lsl.w #2,d1 + move.l pv_wave_sample_table(a4,d1.w),a0 + move.l a0,pv_wg_curr_sample_ptr(a4) + + IFND PRESTO_UNIFIED_STRUCT + add.w #sv_wavelength_table,d1 + adda.w d1,a6 + move.l sv_wavelength_table-sv_wavelength_table(a6),d0 + move.l d0,pv_wg_curr_sample_len_l(a4) + IFNE PRETRACKER_PROGRESS_SUPPORT + move.l sv_wavetotal_table-sv_wavelength_table(a6),pv_precalc_sample_size(a4) + ENDC + move.l sv_waveinfo_table-sv_wavelength_table(a6),a3 + ELSE ; PRESTO_UNIFIED_STRUCT + ; Presto has no MySong structure + lea pv_wavelength_table(a4,d1.w),a6 + + ; copied from raspberry_casket + moveq.l #0,d0 + move.b wi_sam_len_b(a3),d0 + addq.w #1,d0 + lsl.w #7,d0 + move.l d0,pv_wavelength_table-pv_wavelength_table(a6) + move.l d0,d1 + btst #2,wi_flags_b(a3) + beq.s .onlythreeocts + mulu #15,d1 + lsr.l #3,d1 ; * 1.875 +.onlythreeocts + move.l d1,pv_wavetotal_table-pv_wavelength_table(a6) + ; end stuff + move.l d0,pv_wg_curr_sample_len_l(a4) + IFNE PRETRACKER_PROGRESS_SUPPORT + move.l d1,pv_precalc_sample_size(a4) + ENDC + move.l pv_waveinfo_table-pv_wavelength_table(a6),a3 + ENDC ; PRESTO_UNIFIED_STRUCT + + ; clear sample data (a0 and d0 from above) + bsr pre_MemClr + move.l a0,pv_wg_curr_samend_ptr(a4) + + ; read out chord information + lea wi_chord_note1_b(a3),a1 + move.b (a1)+,d1 + move.b (a1)+,d2 + move.b (a1)+,d3 + + moveq.l #0,d4 + move.b d1,d4 + or.b d2,d4 + or.b d3,d4 + seq d4 + neg.b d4 + move.w d4,pv_wg_chord_flag_w(a4) ; has chord flag (0/1) + + move.b wi_osc_basenote_b(a3),d0 + add.b d0,d1 + add.b d0,d2 + add.b d0,d3 + lea pv_wg_chord_pitches(a4),a1 + move.b d0,(a1)+ + move.b d1,(a1)+ + move.b d2,(a1)+ + move.b d3,(a1)+ + + clr.w pv_wg_chord_note_num_b(a4) ; and pv_wg_chord_note_num_b + +.wavegen_chordloop + lea pv_wg_chord_pitches(a4),a1 + moveq.l #0,d1 + move.b pv_wg_chord_note_num_b(a4),d1 ; chord note counter + move.b (a1,d1.w),d0 ; get chord note + ext.w d0 + + tst.w d1 + beq.s .base_note_is_never_skipped ; is base note? + cmp.b wi_osc_basenote_b(a3),d0 + beq .wave_gen_tone_done ; skip chord notes that are same as base note +.base_note_is_never_skipped + moveq.l #0,d5 + moveq.l #NOTES_IN_OCTAVE,d2 + move.w d0,d5 + move.w d0,a2 ; save base note, used later (much later, noise generator)! + add.w #NOTES_IN_OCTAVE*NOTES_IN_OCTAVE,d5 ; make sure we don't run into negative modulo + divu d2,d5 + sub.w d2,d5 ; restore octave, result may be negative + move.w d5,d1 ; +-octave + swap d5 ; note within octave + + moveq.l #0,d7 + move.b .pre_log12_table(pc,d5.w),d7 ; 128, 121, 114, 107, 102, 96, 90, 85, 80, 76, 72, 67 + + moveq.l #3,d0 + mulu d0,d5 + and.b wi_flags_b(a3),d0 + beq.s .osc_selected + addq.w #2,d5 + subq.w #1,d0 + beq.s .osc_selected + subq.w #1,d5 + subq.w #1,d0 +.osc_selected + lea pv_osc_buffers+owb_saw_waves(a4),a6 + lsl.w #7,d5 + adda.w d5,a6 + +; ---------------------------------------- +; pitch ramp + move.b wi_pitch_ramp_b(a3),d2 + ext.w d2 + ext.l d2 + btst #4,wi_flags_b(a3) ; pitch linear flag + beq.s .pitch_not_linear + tst.w d2 + bgt.s .pitch_ramp_positive + + ; FIXME what happens if d1 is negative? rolls out by 63? + lsl.l d1,d2 + add.l d2,d2 + bra.s .pitch_ramp_cont + +.pre_log12_table + dc.b $400000/$8000,$400000/$871d,$400000/$8f2f,$400000/$97b7,$400000/$9fc4,$400000/$a9de + dc.b $400000/$b505,$400000/$bf49,$400000/$cb31,$400000/$d645,$400000/$e215,$400000/$f1a0 + +.pitch_not_linear + tst.w d2 + ble.s .pitch_ramp_cont +.pitch_ramp_positive + muls d2,d2 +.pitch_ramp_cont + lsl.l #8,d2 + lsl.l #2,d2 + + ; check whether we have a noise oscillator or something else + tst.w d0 + beq .no_noise + +; ---------------------------------------- +; d0 = scratch +; d1 = octave +; d2 = pitch ramping value +; d4 = scratch +; a2 = base note +.gen_noise + suba.l a6,a6 + IFNE PRETRACKER_PARANOIA_MODE + tst.w pv_wg_curr_sample_len_w(a4) + beq .wave_gen_tone_done + ENDC + + moveq.l #1,d5 + ror.w #1,d5 ; $00008000 + move.l d5,a5 + tst.w d1 + bge.s .gen_noise_positive_octave + +.gen_noise_negative_octave + moveq.l #NOTES_IN_OCTAVE,d1 + move.l a2,d3 + neg.l d3 + move.l d3,d0 + divu d1,d0 + IFNE PRETRACKER_PARANOIA_MODE + bvs.s .divisionoverflow + ENDC + addq.w #1,d0 + lsr.w d0,d5 + moveq.l #0,d0 + move.w d5,d0 + divu d1,d0 + moveq.l #0,d4 + move.w d0,d4 + IFNE PRETRACKER_PARANOIA_MODE + bra.s .returnfromoverflow +.divisionoverflow + move.l #$AAA,d4 ; some dummy value, I would expect +.returnfromoverflow + ENDC + moveq.l #0,d0 + move.w d3,d0 +.cheap_mod12 + sub.w d1,d0 + bpl.s .cheap_mod12 + neg.w d0 + mulu d4,d0 + add.l d0,d5 + +.gen_noise_positive_octave + moveq.l #0,d0 + move.b wi_osc_phase_min_b(a3),d0 + moveq.l #0,d1 + move.b wi_chord_shift_b(a3),d1 + add.w d1,d0 + addq.w #1,d0 + + ; sum of phase min and shift are used as root for noise + + movea.l d5,a1 + movea.l pv_wg_curr_sample_ptr(a4),a0 + moveq.l #0,d1 + moveq.l #0,d6 + moveq.l #0,d3 + move.b wi_osc_gain_b(a3),d3 + +.gen_noise_outerloop + move.w d0,d1 ; random noise generator + lsl.w #8,d1 + lsl.w #5,d1 + eor.w d1,d0 + + move.w d0,d1 + lsr.w #8,d1 + lsr.w #1,d1 + eor.w d1,d0 + + move.w d0,d1 + lsl.w #7,d1 + eor.w d1,d0 + + move.b d0,d1 ; take the random seed + ext.w d1 + muls d3,d1 ; multiply by gain + asr.w #7,d1 + CLIPTO8BIT d1 + add.b (a0),d1 + + move.w a5,d4 + subq.w #1,d4 + and.w #$7fff,d4 + move.w d4,a5 + addq.w #1,a5 + +.gen_noise_innerloop + move.b d1,(a0)+ + cmp.l pv_wg_curr_samend_ptr(a4),a0 + beq .wave_gen_tone_done + + adda.l a1,a5 + + tst.l d2 + beq.s .gen_noise_no_pitch_ramping + add.l d2,d6 + move.l d6,d4 + asr.l #8,d4 + asr.l #2,d4 + add.l d5,d4 + movea.l d4,a1 + + btst #4,wi_flags_b(a3) ; pitch linear flag + beq.s .noise_nonlinear_pitch + move.l d2,d4 ; filter pitch speed + asr.l #7,d4 + sub.l d4,d2 +.noise_nonlinear_pitch + + cmp.w #$1ff,a1 + bgt.s .gen_noise_no_end_of_pitch_ramp + moveq.l #0,d2 ; stop pitch ramping + move.l d2,a5 + movea.w #$200,a1 +.gen_noise_no_end_of_pitch_ramp +.gen_noise_no_pitch_ramping + cmp.w a5,a5 + beq.s .gen_noise_innerloop + + bra .gen_noise_outerloop + +; ---------------------------------------- +; d1 = octave +; d2 = pitch ramping value +; d5 = osc phase speed +; a2 = base note + +.no_noise + moveq.l #15,d5 + lsl.l d5,d7 + + sub.w d1,d5 ; 15-octave + lsl.w #3,d5 + + moveq.l #0,d3 + move.b wi_osc_phase_min_b(a3),d3 + mulu d5,d3 + lsl.l #6,d3 + + moveq.l #0,d0 + move.b wi_osc_phase_max_b(a3),d0 + mulu d5,d0 + lsl.l #6,d0 + move.l d0,a5 + + moveq.l #0,d5 + move.b wi_osc_phase_spd_b(a3),d5 + lsl.l #8,d5 + lsl.l #3,d5 + + cmp.l d3,d0 + bge.s .osc_with_positive_phase_speed + neg.l d5 + + movea.l d3,a5 + bra.s .osc_continue +.osc_with_positive_phase_speed + move.l d3,d0 + +.osc_continue + move.l d0,pv_wg_osc_speed_l(a4) + + ; I think this calculates the base oscillator speed for higher and lower octaves + moveq.l #1,d6 + moveq.l #15,d0 + add.w d1,d0 + lsl.l d0,d6 + + ; d0 = d6 * chord_shift * chordnum + d6 * phase_min = d6 * (chord_shift * chordnum + phase_min) + + moveq.l #0,d4 + move.b wi_chord_shift_b(a3),d4 + move.w pv_wg_chord_flag_w(a4),d0 + add.b pv_wg_chord_note_num_b(a4),d0 + mulu d0,d4 + moveq.l #0,d0 + move.b wi_osc_phase_min_b(a3),d0 + add.w d0,d4 + move.l d6,d0 + lsr.l #4,d0 + lsl.l #4,d4 + mulu d4,d0 + +.osc_loop_until_in_range + sub.l d7,d0 + bgt.s .osc_loop_until_in_range + add.l d7,d0 + + move.l d6,d1 + tst.b pv_wg_unisono_run_b(a4) + beq.s .is_not_in_unisono + + moveq.l #3<<3,d1 + and.b wi_mod_density_b(a3),d1 + lsr.w #3,d1 + moveq.l #9,d4 + sub.w d1,d4 + + move.l d6,d1 + asr.l d4,d1 + add.l d6,d1 +.is_not_in_unisono + + IFNE PRETRACKER_PARANOIA_MODE + tst.w pv_wg_curr_sample_len_w(a4) + beq .wave_gen_tone_done + ENDC + +; ---------------------------------------- +; chord gen +; in: d0/d1/d2/d3/d5/d7 +; in: a0 + move.l d3,a1 + movea.l pv_wg_curr_sample_ptr(a4),a0 + suba.l a2,a2 + +.chordtoneloop + move.l d0,d4 + sub.l a1,d4 + bpl.s .noclip_osc_phase + moveq.l #0,d4 +.noclip_osc_phase + asr.l #8,d4 + asr.l #7,d4 + move.b (a6,d4.w),d4 ; fetch precalced sample + ext.w d4 + + moveq.l #0,d3 + move.b wi_osc_gain_b(a3),d3 + muls d4,d3 + asr.w #7,d3 + + move.b (a0),d4 + ext.w d4 + add.w d3,d4 + CLIPTO8BIT d4 + move.b d4,(a0)+ + + add.l d1,d0 + cmp.l d7,d0 + blt.s .lbC0025A2 + sub.l d7,d0 + add.l d5,a1 + cmp.l a5,a1 + blt.s .lbC00259A + neg.l d5 + move.l a5,a1 +.lbC00259A + cmp.l pv_wg_osc_speed_l(a4),a1 + bgt.s .lbC0025A2 + neg.l d5 + move.l pv_wg_osc_speed_l(a4),a1 +.lbC0025A2 + tst.l d2 + beq.s .chordtone_done + adda.l d2,a2 + move.l a2,d1 + asr.l #8,d1 + asr.l #2,d1 + add.l d6,d1 + + btst #4,wi_flags_b(a3) ; pitch linear flag + beq.s .no_linear_pitch + move.l d2,d4 + asr.l #7,d4 + sub.l d4,d2 +.no_linear_pitch + cmp.l d7,d1 + bcs.s .chordtone_done + moveq.l #0,d2 + moveq.l #0,d1 +.chordtone_done + cmp.l pv_wg_curr_samend_ptr(a4),a0 + bne.s .chordtoneloop + +.wave_gen_tone_done + addq.b #1,pv_wg_chord_note_num_b(a4) + cmp.b #4,pv_wg_chord_note_num_b(a4) + bne .wavegen_chordloop + + moveq.l #3<<3,d0 + and.b wi_mod_density_b(a3),d0 ; unisono + beq.s .chords_done + move.l a6,d1 + beq.s .chords_done + tst.b pv_wg_unisono_run_b(a4) + bne.s .chords_done + move.w #$0001,pv_wg_chord_note_num_b(a4) ; sets also pv_wg_unisono_run_b + bra .wavegen_chordloop + +.chords_done +; ---------------------------------------- +; filters +; proposed register assignment: +; a0 = sample output +; a1 = end of filter chunk +; a2 = filter func +; d7/a6 = filter start +; a4 = MyPlayer +; a5 = unused +; a3 = waveinfo +; d3/d4/d5/d6 = filter taps +; d0/d1/d7 = scratch + + moveq.l #0,d0 + move.b wi_flt_type_b(a3),d0 + beq .filter_done + + IFNE PRETRACKER_PARANOIA_MODE + tst.w pv_wg_curr_sample_len_w(a4) + beq .filter_done + ENDC + + add.w d0,d0 + lea .filterfunc_jmptable(pc),a2 + add.w -1*2(a2,d0.w),a2 + + moveq.l #0,d4 ; filter tap values + moveq.l #0,d5 ; filter tap values + movem.l d4-d5,pv_wg_flt_taps(a4) + + lea wi_flt_start_b(a3),a0 + moveq.l #0,d0 + move.b (a0)+,d0 ; wi_flt_start_b + lsl.w #8,d0 + + move.b (a0)+,d4 ; wi_flt_min_b + lsl.w #8,d4 ; flt_min*256 + + move.b (a0)+,d5 ; wi_flt_max_b + lsl.w #8,d5 ; flt_max*256 + + move.b (a0)+,d3 ; wi_flt_speed_b + ext.w d3 + ext.l d3 ; flt_speed*128 + lsl.l #7,d3 + + movea.l pv_wg_curr_sample_ptr(a4),a0 + +.entry_to_filter_loop + move.l d0,a6 + move.l d3,d1 ; flt_speed_b*128 + adda.l d1,a6 ; suppress M68kUnexpectedConditionalInstruction + bgt.s .filter_speed_pos + +.filter_speed_neg + move.l d4,d1 ; flt_min*256 + cmp.l d1,d0 + blt.s .lbC002790 + cmp.l d1,a6 + bgt.s .lbC002936 + move.l d1,a6 + cmp.l d5,d1 ; flt_max*256 + beq.s .filter_load_min + neg.l d3 ; flt_speed_b*128 + bra.s .filter_load_min + +.filterfunc_jmptable + dc.w .lowpassfilter-.filterfunc_jmptable + dc.w .highpassfilter-.filterfunc_jmptable + dc.w .bandpassfilter-.filterfunc_jmptable + dc.w .notchfilter-.filterfunc_jmptable + +.lbC002790 + tst.l d0 + blt.s .lbC002936 + move.l a6,d7 + bgt.s .lbC002936 + neg.l d3 ; flt_speed_b*128 + move.w #$FF,d2 + move.w d2,d1 + sub.l a6,a6 + bra.s .filter_cont + +.filter_speed_pos + cmp.l d5,d0 ; flt_max*256 + bgt.s .lbC002D2A + cmp.l d5,a6 ; flt_max*256 + blt.s .lbC002936 + move.l d4,d2 ; flt_min*256 + cmp.l d5,d2 ; flt_max*256 + beq.s .filter_load_max_no_flip + neg.l d3 ; flt_speed_b*128 + move.l d5,a6 ; flt_max*256 + bra.s .filter_load_max + +.lbC002D2A + cmpi.l #$FF00,d0 + bgt.s .lbC002936 + cmp.l #$FEFF,a6 + ble.s .lbC002936 + neg.l d3 ; flt_speed_b*128 + moveq.l #0,d2 + move.l #$FF00,a6 + bra.s .filter_cont + +.lbC002936 + move.w a6,d2 + lsr.w #8,d2 + not.b d2 + bra.s .filter_cont + +.filter_load_max_no_flip + movea.l d2,a6 +.filter_load_max + moveq.l #0,d2 + move.b wi_flt_max_b(a3),d2 + not.b d2 + bra.s .filter_cont + +.filter_load_min + moveq.l #0,d2 + move.b wi_flt_min_b(a3),d2 + not.b d2 + +.filter_cont + btst #0,wi_flt_type_b(a3) + bne.s .not_notch_or_highpass +.highpass_or_notch ; entered for 2 or 4 + not.b d2 +.not_notch_or_highpass ; entered for 1 or 3 + move.w d2,d0 + add.w d0,d0 + + moveq.l #0,d7 + move.b wi_flt_resonance_b(a3),d7 + beq.s .filter_no_resonance + move.w d2,d1 + ext.l d1 + lsl.l #8,d1 + + moveq.l #$B6/2,d0 + sub.w d7,d0 + add.w d0,d0 + + cmpi.w #$36,d0 + bge.s .filter_no_clip_resonance + moveq.l #$36,d0 +.filter_no_clip_resonance + divu d0,d1 + move.w d2,d0 + add.w d1,d0 +.filter_no_resonance + lea $40(a0),a1 ; end of sample chunk + + movem.l d3-d5,-(sp) + movem.w pv_wg_flt_taps(a4),d3-d6 + + ; d0/d2 relevant for inner loop +.filter_innerloop + move.b (a0),d1 + ext.w d1 + + move.w d4,d7 + sub.w d5,d7 + muls d0,d7 + asr.l #8,d7 + sub.w d4,d7 + + add.w d1,d7 + muls d2,d7 + asr.l #8,d7 + add.w d7,d4 + move.w d4,d7 + + sub.w d5,d7 + muls d2,d7 + asr.l #8,d7 + add.w d7,d5 + move.w d5,d7 + + sub.w d6,d7 + muls d2,d7 + asr.l #8,d7 + add.w d7,d6 + move.w d6,d7 + + sub.w d3,d7 + muls d2,d7 + asr.l #8,d7 + add.w d7,d3 + move.w d3,d7 + + jmp (a2) + +.highpassfilter + sub.w d1,d7 + bra.s .filterclipresult + +.bandpassfilter + sub.w d4,d7 + sub.w d5,d7 + sub.w d6,d7 + asr.w #1,d7 + bra.s .filterclipresult + +.notchfilter + sub.w d4,d7 + neg.w d7 + +.lowpassfilter +.filterclipresult + CLIPTO8BIT d7 +.filter_outputbyte + move.b d7,(a0)+ + cmp.l a0,a1 + bne.s .filter_innerloop + +.filterloop_end_test + movem.w d3-d6,pv_wg_flt_taps(a4) + movem.l (sp)+,d3-d5 + + cmp.l pv_wg_curr_samend_ptr(a4),a0 + bhs.s .filter_done + move.l a6,d0 + bra .entry_to_filter_loop + +.filter_done +; ---------------------------------------- +; Optional Pre-Modulator + btst #5,wi_mod_density_b(a3) ; post bit + bne.s .nopremodulator + bsr pre_Modulator +.nopremodulator + +; ---------------------------------------- +; start with volume envelope +; a0 = output sample buffer +; d0 = scratch (e.g. sample) +; d1 = increment for attack phase +; d3 = current volume for attack and decay phases +; d4 = remaining sample length - 1 +; a3 = wave info + +.vol_do_envelope + move.l pv_wg_curr_sample_ptr(a4),a0 ; load buffer pointer + move.w pv_wg_curr_sample_len_w(a4),d4 ; load length + IFNE PRETRACKER_PARANOIA_MODE + beq .vol_envelope_finished ; paranoia + ENDC + subq.w #1,d4 ; we use length-1, <0 is end + + moveq.l #2,d1 ; turns into $20000 through swap + moveq.l #0,d0 + move.b wi_vol_attack_b(a3),d0 + bne.s .has_attack_volume + cmp.b #$ff,wi_vol_sustain_b(a3) + beq .vol_envelope_finished + ; no attack but not full sustain -> go to delay + ;move.l #$100<<16,d3 + bra.s .vol_skip_attack + +.vol_avoid_overflow_with_1 + moveq.l #1,d1 + bra.s .cont_vol_envelope +.has_attack_volume + moveq.l #0,d3 + cmp.w #1,d0 + beq.s .cont_vol_envelope + cmp.w #2,d0 + beq.s .vol_avoid_overflow_with_1 + swap d1 ; turn into $20000 + divu d0,d1 + swap d1 + clr.w d1 + ; swap is done below +.cont_vol_envelope + swap d1 ; move to high word (should be max $20000 then) + btst #5,wi_flags_b(a3) ; vol fast flag + beq.s .vol_no_fast + lsl.l #4,d1 ; multiply speed by 16 +.vol_no_fast + add.l d1,d3 ; increase volume + cmp.l #$ffffff,d3 + ble.s .vol_do_attack ; first step overshooting? +.vol_skip_attack + btst #3,wi_flags_b(a3) ; boost flag + bne.s .vol_delay_boosted + bra.s .vol_delay_normal + +.vol_do_attack + btst #3,wi_flags_b(a3) ; boost flag + bne.s .vol_attack_boosted + +; ---------------------------------------- +; attack phase with volume boosted +.vol_attack_normal +.vol_attack_normal_loop + move.b (a0),d0 + ext.w d0 + swap d3 + muls d3,d0 + swap d3 + asr.w #8,d0 + move.b d0,(a0)+ + + subq.w #1,d4 + bmi .vol_envelope_finished + add.l d1,d3 ; increase volume + cmp.l #$ffffff,d3 + ble.s .vol_attack_normal_loop + +; ---------------------------------------- +; delay phase (normal) + +.vol_delay_normal ; moved this label two inst up, didn't make sense there + moveq.l #0,d0 + move.b wi_vol_delay_b(a3),d0 + lsl.w #4,d0 + + IFNE PRETRACKER_FASTER_CODE + ; skip the delay -- we don't change the volume for this section + addq.w #1,d0 + sub.w d0,d4 + bmi .vol_envelope_finished + lea 1(a0,d0.w),a0 + ELSE + lea 2(a0,d0.w),a1 + + move.w #$ff,d3 ; FIXME I don't think that this is quite right. Shouldn't the max volume NOT change the value? +.vol_delay_normal_loop + move.b (a0),d0 + IFNE 1 + ext.w d0 + muls d3,d0 + asr.w #8,d0 + ELSE + ; this should be the same as above (*(256-1)) + spl d3 + add.b d3,d0 + ENDC + move.b d0,(a0)+ + + cmp.l a1,a0 + dbeq d4,.vol_delay_normal_loop + bne .vol_envelope_finished + ENDC + + bra.s .vol_delay_end_reached + +; ---------------------------------------- +; attack with volume boosted + +.vol_attack_boosted +.vol_attack_boosted_loop + move.b (a0),d0 + ext.w d0 + swap d3 + muls d3,d0 + swap d3 + asr.w #6,d0 + CLIPTO8BIT d0 + move.b d0,(a0)+ + + subq.w #1,d4 + bmi .vol_envelope_finished + add.l d1,d3 + cmp.l #$ffffff,d3 + ble.s .vol_attack_boosted_loop + +; ---------------------------------------- +; delay with max volume boosted + +.vol_delay_boosted + moveq.l #0,d0 + move.b wi_vol_delay_b(a3),d0 + lsl.w #4,d0 + + lea 2(a0,d0.w),a1 + + IFNE PRETRACKER_FASTER_CODE +.vol_delay_boosted_loop + move.b (a0),d0 + add.b d0,d0 + CLIPTO8BITAFTERADD d0 + add.b d0,d0 + CLIPTO8BITAFTERADD d0 + ELSE + move.w #$ff,d3 ; FIXME I don't think that this is quite right. It should be $100 to boost by full volume +.vol_delay_boosted_loop + move.b (a0),d0 + ext.w d0 + muls d3,d0 + asr.w #6,d0 + CLIPTO8BIT d0 + ENDC + move.b d0,(a0)+ + + cmp.l a1,a0 + dbeq d4,.vol_delay_boosted_loop + bne .vol_envelope_finished + +.vol_delay_end_reached + subq.w #1,d4 + +; ---------------------------------------- +; decay phase +; d0 = scratch +; d1 = current volume decrement +; d2 = table index boundary +; d3 = 16:16 decay pos +; d4 = sample length counter +; d5 = volume +; d6 = scratch +; d7 = decay increment +; a0 = sample pointer +; a1 = (current) roll off table pointer (points to upper bound) +; a2 = lower bound + +.vol_do_decay + moveq.l #0,d3 + move.b wi_vol_decay_b(a3),d3 + beq .vol_do_sustain + move.w d3,d7 + mulu d7,d7 + lsr.w #2,d7 + add.w d3,d7 ; d7 = (d3^2)/4+d3 (<= 16511) + + btst #5,wi_flags_b(a3) ; vol fast flag + beq.s .vol_decay_not_fast + moveq.l #0,d3 ; will cause a5=$400,a2=$200,d2=0, decay value has no effect on the ramp used +.vol_decay_not_fast + lsl.w #8,d3 + lsl.l #4,d3 + move.l d3,d2 + swap d2 + lea pre_roll_off_table(pc),a1 + add.w d2,d2 + adda.w d2,a1 + move.w (a1)+,a2 ; first index in table + lsr.w #1,d2 ; update next boundary + + moveq.l #0,d1 ; current volume decrement + moveq.l #0,d5 + not.w d5 ; set maximum volume +.vol_decay_normal_loop + add.l d7,d3 ; increment position in decay + swap d3 + + cmp.w #$8e,d3 ; pos in table where it makes no sense to do lerp anymore + bhi.s .vol_keep_voldec + cmp.w d2,d3 + bls.s .vol_do_lerp + +.vol_lerp_next_section + move.w (a1),a2 + IFNE PRETRACKER_BUGFIX_CODE + lea pre_roll_off_table+2(pc),a1 ; Take the right boundary value + ELSE + lea pre_roll_off_table(pc),a1 ; This will set a wrong boundary and thus plateau the slope decay speed + ENDC + add.w d3,a1 + add.w d3,a1 + + move.w d3,d2 ; update next boundary + +.vol_do_lerp ; ((lowerbound-upperbound)*(d3<<8))>>8 + upperbound + move.w a2,d1 + move.w (a1),d0 + sub.w d1,d0 ; delta between lower and upper bound (negative value) + beq.s .vol_skip_lerp + + swap d3 + move.w d3,d1 + lsr.w #8,d1 + muls d0,d1 + asr.l #8,d1 + add.w a2,d1 + swap d3 + +.vol_keep_voldec +.vol_skip_lerp + swap d3 + sub.w d1,d5 + bls.s .vol_do_sustain + + move.w d5,d6 + lsr.w #8,d6 + + cmp.b wi_vol_sustain_b(a3),d6 + bls.s .vol_do_sustain + + move.b (a0),d0 + ext.w d0 + muls d6,d0 + btst #3,wi_flags_b(a3) ; boost flag + CLIPORTRUNC8BIT d0 + move.b d0,(a0)+ + + dbra d4,.vol_decay_normal_loop + bra.s .vol_envelope_finished + +; ---------------------------------------- +; sustain phase +.vol_do_sustain + moveq.l #0,d3 + move.b wi_vol_sustain_b(a3),d3 + beq.s .vol_sustain_silence + + btst #3,wi_flags_b(a3) ; boost flag + beq.s .vol_sustain_normal +.vol_sustain_boosted +.vol_sustain_boosted_loop + move.b (a0),d0 + ext.w d0 + muls d3,d0 + asr.w #6,d0 + + CLIPTO8BIT d0 + move.b d0,(a0)+ + dbra d4,.vol_sustain_boosted_loop + bra.s .vol_envelope_finished + +.vol_sustain_silence + moveq.l #0,d0 +.vol_sustain_silence_loop + move.b d0,(a0)+ + dbra d4,.vol_sustain_silence_loop + bra.s .vol_envelope_finished + +.vol_sustain_normal + IFNE PRETRACKER_FASTER_CODE + cmp.b #$ff,d3 + beq.s .vol_envelope_finished + ENDC + +.vol_sustain_normal_loop + move.b (a0),d0 + ext.w d0 + muls d3,d0 + asr.w #8,d0 + move.b d0,(a0)+ + dbra d4,.vol_sustain_normal_loop + +.vol_envelope_finished + +; ---------------------------------------- +; Optional Post-Modulator + + btst #5,wi_mod_density_b(a3) ; post bit + beq.s .nopostmodulator + bsr.s pre_Modulator +.nopostmodulator + +; ---------------------------------------- +; wave mixing (removed some code here that was doing nothing as result +; because below higher octaves code would overwrite it anyway). + IFND PRESTO_UNIFIED_STRUCT + movea.l pv_my_song(a4),a6 + ENDC + + moveq.l #0,d0 + move.b wi_mix_wave_b(a3),d0 + beq.s .mix_no_wave_mixing ; no mixing selected + subq.b #1,d0 + IFNE PRETRACKER_PARANOIA_MODE ; same wave for mixing cannot be selected in Pretracker + cmp.b pv_wg_curr_wave_num_b(a4),d0 + beq .mix_no_wave_mixing ; same wave number! + ENDC + + lsl.w #2,d0 + move.l pv_wave_sample_table(a4,d0.w),a1 + IFND PRESTO_UNIFIED_STRUCT + add.w #sv_wavelength_table,d0 + move.l (a6,d0.w),d3 + ELSE + move.l pv_wavelength_table(a4,d0.w),d3 + ENDC + + move.w pv_wg_curr_sample_len_w(a4),d4 ; length of the sample to mix to + cmp.w d3,d4 + ble.s .mix_picked_shorter + move.w d3,d4 +.mix_picked_shorter + + move.l pv_wg_curr_sample_ptr(a4),a0 + + subq.w #1,d4 +.mix_mixloop + move.b (a0),d0 + add.b (a1)+,d0 + CLIPTO8BITAFTERADD d0 + move.b d0,(a0)+ + dbra d4,.mix_mixloop +.mix_no_wave_mixing + +; ---------------------------------------- +; create higher octaves (this has been massively shortened) + + btst #2,wi_flags_b(a3) + beq.s .oct_has_no_extra_octaves + + move.l pv_wg_curr_sample_len_l(a4),d4 + IFNE PRETRACKER_PARANOIA_MODE + beq.s .oct_has_no_extra_octaves + ENDC + + movea.l pv_wg_curr_sample_ptr(a4),a1 + lea (a1,d4.l),a0 ; needs to be .l due to 32678 max length + + mulu #7,d4 + lsr.l #3,d4 ; * 0.875 + subq.w #1,d4 +.oct_downsample_loop + move.b (a1),(a0)+ + addq.l #2,a1 + dbra d4,.oct_downsample_loop + +.oct_has_no_extra_octaves +; ---------------------------------------- + IFNE PRETRACKER_PROGRESS_SUPPORT + move.l pv_precalc_progress_ptr(a4),d0 + beq.s .no_progress_out + move.l d0,a0 + move.l pv_precalc_sample_size(a4),d0 + add.l d0,(a0) +.no_progress_out + ENDC + move.l (sp)+,a1 + subq.w #1,pv_wg_wave_counter_w(a4) + bgt .wavegenloop + + rts + +;-------------------------------------------------------------------- +; a3: waveinfo +; +; uses all data registers and a0-a1 (a2/a3 unchanged) +pre_Modulator: + tst.b wi_mod_wetness_b(a3) + beq.s .earlyexit + moveq.l #7,d0 + and.b wi_mod_density_b(a3),d0 + bne.s .has_density +.earlyexit + rts +.has_density + move.l pv_wg_curr_sample_ptr(a4),a0 + move.w pv_wg_curr_sample_len_w(a4),d4 + IFNE PRETRACKER_PARANOIA_MODE + bne.s .not_zero + rts +.not_zero + ENDC + moveq.l #0,d6 + move.b wi_mod_wetness_b(a3),d6 + + moveq.l #0,d7 + + lea pre_modulator_ramp_8(pc),a1 +.loop moveq.l #0,d5 + move.b wi_mod_length_b(a3),d5 + mulu (a1)+,d5 ; result is a long value + + moveq.l #0,d1 + move.b wi_mod_predelay_b(a3),d1 + + btst #5,wi_mod_density_b(a3) ; post-modulator? + bne.s .factor1_256 + ; factor 1/4 and 64 + lsr.l #2,d5 + lsl.l #6,d1 + bra.s .cont + +.factor1_256 + lsl.w #8,d1 +.cont add.l d1,d5 ; sum up length and predelay + + moveq.l #0,d2 + moveq.l #0,d3 + +.innerloop + moveq.l #0,d1 + add.w d7,d3 + addq.w #8,d3 + smi d1 + ext.w d1 + eor.w d3,d1 ; flip order if it was negative + lsr.w #6,d1 ; 4 bit key is bits 14 to 11, needs to be 8 to 5 + and.w #15<<5,d1 + + add.l d5,d1 + lsr.l #6,d1 + + move.w d2,d0 + sub.w d1,d0 + bmi.s .is_outside_sample + + move.b (a0,d0.w),d1 + ext.w d1 + btst #0,d7 + beq.s .keep_dc + neg.w d1 +.keep_dc + + muls d6,d1 + asr.w #8,d1 + add.b (a0,d2.w),d1 + + CLIPTO8BITAFTERADD d1 + move.b d1,(a0,d2.w) +.is_outside_sample + addq.w #1,d2 + cmp.w d4,d2 + bcs.s .innerloop + +.restartloop + addq.w #1,d7 + moveq.l #7,d0 + and.b wi_mod_density_b(a3),d0 + cmp.w d0,d7 + bcs.s .loop + rts + + +;-------------------------------------------------------------------- + +pre_MemClr + lsr.w #1,d0 + subq.w #1,d0 + bmi.s .skipmemclr + moveq.l #0,d1 +.fillmemloop + move.w d1,(a0)+ + dbra d0,.fillmemloop +.skipmemclr + rts diff --git a/source/framework/os_startupcode.asm b/source/framework/os_startupcode.asm index 2e54b2b..b723542 100644 --- a/source/framework/os_startupcode.asm +++ b/source/framework/os_startupcode.asm @@ -22,9 +22,9 @@ FASTMEM_SIZE = 4 move.l a0,fw_DemoAbortStackPointer(a6) ENDC - PUTMSG 10,<"%d: Entrypoint: %p">,fw_FrameCounterLong(a6),#entrypoint + PUTMSG 10,<"%d: Entrypoint: %p">,fw_FrameCounter-2(a6),#entrypoint bsr entrypoint - PUTMSG 10,<"%d: Part terminated">,fw_FrameCounterLong(a6) + PUTMSG 10,<"%d: Part terminated">,fw_FrameCounter-2(a6) bra os_AppShutdown @@ -39,6 +39,21 @@ os_AppInit: ENDC move.l 4.w,a6 + IF DEBUG_DETAIL + move.l #MEMF_CHIP,d1 + CALL AvailMem + PUTMSG 10,<"Chip memory free: %ld bytes">,d0 + move.l #MEMF_CHIP|MEMF_LARGEST,d1 + CALL AvailMem + PUTMSG 10,<"Chip memory largest: %ld bytes">,d0 + move.l #MEMF_FAST,d1 + CALL AvailMem + PUTMSG 10,<"Fast memory free: %ld bytes">,d0 + move.l #MEMF_FAST|MEMF_LARGEST,d1 + CALL AvailMem + PUTMSG 10,<"Fast memory largest: %ld bytes">,d0 + ENDC + IFEQ FW_HD_TRACKMO_MODE IFD pd_SIZEOF move.l #pd_SIZEOF,d0 @@ -220,7 +235,7 @@ os_AppInit: IF FW_DYNAMIC_MEMORY_SUPPORT IF FW_MUSIC_SUPPORT - IF (FW_MUSIC_PLAYER_CHOICE==4)||(FW_MUSIC_PLAYER_CHOICE==5) + IF (FW_MUSIC_PLAYER_CHOICE>=4)&&(FW_MUSIC_PLAYER_CHOICE<=6) bsr fw_MusicAlloc ENDC ENDC @@ -230,7 +245,7 @@ os_AppInit: ELSE ; FW_DYNAMIC_MEMORY_SUPPORT IF FW_MUSIC_SUPPORT - IF (FW_MUSIC_PLAYER_CHOICE==4)||(FW_MUSIC_PLAYER_CHOICE==5) + IF (FW_MUSIC_PLAYER_CHOICE>=4)&&(FW_MUSIC_PLAYER_CHOICE<=6) bsr fw_MusicAlloc bsr fw_PushMemoryState ENDC @@ -299,8 +314,15 @@ os_AppInit: lea $dff000,a5 exg a4,a6 ; from now on, a6 is supposed to be our framework pointer, a5 is _custom move.l a0,fw_VBR(a6) + IF FW_SOFT_IRQ_SUPPORT + move.l $64(a0),fw_OldSystemSoftIRQ(a6) + ENDC move.l $6c(a0),fw_OldSystemVBlankIRQ(a6) + IF FW_AUDIO_IRQ_SUPPORT + move.l $70(a0),fw_OldSystemAudioIRQ(a6) + ENDC + move.w #$7fff,d4 move.w intenar(a5),d0 move.w d4,intena(a5) @@ -388,7 +410,13 @@ os_AppShutdown: move.w d0,adkcon(a5) move.l fw_VBR(a6),a0 + IF FW_SOFT_IRQ_SUPPORT + move.l fw_OldSystemSoftIRQ(a6),$64(a0) + ENDC move.l fw_OldSystemVBlankIRQ(a6),$6c(a0) + IF FW_AUDIO_IRQ_SUPPORT + move.l fw_OldSystemAudioIRQ(a6),$70(a0) + ENDC movea.l fw_GfxBase(a6),a0 ; graphics.library move.l $26(a0),cop1lc(a5) diff --git a/source/framework/trackmo_startupcode.asm b/source/framework/trackmo_startupcode.asm index 71a61cd..121b6a7 100644 --- a/source/framework/trackmo_startupcode.asm +++ b/source/framework/trackmo_startupcode.asm @@ -143,7 +143,7 @@ trackmo_AppInit: bsr fw_InitDos IF FW_MUSIC_SUPPORT - IF (FW_MUSIC_PLAYER_CHOICE==4)||(FW_MUSIC_PLAYER_CHOICE==5) + IF (FW_MUSIC_PLAYER_CHOICE>=4)&&(FW_MUSIC_PLAYER_CHOICE<=6) bsr fw_MusicAlloc ENDC ENDC diff --git a/source/gotham/gotham.asm b/source/gotham/gotham.asm index 3c8d934..d7774db 100644 --- a/source/gotham/gotham.asm +++ b/source/gotham/gotham.asm @@ -61,7 +61,7 @@ DEBUG_DETAIL SET 10 NEWAGE_DEBUG = 1 - include "../framework/framework.i" + include "framework.i" ; Memory use: @@ -109,7 +109,7 @@ NEWAGE_DEBUG = 1 LABEL pd_SIZEOF IFND FW_DEMO_PART - include "../framework/framework.asm" + include "framework.asm" ENDC entrypoint: @@ -945,22 +945,22 @@ gth_extra_copperlist_ptr: COP_END gth_meanwhile_text: - incbin "../data/gotham/meanwhile320x18x4.BPL" + incbin "data/gotham/meanwhile320x18x4.BPL" gth_gothamcity_text: - incbin "../data/gotham/gothamcity320x23x4.BPL" + incbin "data/gotham/gothamcity320x23x4.BPL" gth_gotham_text: - incbin "../data/gotham/gotham320x23x4.BPL" + incbin "data/gotham/gotham320x23x4.BPL" gth_hameelinna_text: - incbin "../data/gotham/hameelinna320x23x4.BPL" + incbin "data/gotham/hameelinna320x23x4.BPL" gth_ham_text: - incbin "../data/gotham/ham320x23x4.BPL" + incbin "data/gotham/ham320x23x4.BPL" gth_ham_tech: - incbin "../data/gotham/hamtechnology320x13x4.BPL" + incbin "data/gotham/hamtechnology320x13x4.BPL" blitter_temp_output_word: dc.w 0 @@ -968,7 +968,7 @@ blitter_temp_output_word: IFND FW_DEMO_PART section "gth_sample",data,chip gth_psenough_ham: - incbin "../data/gotham/hamtechnology.raw" + incbin "data/gotham/hamtechnology.raw" ENDC END \ No newline at end of file diff --git a/source/gouraud/gouraud.asm b/source/gouraud/gouraud.asm index 4ee9b7b..939e918 100755 --- a/source/gouraud/gouraud.asm +++ b/source/gouraud/gouraud.asm @@ -97,7 +97,7 @@ NEWAGE_DEBUG = 1 ; - FAST BSS 32 x 1424 = 45568 (Cube preprocessing) 12+3*3*2*2+8*3*2+8*2*2+12*(11*4+4+8*2) - include "../framework/framework.i" + include "framework.i" STRUCTURE BQLine,bq_SIZEOF ULONG bql_BltCon01 @@ -228,7 +228,7 @@ NEWAGE_DEBUG = 1 LABEL pd_SIZEOF IFND FW_DEMO_PART - include "../framework/framework.asm" + include "framework.asm" ENDC entrypoint: @@ -410,7 +410,7 @@ gou_intro: lea .script(pc),a0 CALLFW InstallMusicScript - PUTMSG 10,<"Main Frame Start %ld">,fw_FrameCounterLong(a6) + PUTMSG 10,<"Main Frame Start %ld">,fw_FrameCounter-2(a6) .loop BLTWAIT @@ -881,7 +881,7 @@ gou_flip_cube_buffer: ;-------------------------------------------------------------------- gou_async_calc_task: - PUTMSG 10,<"%d: async_calc_task">,fw_FrameCounterLong(a6) + PUTMSG 10,<"%d: async_calc_task">,fw_FrameCounter-2(a6) move.l pd_CubeDataPtr(a6),a1 moveq.l #CUBE_PRECALC_NUM-1,d7 .cdloop @@ -1252,7 +1252,7 @@ ZEROIPOL MACRO ;-------------------------------------------------------------------- ; a1 = cubedata gou_interpolate_outer_cube_lines: - PUTMSG 20,<"%d: ----- gou_interpolate_outer_cube_lines">,fw_FrameCounterLong(a6) + PUTMSG 20,<"%d: ----- gou_interpolate_outer_cube_lines">,fw_FrameCounter-2(a6) move.w cd_LinesToDraw(a1),d7 sub.w cd_InnerLines(a1),d7 bne.s .cont @@ -1961,7 +1961,7 @@ LINEIPOL MACRO ;-------------------------------------------------------------------- ; a1 = cubedata gou_interpolate_inner_cube_lines: - PUTMSG 20,<"%d: ----- gou_interpolate_inner_cube_lines">,fw_FrameCounterLong(a6) + PUTMSG 20,<"%d: ----- gou_interpolate_inner_cube_lines">,fw_FrameCounter-2(a6) move.w cd_InnerLines(a1),d7 bne.s .cont rts @@ -2994,7 +2994,7 @@ gou_extra_copperlist_ptr: COP_END gou_bendit_sprite: - incbin "../data/gouraud/bendit128x128x4.SPR" + incbin "data/gouraud/bendit128x128x4.SPR" blitter_temp_output_word: dc.w 0 @@ -3003,11 +3003,11 @@ blitter_temp_output_word: IFD ENABLE_PART_MUSIC section "part_music_samples",data,chip ; section for music playback part_music_smp: - incbin "../data/music/dsr_68k_tune_2_v11.lsbank" + incbin "data/music/dsr_68k_tune_2_v11.lsbank" section "part_music_data",data ; section for music playback part_music_data: - incbin "../data/music/dsr_68k_tune_2_v11.lsmusic" + incbin "data/music/dsr_68k_tune_2_v11.lsmusic" ENDC ENDC END \ No newline at end of file diff --git a/source/hamazing/build.bat b/source/hamazing/build.bat index e601cb4..fb55404 100644 --- a/source/hamazing/build.bat +++ b/source/hamazing/build.bat @@ -93,9 +93,9 @@ copy "..\data\endpart\screenshots_320x1620.BPL" build rem ############ ASSEMBLE FRAMEWORK AND BOOTBLOCK ############ copy "..\tools\vc.cfg" %~dp0 -..\tools\vasmm68k_mot -m68010 -Fbin -phxass -o "build\trackmo_launcher" -I"%~dp0\..\includes" "trackmo_launcher.asm" +..\tools\vasmm68k_mot -m68010 -Fbin -phxass -o "build\trackmo_launcher" -I"%~dp0\..\framework" -I"%~dp0\..\includes" "trackmo_launcher.asm" @if %ERRORLEVEL% NEQ 0 goto failed -..\tools\vasmm68k_mot -m68000 -Fbin -phxass -o "build\bootblock" -I"%~dp0\..\includes" "..\framework\bootblock.asm" +..\tools\vasmm68k_mot -m68000 -Fbin -phxass -o "build\bootblock" -I"%~dp0\..\includes" -I"%~dp0\..\includes" "..\framework\bootblock.asm" @if %ERRORLEVEL% NEQ 0 goto failed rem ############ BUILD DISK ############ diff --git a/source/hamazing/hd_launcher.asm b/source/hamazing/hd_launcher.asm index 793e4a6..a06428f 100644 --- a/source/hamazing/hd_launcher.asm +++ b/source/hamazing/hd_launcher.asm @@ -6,8 +6,8 @@ NEWAGE_DEBUG = 1 ; enable for UAE warp exit on start with debug detail en CHIPMEM_SIZE = 469*1024 ; maximum chip memory use for whole demo FASTMEM_SIZE = 458*1024 ; maximum fast memory use for whole demo - include "../framework/framework.i" - include "../framework/framework.asm" + include "framework.i" + include "framework.asm" entrypoint: include "trackmo_script.asm" diff --git a/source/hamazing/trackmo_launcher.asm b/source/hamazing/trackmo_launcher.asm index a0b4c93..0f2773b 100644 --- a/source/hamazing/trackmo_launcher.asm +++ b/source/hamazing/trackmo_launcher.asm @@ -1,7 +1,7 @@ opt p+,o+ include "trackmo_settings.i" - include "../framework/framework.i" + include "framework.i" bsr trackmo_AppInit @@ -11,4 +11,4 @@ .loop bra.s .loop - include "../framework/framework.asm" + include "framework.asm" diff --git a/source/hamazing/trackmo_script.asm b/source/hamazing/trackmo_script.asm index c24383a..b62ba9e 100644 --- a/source/hamazing/trackmo_script.asm +++ b/source/hamazing/trackmo_script.asm @@ -18,7 +18,7 @@ ; trackmo: - PUTMSG 10,<"%d: Trackmo start!">,fw_FrameCounterLong(a6) + PUTMSG 10,<"%d: Trackmo start!">,fw_FrameCounter-2(a6) .restart btst #6,$bfe001 bne.s .part1 diff --git a/source/hexagon/hexagon.asm b/source/hexagon/hexagon.asm index a771df2..277a167 100644 --- a/source/hexagon/hexagon.asm +++ b/source/hexagon/hexagon.asm @@ -64,7 +64,7 @@ DEBUG_DETAIL SET 10 NEWAGE_DEBUG = 1 - include "../framework/framework.i" + include "framework.i" STRUCTURE PartData,fw_SIZEOF APTR pd_CurrPlanesPtr @@ -107,7 +107,7 @@ NEWAGE_DEBUG = 1 LABEL pd_SIZEOF IFND FW_DEMO_PART - include "../framework/framework.asm" + include "framework.asm" ENDC entrypoint: @@ -260,7 +260,7 @@ hex_init_shade_table: ;-------------------------------------------------------------------- hex_main: - PUTMSG 10,<"%d: Main part started (%d music frames)">,fw_FrameCounterLong(a6),fw_MusicFrameCount-2(a6) + PUTMSG 10,<"%d: Main part started (%d music frames)">,fw_FrameCounter-2(a6),fw_MusicFrameCount-2(a6) move.w #2,copcon(a5) ; enable copper danger (copper controlled blitter) @@ -865,7 +865,7 @@ hex_hexgrid_black_palette: ENDR hex_hexgrid_data: - incbin "../data/hexagon/hexagon_reg16x254.EHB" + incbin "data/hexagon/hexagon_reg16x254.EHB" section "hex_copper",data,chip @@ -887,21 +887,21 @@ hex_extra_copperlist_ptr: COP_END hex_winners_sprites: - incbin "../data/hexagon/winners128x128x4.SPR" + incbin "data/hexagon/winners128x128x4.SPR" IFND FW_DEMO_PART section "hex_kaleidoscope_texture",data hex_kaleidoscope_texture: - incbin "../data/hexagon/kaleitc.raw" + incbin "data/hexagon/kaleitc.raw" IFD ENABLE_PART_MUSIC section "part_music_samples",data,chip ; section for music playback part_music_smp: - incbin "../data/music/desire_demo_68k_v6.lsbank" + incbin "data/music/desire_demo_68k_v6.lsbank" section "part_music_data",data ; section for music playback part_music_data: - incbin "../data/music/desire_demo_68k_v6.lsmusic" + incbin "data/music/desire_demo_68k_v6.lsmusic" ENDC ENDC diff --git a/source/kaleidoscope/kaleidoscope.asm b/source/kaleidoscope/kaleidoscope.asm index 4d8d3fb..1e7b09e 100644 --- a/source/kaleidoscope/kaleidoscope.asm +++ b/source/kaleidoscope/kaleidoscope.asm @@ -115,7 +115,7 @@ DEBUG_DETAIL SET 10 NEWAGE_DEBUG = 1 - include "../framework/framework.i" + include "framework.i" ; Chip memory use: ; - CHIP DATA: 256 x 256 x 6 x 3 = 147456 (Pattern/Texture) @@ -319,7 +319,7 @@ NEWAGE_DEBUG = 1 LABEL pd_SIZEOF IFND FW_DEMO_PART - include "../framework/framework.asm" + include "framework.asm" ENDC entrypoint: @@ -676,7 +676,7 @@ kds_fill_noise_buffer: ;-------------------------------------------------------------------- kds_intro: - PUTMSG 10,<"%d: Intro part started (%d music frames)">,fw_FrameCounterLong(a6),fw_MusicFrameCount-2(a6) + PUTMSG 10,<"%d: Intro part started (%d music frames)">,fw_FrameCounter-2(a6),fw_MusicFrameCount-2(a6) move.w #420,pd_PartCountDown(a6) CALLFW SetBlitterQueueSingleFrame @@ -705,7 +705,7 @@ kds_intro: cmp.w #4032,fw_MusicFrameCount(a6) blt.s .waitloop - PUTMSG 10,<"%d: Intro part launching (%d music frames)">,fw_FrameCounterLong(a6),fw_MusicFrameCount-2(a6) + PUTMSG 10,<"%d: Intro part launching (%d music frames)">,fw_FrameCounter-2(a6),fw_MusicFrameCount-2(a6) .loop bsr kds_flip_db_frame @@ -746,7 +746,7 @@ kds_intro: ;-------------------------------------------------------------------- kds_transition: - PUTMSG 10,<"%d: Transition part started (%d music frames)">,fw_FrameCounterLong(a6),fw_MusicFrameCount-2(a6) + PUTMSG 10,<"%d: Transition part started (%d music frames)">,fw_FrameCounter-2(a6),fw_MusicFrameCount-2(a6) move.w #260,pd_PartCountDown(a6) CALLFW SetBlitterQueueSingleFrame @@ -822,7 +822,7 @@ kds_transition: ;-------------------------------------------------------------------- kds_dissolve: - PUTMSG 10,<"%d: Dissolve part started (%d music frames)">,fw_FrameCounterLong(a6),fw_MusicFrameCount-2(a6) + PUTMSG 10,<"%d: Dissolve part started (%d music frames)">,fw_FrameCounter-2(a6),fw_MusicFrameCount-2(a6) CALLFW SetBlitterQueueSingleFrame @@ -870,7 +870,7 @@ kds_dissolve: ;-------------------------------------------------------------------- kds_pre_main: - PUTMSG 10,<"%d: Pre Main part started (%d music frames)">,fw_FrameCounterLong(a6),fw_MusicFrameCount-2(a6) + PUTMSG 10,<"%d: Pre Main part started (%d music frames)">,fw_FrameCounter-2(a6),fw_MusicFrameCount-2(a6) CALLFW SetBlitterQueueMultiFrame move.w joy0dat(a5),pd_OldMouseY(a6) @@ -979,11 +979,11 @@ kds_pre_main: ;-------------------------------------------------------------------- kds_post_main: - PUTMSG 10,<"%d: Post Main part started (%d music frames)">,fw_FrameCounterLong(a6),fw_MusicFrameCount-2(a6) + PUTMSG 10,<"%d: Post Main part started (%d music frames)">,fw_FrameCounter-2(a6),fw_MusicFrameCount-2(a6) bsr .prepare bsr .prepare - PUTMSG 10,<"%d: Prep done">,fw_FrameCounterLong(a6) + PUTMSG 10,<"%d: Prep done">,fw_FrameCounter-2(a6) .loop bsr kds_flip_db_frame move.l pd_CurrSpriteStencilPtr(a6),pd_CurrFairySprite(a6) @@ -1020,7 +1020,7 @@ kds_post_main: bsr kds_update_copper_list_pointers CALLFW VSyncWithTask - PUTMSG 10,<"%d: Post Main finished (%d music frames)">,fw_FrameCounterLong(a6),fw_MusicFrameCount-2(a6) + PUTMSG 10,<"%d: Post Main finished (%d music frames)">,fw_FrameCounter-2(a6),fw_MusicFrameCount-2(a6) rts @@ -1049,7 +1049,7 @@ kds_post_main: ;-------------------------------------------------------------------- kds_main: - PUTMSG 10,<"%d: Main part started (%d music frames)">,fw_FrameCounterLong(a6),fw_MusicFrameCount-2(a6) + PUTMSG 10,<"%d: Main part started (%d music frames)">,fw_FrameCounter-2(a6),fw_MusicFrameCount-2(a6) CALLFW SetBlitterQueueMultiFrame IF 0 @@ -6211,7 +6211,7 @@ kds_bright_transition_palette: dc.w $68c,$68c,$9f4,$9f4,$fff,$fff,$ffc,$ffc kds_fairy_sprite_palette: - incbin "../data/kaleidoscope/fairy1_48x51x16.PAL" + incbin "data/kaleidoscope/fairy1_48x51x16.PAL" ; Points kds_fairy_points: @@ -6312,22 +6312,22 @@ kds_extra_copperlist_ptr: COP_END kds_fairy_body1: - incbin "../data/kaleidoscope/fairy1_48x51x16.BPL" + incbin "data/kaleidoscope/fairy1_48x51x16.BPL" kds_fairy_body2: - incbin "../data/kaleidoscope/fairy2_48x51x16.BPL" + incbin "data/kaleidoscope/fairy2_48x51x16.BPL" kds_fairy_body3: - incbin "../data/kaleidoscope/fairy3_48x51x16.BPL" + incbin "data/kaleidoscope/fairy3_48x51x16.BPL" kds_puff_sprite1: - incbin "../data/kaleidoscope/puff1_32x15x16.BPL" + incbin "data/kaleidoscope/puff1_32x15x16.BPL" kds_puff_sprite2: - incbin "../data/kaleidoscope/puff2_32x15x16.BPL" + incbin "data/kaleidoscope/puff2_32x15x16.BPL" kds_puff_sprite3: - incbin "../data/kaleidoscope/puff3_32x15x16.BPL" + incbin "data/kaleidoscope/puff3_32x15x16.BPL" kds_puff_sprite4: - incbin "../data/kaleidoscope/puff4_32x15x16.BPL" + incbin "data/kaleidoscope/puff4_32x15x16.BPL" kds_kaleidoscope_pattern: - incbin "../data/kaleidoscope/plt_neuro2_ham.raw" + incbin "data/kaleidoscope/plt_neuro2_ham.raw" blitter_temp_output_word: dc.w 0 @@ -6336,11 +6336,11 @@ blitter_temp_output_word: IFD ENABLE_PART_MUSIC section "part_music_samples",data,chip ; section for music playback part_music_smp: - incbin "../data/music/desire_demo_68k_v6.lsbank" + incbin "data/music/desire_demo_68k_v6.lsbank" section "part_music_data",data ; section for music playback part_music_data: - incbin "../data/music/desire_demo_68k_v6.lsmusic" + incbin "data/music/desire_demo_68k_v6.lsmusic" ENDC ENDC diff --git a/source/stham/stham.asm b/source/stham/stham.asm index 2f579f7..a492192 100644 --- a/source/stham/stham.asm +++ b/source/stham/stham.asm @@ -81,7 +81,7 @@ DEBUG_DETAIL SET 10 NEWAGE_DEBUG = 1 - include "../framework/framework.i" + include "framework.i" ; Memory use: @@ -151,7 +151,7 @@ NEWAGE_DEBUG = 1 LABEL pd_SIZEOF IFND FW_DEMO_PART - include "../framework/framework.asm" + include "framework.asm" ENDC entrypoint: @@ -188,9 +188,9 @@ entrypoint: IFD FW_DEMO_PART move.l fw_GlobalUserData(a6),a0 move.l pd_HamphreyBuffer(a6),a1 - PUTMSG 10,<"%d: Decrunching from %p to %p">,fw_FrameCounterLong(a6),a0,a1 + PUTMSG 10,<"%d: Decrunching from %p to %p">,fw_FrameCounter-2(a6),a0,a1 CALLFW DecompressZX0 - PUTMSG 10,<"%d: Image decrunched until %p">,fw_FrameCounterLong(a6),a1 + PUTMSG 10,<"%d: Image decrunched until %p">,fw_FrameCounter-2(a6),a1 clr.l fw_GlobalUserData(a6) ENDC bsr sth_create_curtain @@ -284,9 +284,9 @@ sth_init_vars: sth_intro: IFD FW_DEMO_PART - PUTMSG 10,<"%d: Intro part started (%d music frames)">,fw_FrameCounterLong(a6),fw_MusicFrameCount-2(a6) + PUTMSG 10,<"%d: Intro part started (%d music frames)">,fw_FrameCounter-2(a6),fw_MusicFrameCount-2(a6) ELSE - PUTMSG 10,<"%d: Intro part started">,fw_FrameCounterLong(a6) + PUTMSG 10,<"%d: Intro part started">,fw_FrameCounter-2(a6) move.w #400,pd_PartCountDown(a6) ENDC @@ -312,9 +312,9 @@ sth_intro: sth_main: IFD FW_DEMO_PART - PUTMSG 10,<"%d: Main part started (%d music frames)">,fw_FrameCounterLong(a6),fw_MusicFrameCount-2(a6) + PUTMSG 10,<"%d: Main part started (%d music frames)">,fw_FrameCounter-2(a6),fw_MusicFrameCount-2(a6) ELSE - PUTMSG 10,<"%d: Main part started">,fw_FrameCounterLong(a6) + PUTMSG 10,<"%d: Main part started">,fw_FrameCounter-2(a6) ENDC move.w #800,pd_PartCountDown(a6) CALLFW SetBlitterQueueSingleFrame @@ -364,9 +364,9 @@ sth_main: sth_curtain: IFD FW_DEMO_PART - PUTMSG 10,<"%d: Curtain part started (%d music frames)">,fw_FrameCounterLong(a6),fw_MusicFrameCount-2(a6) + PUTMSG 10,<"%d: Curtain part started (%d music frames)">,fw_FrameCounter-2(a6),fw_MusicFrameCount-2(a6) ELSE - PUTMSG 10,<"%d: Curtain part started">,fw_FrameCounterLong(a6) + PUTMSG 10,<"%d: Curtain part started">,fw_FrameCounter-2(a6) ENDC move.w #186,pd_PartCountDown(a6) CALLFW SetBlitterQueueSingleFrame @@ -791,7 +791,7 @@ sth_drop_bars: sth_create_curtain: move.l pd_CurtainDataPtr(a6),a0 - PUTMSG 10,<"%d: Curtain %p">,fw_FrameCounterLong(a6),a0 + PUTMSG 10,<"%d: Curtain %p">,fw_FrameCounter-2(a6),a0 move.l #(spr+0*sd_SIZEOF+sd_pos)<<16,d4 move.l #$1fe<<16,d3 @@ -862,7 +862,7 @@ sth_create_curtain: move.l d3,(a0)+ dbra d7,.emptylineloop - PUTMSG 10,<"%d: Curtain done">,fw_FrameCounterLong(a6) + PUTMSG 10,<"%d: Curtain done">,fw_FrameCounter-2(a6) rts ;-------------------------------------------------------------------- @@ -1373,10 +1373,10 @@ sth_scrolltext: even sth_curtainsines: - incbin "../data/stham/curtainsine.bin" + incbin "data/stham/curtainsine.bin" sth_hamphrey_palette: - include "../data/stham/PLT_HAMph_path_2_test08b_ham.pal.asm" + include "data/stham/PLT_HAMph_path_2_test08b_ham.pal.asm" ; https://gradient-blaster-grahambates.vercel.app/?points=cff@0,09a@171&steps=256&blendMode=oklab&ditherMode=errorDiffusion&target=amigaOcs&ditherAmount=55 sth_scroller_gradient: @@ -1721,7 +1721,7 @@ sth_scroller_shift_2_bitmap: IFND FW_DEMO_PART sth_hamphrey_pic: - incbin "../data/stham/PLT_HAMph_path_2_test08b_ham.raw" + incbin "data/stham/PLT_HAMph_path_2_test08b_ham.raw" ENDC END \ No newline at end of file diff --git a/source/tools/demo.cfg b/source/tools/demo.cfg index 4b3a697..c14bba9 100644 --- a/source/tools/demo.cfg +++ b/source/tools/demo.cfg @@ -1,5 +1,5 @@ --as=vasmm68k_mot -x -maxerrors=50 -m68000 -Fhunk -align -phxass %s -DFW_DEMO_PART=1 -o %s -I"%%VBCC%%/../includes" -quiet --asv=vasmm68k_mot -x -maxerrors=50 -m68000 -Fhunk -align -phxass %s -DFW_DEMO_PART=1 -o %s -I"%%VBCC%%/../includes" +-as=vasmm68k_mot -x -maxerrors=50 -m68000 -Fhunk -align -phxass %s -DFW_DEMO_PART=1 -o %s -I"%%VBCC%%/../" -I"%%VBCC%%/../framework" -I"%%VBCC%%/../framework/musicplayers" -I"%%VBCC%%/../includes" -quiet +-asv=vasmm68k_mot -x -maxerrors=50 -m68000 -Fhunk -align -phxass %s -DFW_DEMO_PART=1 -o %s -I"%%VBCC%%/../" -I"%%VBCC%%/../framework" -I"%%VBCC%%/../framework/musicplayers" -I"%%VBCC%%/../includes" -cc=vbccm68k -warn=-1 -maxerrors=50 -dontwarn=168 -dontwarn=81 -c99 %s -o= %s %s -O=%ld -quiet -ccv=vbccm68k -warn=-1 -maxerrors=50 -dontwarn=168 -dontwarn=81 -c99 %s -o= %s %s -O=%ld -l2=vlink -bamigahunk -Bstatic -Cvbcc -nostdlib -L"%%VBCC%%/targets/m68k-amigaos/lib" %s %s -o %s diff --git a/source/tools/vc.cfg b/source/tools/vc.cfg index 7449a33..3039980 100644 --- a/source/tools/vc.cfg +++ b/source/tools/vc.cfg @@ -1,11 +1,11 @@ --as=vasmm68k_mot -x -maxerrors=50 -m68000 -showopt -Fhunk -kick1hunks -align -phxass %s -o %s -I"%%VBCC%%/../includes" -quiet --asv=vasmm68k_mot -x -maxerrors=50 -m68000 -showopt -Fhunk -kick1hunks -align -phxass %s -o %s -I"%%VBCC%%/../includes" +-as=vasmm68k_mot -x -maxerrors=50 -m68000 -showopt -Fhunk -kick1hunks -align -phxass %s -o %s -I"%%VBCC%%/../" -I"%%VBCC%%/../framework" -I"%%VBCC%%/../framework/musicplayers" -I"%%VBCC%%/../includes" -quiet +-asv=vasmm68k_mot -x -maxerrors=50 -m68000 -showopt -Fhunk -kick1hunks -align -phxass %s -o %s -I"%%VBCC%%/../" -I"%%VBCC%%/../framework" -I"%%VBCC%%/../framework/musicplayers" -I"%%VBCC%%/../includes" -cc=vbccm68k -warn=-1 -maxerrors=50 -dontwarn=168 -dontwarn=81 -c99 %s -o= %s %s -O=%ld -quiet -ccv=vbccm68k -warn=-1 -maxerrors=50 -dontwarn=168 -dontwarn=81 -c99 %s -o= %s %s -O=%ld --l2=vlink -bamigahunk -Bstatic -Cvbcc -nostdlib -mrel -L"%%VBCC%%/targets/m68k-amigaos/lib" %s %s -o %s --l2v=vlink -bamigahunk -Bstatic -Cvbcc -nostdlib -mrel -L"%%VBCC%%/targets/m68k-amigaos/lib" %s %s -o %s -t --ld=vlink -bamigahunk -Bstatic -Cvbcc -nostdlib -mrel -L"%%VBCC%%/targets/m68k-amigaos/lib" "%%VBCC%%/targets/m68k-amigaos/lib/startup.o" %s %s -lvc -o %s --ldv=vlink -bamigahunk -Bstatic -Cvbcc -nostdlib -mrel -L"%%VBCC%%/targets/m68k-amigaos/lib" "%%VBCC%%/targets/m68k-amigaos/lib/startup.o" %s %s -lvc -o %s -t +-l2=vlink -bamigahunk -Bstatic -Cvbcc -Z -nostdlib -mrel -L"%%VBCC%%/targets/m68k-amigaos/lib" %s %s -o %s +-l2v=vlink -bamigahunk -Bstatic -Cvbcc -Z -nostdlib -mrel -L"%%VBCC%%/targets/m68k-amigaos/lib" %s %s -o %s -t +-ld=vlink -bamigahunk -Bstatic -Cvbcc -Z -nostdlib -mrel -L"%%VBCC%%/targets/m68k-amigaos/lib" "%%VBCC%%/targets/m68k-amigaos/lib/startup.o" %s %s -lvc -o %s +-ldv=vlink -bamigahunk -Bstatic -Cvbcc -Z -nostdlib -mrel -L"%%VBCC%%/targets/m68k-amigaos/lib" "%%VBCC%%/targets/m68k-amigaos/lib/startup.o" %s %s -lvc -o %s -t -ldnodb=-S -s -x -ul=-l%s -cf=-F%s diff --git a/source/virgillbars/virgillbars.asm b/source/virgillbars/virgillbars.asm index a236cb3..e50b482 100644 --- a/source/virgillbars/virgillbars.asm +++ b/source/virgillbars/virgillbars.asm @@ -93,7 +93,7 @@ DEBUG_DETAIL SET 10 NEWAGE_DEBUG = 1 - include "../framework/framework.i" + include "framework.i" ; Process: ; @@ -247,7 +247,7 @@ NEWAGE_DEBUG = 1 LABEL pd_SIZEOF IFND FW_DEMO_PART - include "../framework/framework.asm" + include "framework.asm" ENDC entrypoint: @@ -456,7 +456,7 @@ vgb_init_vars: vgb_init_cot_table: move.l fw_CosTable(a6),a1 lea pd_CotTable(a6),a0 - PUTMSG 10,<"%d: CotTable %p">,fw_FrameCounterLong(a6),a0 + PUTMSG 10,<"%d: CotTable %p">,fw_FrameCounter-2(a6),a0 moveq.l #(ROT_ANGLES-1)-1,d7 moveq.l #0,d0 moveq.l #0,d5 @@ -466,13 +466,13 @@ vgb_init_cot_table: move.w d1,(a0)+ addq.l #2*2,a1 dbra d7,.loop - PUTMSG 10,<"%d: CotTable done">,fw_FrameCounterLong(a6) + PUTMSG 10,<"%d: CotTable done">,fw_FrameCounter-2(a6) rts ;-------------------------------------------------------------------- vgb_init_modshift_table: - PUTMSG 10,<"%d: Calc modshift table">,fw_FrameCounterLong(a6) + PUTMSG 10,<"%d: Calc modshift table">,fw_FrameCounter-2(a6) move.l pd_ModShiftDataPtr(a6),a1 move.l pd_XPosBufferPtr(a6),a0 moveq.l #ROT_ANGLES-1,d7 @@ -502,14 +502,14 @@ vgb_init_modshift_table: lea (VGBARS_HEIGHT*2)(a0),a0 subq.w #2,d0 dbra d7,.loop2 - PUTMSG 10,<"%d: Calc modshift table done">,fw_FrameCounterLong(a6) + PUTMSG 10,<"%d: Calc modshift table done">,fw_FrameCounter-2(a6) rts ;-------------------------------------------------------------------- vgb_init_one_color_change_table: move.l pd_OneColorChangeTable(a6),a0 - PUTMSG 10,<"%d: pd_OneColorChangeTable %p">,fw_FrameCounterLong(a6),a0 + PUTMSG 10,<"%d: pd_OneColorChangeTable %p">,fw_FrameCounter-2(a6),a0 moveq.l #1,d0 move.w #$f00,d4 move.w #$0f0,d5 @@ -558,14 +558,14 @@ vgb_init_one_color_change_table: .good addq.w #1,d0 dbra d7,.loop - PUTMSG 10,<"%d: pd_OneColorChangeTable done">,fw_FrameCounterLong(a6) + PUTMSG 10,<"%d: pd_OneColorChangeTable done">,fw_FrameCounter-2(a6) rts ;-------------------------------------------------------------------- vgb_init_red_blue_table: move.l pd_RedBlueTable(a6),a0 - PUTMSG 10,<"%d: pd_RedBlueTable %p">,fw_FrameCounterLong(a6),a0 + PUTMSG 10,<"%d: pd_RedBlueTable %p">,fw_FrameCounter-2(a6),a0 moveq.l #0,d0 move.w #4096-1,d7 .loop @@ -578,14 +578,14 @@ vgb_init_red_blue_table: move.b d2,(a0)+ addq.w #1,d0 dbra d7,.loop - PUTMSG 10,<"%d: pd_RedBlueTable done">,fw_FrameCounterLong(a6) + PUTMSG 10,<"%d: pd_RedBlueTable done">,fw_FrameCounter-2(a6) rts ;-------------------------------------------------------------------- vgb_init_diff_table: move.l pd_DiffTable(a6),a0 - PUTMSG 10,<"%d: pd_DiffTable %p">,fw_FrameCounterLong(a6),a0 + PUTMSG 10,<"%d: pd_DiffTable %p">,fw_FrameCounter-2(a6),a0 add.l #$10000,a0 move.w #256-1,d7 .oloop @@ -614,7 +614,7 @@ vgb_init_diff_table: move.b d4,-(a0) dbra d6,.loop dbra d7,.oloop - PUTMSG 10,<"%d: pd_DiffTable done">,fw_FrameCounterLong(a6) + PUTMSG 10,<"%d: pd_DiffTable done">,fw_FrameCounter-2(a6) rts .takelow move.b d3,-(a0) @@ -626,7 +626,7 @@ vgb_init_diff_table: vgb_init_mod40_table: lea pd_Mod40TablePos(a6),a0 - PUTMSG 10,<"%d: pd_Mod40TablePos %p">,fw_FrameCounterLong(a6),a0 + PUTMSG 10,<"%d: pd_Mod40TablePos %p">,fw_FrameCounter-2(a6),a0 move.l a0,a1 move.w #(VGBARS_WIDTH/8)*VGBARS_PLANES,d2 moveq.l #0,d0 @@ -638,7 +638,7 @@ vgb_init_mod40_table: sub.w d2,d1 move.w d1,-(a1) dbra d7,.loop - PUTMSG 10,<"%d: pd_Mod40TablePos done">,fw_FrameCounterLong(a6) + PUTMSG 10,<"%d: pd_Mod40TablePos done">,fw_FrameCounter-2(a6) rts ;-------------------------------------------------------------------- @@ -3244,12 +3244,12 @@ vgb_xpos_table: dc.w 643,687,737,795,862,942,1037,1154,1299,1486,1735,2083,2605,3475,5214,10429 vgb_cat_sprite_palette: - incbin "../data/virgillbars/PLT_Lolcat64x128x16.PAL" + incbin "data/virgillbars/PLT_Lolcat64x128x16.PAL" - incbin "../data/virgillbars/curtainsine.bin" + incbin "data/virgillbars/curtainsine.bin" vgb_wobble_table: - incbin "../data/virgillbars/curtainsine.bin" - incbin "../data/virgillbars/curtainsine.bin" + incbin "data/virgillbars/curtainsine.bin" + incbin "data/virgillbars/curtainsine.bin" ;******************************************************************** @@ -3282,26 +3282,26 @@ vgb_extra_copperlist_ptr: COP_END vgb_cat_sprite: - incbin "../data/virgillbars/PLT_Lolcat64x128x16.ASP" + incbin "data/virgillbars/PLT_Lolcat64x128x16.ASP" vgb_add_of_light_div_sprite: - incbin "../data/virgillbars/additionsprite96x112x4.SPR" + incbin "data/virgillbars/additionsprite96x112x4.SPR" vgb_light_break_sprite: - incbin "../data/virgillbars/lightbreak128x128x4.SPR" + incbin "data/virgillbars/lightbreak128x128x4.SPR" vgb_stay_broken_sprite: - incbin "../data/virgillbars/staybroken128x128x4.SPR" + incbin "data/virgillbars/staybroken128x128x4.SPR" IFND FW_DEMO_PART IFD ENABLE_PART_MUSIC section "part_music_samples",data,chip ; section for music playback part_music_smp: - incbin "../data/music/dsr_68k_tune_2_v11.lsbank" + incbin "data/music/dsr_68k_tune_2_v11.lsbank" section "part_music_data",data ; section for music playback part_music_data: - incbin "../data/music/dsr_68k_tune_2_v11.lsmusic" + incbin "data/music/dsr_68k_tune_2_v11.lsmusic" ENDC ENDC END \ No newline at end of file