Trkdemo.asm and demosong.asm

From Intellivision Wiki

Jump to: navigation, search


This is an example of use of tracker.asm and tracker.mac.

trkdemo.asm

This is the main entry point. This file requires tracker.asm, tracker.mac, demosong.asm (below) and print.asm to compile.

;* ======================================================================== *;
;*  This code is placed into the public domain by its author.               *;
;*  All copyright rights are hereby relinquished on the code and data in    *;
;*  this file.  -- Arnauld Chevallier, 2008                                 *;
;* ======================================================================== *;
            ROMW        16

;; ======================================================================== ;;
;;  VARIABLES IN SCRACTH RAM                                                ;;
;; ======================================================================== ;;
FRAME       EQU         $0102

TRKSCRACTH  ORG         $01DC, $01DC, "-RWBN"
G_FAD       RMB         1
REF_M       RMB         1
NOTE_A      RMB         1
NOTE_B      RMB         1
NOTE_C      RMB         1
REF_A       RMB         1
REF_B       RMB         1
REF_C       RMB         1
VOL_A       RMB         1
VOL_B       RMB         1
VOL_C       RMB         1
INSTR_A     RMB         1
INSTR_B     RMB         1
INSTR_C     RMB         1
COUNT_A     RMB         1
COUNT_B     RMB         1
COUNT_C     RMB         1
COUNT_M     RMB         1
COUNT_P     RMB         1
PAT         RMB         1

;; ======================================================================== ;;
;;  VARIABLES IN SYSTEM RAM                                                 ;;
;; ======================================================================== ;;
TRKSYSTEM   ORG         $035B, $035B, "-RWBN"
SONG        RMB         1
INS_PTR     RMB         1
POS_A       RMB         1
POS_B       RMB         1
POS_C       RMB         1

;; ======================================================================== ;;
;;  EXEC-friendly ROM header                                                ;;
;; ======================================================================== ;;
            ORG     $5000

ROMHDR:     BIDECLE ZERO            ; MOB picture base   (points to NULL list)
            BIDECLE ZERO            ; Process table      (points to NULL list)
            BIDECLE MAIN            ; Program start address
            BIDECLE ZERO            ; Bkgnd picture base (points to NULL list)
            BIDECLE ONES            ; GRAM pictures      (points to NULL list)
            BIDECLE TITLE           ; Cartridge title/date
            DECLE   $03C0           ; Flags:  No ECS title,
                                    ; run code after title, no clicks
ZERO:       DECLE   $0000           ; Screen border control
            DECLE   $0000           ; 0 = color stack, 1 = f/b mode
ONES:       DECLE   1, 1, 1, 1, 1   ; Color stack initialization

TITLE:      DECLE   108, "Tracker Demo", 0

;; ======================================================================== ;;
;;  MAIN                                                                    ;;
;; ======================================================================== ;;
MAIN        PROC

            MVII    #ISR,   R0      ; set our own ISR
            MVO     R0,     $100
            SWAP    R0
            MVO     R0,     $101

            EIS                     ; enable interrupts

            CALL    PRINT.FLS       ; overwrite title
            DECLE   7
            DECLE   $200 + 3*20 + 1
            DECLE   "Arnauld Chevallier", 0

            CALL    PRINT.FLS       ; overwrite copyright notice
            DECLE   7
            DECLE   $200 + 10*20 + 1
            DECLE   "   07 Sep. 2008   ", 0

            CALL    TRKINIT         ; initialize tracker

            CALL    TRKSNGINIT      ; initialize song
            DECLE   SONG00

@@spin      CALL    WAITVBL         ; wait for VBlank
            CALL    TRKPLAY         ; tick the player
            B       @@spin          ; spin forever

            ENDP

;; ======================================================================== ;;
;;  ISR           Simple ISR                                                ;;
;; ======================================================================== ;;
ISR         PROC

            MVO     R0,     $0020   ; hit $0020 to enable display

            MVI     FRAME,  R0      ; increment frame counter
            INCR    R0
            MVO     R0,     FRAME

            B       $1014           ; back into Exec

            ENDP

;; ======================================================================== ;;
;;  WAITVBL       Wait for next VBlank                                      ;;
;; ======================================================================== ;;
WAITVBL     PROC

            MVI     FRAME,  R0      ; R0 = current frame

@@wait      CMP     FRAME,  R0      ; wait for the next one
            BEQ     @@wait

            JR      R5

            ENDP

;; ======================================================================== ;;
;;  REQUIRED FILES                                                          ;;
;; ======================================================================== ;;
            INCLUDE "print.asm"
            INCLUDE "tracker.mac"
            INCLUDE "tracker.asm"
            INCLUDE "demosong.asm"

;; ======================================================================== ;;
;;  End of File:  trkdemo.asm                                               ;;
;; ======================================================================== ;;

demosong.asm

This is the data file which contains the short demo song used by trkdemo.asm (above). It includes 1 pitch effect, 2 software envelopes, 3 drums and 5 patterns. It's also using 2 vibrato levels.

;* ======================================================================== *;
;*  This code is placed into the public domain by its author.               *;
;*  All copyright rights are hereby relinquished on the code and data in    *;
;*  this file.  -- Arnauld Chevallier, 2008                                 *;
;* ======================================================================== *;

;; ======================================================================== ;;
;;  Global music definitions                                                ;;
;; ======================================================================== ;;
MUSIC       PROC

;; ------------------------------------------------------------------------ ;;
;;  Pitch effects                                                           ;;
;; ------------------------------------------------------------------------ ;;
@@pitch01   DECLE   0, 0, 0, 0
@@pitch02   DECLE   0, 0, 12, 12

;; ------------------------------------------------------------------------ ;;
;;  Envelopes                                                               ;;
;; ------------------------------------------------------------------------ ;;
@@env01     DECLE   2
            DECLE   $FEDC, $BA98, $7654, $3210
            DECLE   $0000, $0000, $0000, $0000
            DECLE   $0000, $0000, $0000, $0000
            DECLE   $0000, $0000, $0000, $0000

@@env02     DECLE   1
            DECLE   $FFFF, $EEEE, $DDDD, $CCCC
            DECLE   $BBBB, $AAAA, $9999, $8888
            DECLE   $7777, $6666, $5555, $4444
            DECLE   $3333, $2222, $1111, $0000

;; ------------------------------------------------------------------------ ;;
;;  Drums                                                                   ;;
;; ------------------------------------------------------------------------ ;;
@@drum1     DRUM($380, $10, 0, 1, $F)
            DRUM($380, $10, 1, 0, $F)
            DRUM($380, $10, 1, 0, $F)
            DRUM($580, $1F, 1, 0, $E)
            DRUM($580, $1F, 1, 1, $D)
            DRUM($580, $1F, 1, 1, $C)
            DRUM($580, $1F, 1, 0, $A)
            DRUM($580, $1F, 1, 0, $8)

@@drum2     DRUM($280, $10, 0, 1, $F)
            DRUM($280, $10, 1, 0, $F)
            DRUM($280, $10, 1, 0, $F)
            DRUM($480, $1F, 1, 0, $E)
            DRUM($480, $1F, 1, 1, $D)
            DRUM($480, $1F, 1, 1, $C)
            DRUM($480, $1F, 1, 0, $A)
            DRUM($480, $1F, 1, 0, $8)

@@hithat    DRUM($380, $04, 0, 1, $D)
            DRUM($380, $04, 0, 1, $6)
            DRUM(0, 0, 0, 0, 0)
            DRUM(0, 0, 0, 0, 0)
            DRUM(0, 0, 0, 0, 0)
            DRUM(0, 0, 0, 0, 0)
            DRUM(0, 0, 0, 0, 0)
            DRUM(0, 0, 0, 0, 0)

            ENDP

;; ======================================================================== ;;
;;  Song #00                                                                ;;
;; ======================================================================== ;;
SONG00      PROC

;; ------------------------------------------------------------------------ ;;
;;  Speed / Pointers                                                        ;;
;; ------------------------------------------------------------------------ ;;
            DECLE   6, @@patterns, @@instr

;; ------------------------------------------------------------------------ ;;
;;  Order of patterns                                                       ;;
;; ------------------------------------------------------------------------ ;;
            DECLE   0, 1, 2, 3, 0, 1, 2, 4, (-8 AND $FFFF)

;; ------------------------------------------------------------------------ ;;
;;  Details of patterns                                                     ;;
;; ------------------------------------------------------------------------ ;;
@@patterns  DECLE   32, @@p000, @@p001, @@p002
            DECLE   32, @@p000, @@p001, @@p003
            DECLE   32, @@p000, @@p001, @@p004
            DECLE   32, @@p000, @@p001, @@p005
            DECLE   32, @@p000, @@p001, @@p006

;; ------------------------------------------------------------------------ ;;
;;  Standard instruments (pitch effect, vibrato, envelope)                  ;;
;; ------------------------------------------------------------------------ ;;
@@instr     DECLE   MUSIC.pitch01, 1, MUSIC.env01
            DECLE   MUSIC.pitch01, 2, MUSIC.env02
            DECLE   MUSIC.pitch02, 2, MUSIC.env01
            DECLE   MUSIC.pitch01, 2, MUSIC.env01

;; ------------------------------------------------------------------------ ;;
;;  Drums                                                                   ;;
;; ------------------------------------------------------------------------ ;;
            DECLE   MUSIC.drum1
            DECLE   MUSIC.drum2
            DECLE   MUSIC.hithat

;; ------------------------------------------------------------------------ ;;
;;  Patterns                                                                ;;
;; ------------------------------------------------------------------------ ;;
@@p000      NOTES("DRM 1F0", "A-2 1F0", "DRM 3F0", "A-2 1F0")
            NOTES("DRM 2F0", "A-2 1F0", "DRM 3F0", "A-2 1F0")
            NOTES("DRM 1F0", "A-2 1F0", "DRM 1F0", "A-2 1F0")
            NOTES("DRM 2F0", "A-2 1F0", "DRM 3F0", "A-2 1F0")
            NOTES("DRM 1F0", "E-2 1F0", "DRM 3F0", "E-2 1F0")
            NOTES("DRM 2F0", "E-2 1F0", "DRM 3F0", "E-2 1F0")
            NOTES("DRM 1F0", "E-3 1F0", "DRM 1F0", "E-3 1F0")
            NOTES("DRM 2F0", "E-3 1F0", "DRM 2F0", "E-3 1F0")

@@p001      NOTES("A-3 2E3", "C-4 2E2", "E-4 2E0", "F-4 2E1")
            NOTES("E-4 2E1", "C-4 2E3", "A-3 2E3", "C-4 2E2")
            NOTES("E-4 2E0", "F-4 2E1", "A-4 2E1", "G-4 2E3")

@@p002      NOTES("A-5 3F7", "G-5 3F7", "E-5 3F7", "D-5 3F1")
            NOTES("E-5 3F5", "", "", "")

@@p003      NOTES("A-5 3F7", "G-5 3F7", "E-5 3F7", "F-5 3F1")
            NOTES("E-5 3F5", "", "", "")

@@p004      NOTES("A-5 4F3", "G-5 4F1", "A-5 4F1", "C-6 4F1")
            NOTES("B-5 4F2", "A-5 4F0", "G-5 4F1", "E-5 4F3")
            NOTES("D-5 4F1", "E-5 4F3", "A-5 4F1", "G-5 4F3")

@@p005      NOTES("A-5 4F3", "G-5 4F1", "A-5 4F1", "C-6 4F1")
            NOTES("B-5 4F3", "C-6 4F0", "D-6 4F0", "E-6 4F1")
            NOTES("C-6 4F1", "B-5 4F1", "G-5 4F1", "C-6 4F1")
            NOTES("A-5 4F1", "F-5 4F1", "G-5 4F1", "")

@@p006      NOTES("A-5 4F3", "G-5 4F1", "A-5 4F1", "C-6 4F1")
            NOTES("B-5 4F3", "C-6 4F0", "D-6 4F0", "E-6 4F0")
            NOTES("F-6 4F0", "E-6 4F1", "E-6 4F0", "F-6 4F0")
            NOTES("E-6 4F0", "D-6 4F0", "E-6 4F0", "D-6 4F0")
            NOTES("C-6 4F0", "B-5 4F0", "C-6 4F0", "B-5 4F0")
            NOTES("A-5 4F0", "G-5 4F0", "", "")

            ENDP

;; ======================================================================== ;;
;;  End of File:  demosong.asm                                              ;;
;; ======================================================================== ;;

Assembling

Assemble trkdemo.asm with the following command:

as1600 -o trkdemo -l trkdemo.lst trkdemo.asm
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox