TESTGMC.ASM

EXAMPLE CODE

;*********************************************************************
;* Title: testgmc.asm
;*********************************************************************
;* Author: R. Allen Murphey
;*
;* Description: Support for John Linville's Game Master Cart
;*
;* Documentation:
;* $FF40 ROM Banks http://archive.org/stream/rainbowmagazine-1990-06
;* $FF41 DCSG http://en.wikipedia.org/wiki/Texas_Instruments_SN76489
;* At 4MHz, the DCSG needs 32 clocks between register writes
;* That means we need a delay of ~15 clocks per write at 1.789MHz
;* That means we need a delay of ~8 clocks per write at 0.894 MHz
;*
;* Include Files: none
;*
;* Assembler: lwasm 1.4.2
;* Example Build Instructions
;* >>> vi testgmc.asm
;* >>> lwasm -9 -p cd --list=testgmc.txt -o testgmc.bin testgmc.asm
;* >>> decb dskini TESTGMC.DSK
;* >>> decb copy testgmc.bin TESTGMC.DSK,TESTGMC.BIN -2
;* >>> mame coco3h -ramsize 2M -window -resolution 1920x1080 -skip_gameinfo -ext multi -ext:multi:slot1 games_master -ext:multi:slot4 fdcv11 -flop1 TESTGMC.DSK &
;*
;* Revision History:
;* Rev #     Date      Who     Comments
;* -----  -----------  ------  ---------------------------------------
;* 00     2020         RAM     Initial note table
;*********************************************************************

GMCPORTA:   equ   $FF40       ; GMC bank switching port
GMCPORTB:   equ   $FF41       ; GMC SN76489 port
           
            org   $7000
GMCTEST:                      ; SETUP
                              ; switch MPI to slot 0
            lda   $FF7F       ; Get current MPI setup
            anda  #$F0        ; Clear lower 4 SCS bits for slot 0
            sta   $FF7F       ; And switch the SCS slot number

                              ; SN76489 starts with all channels playing
            lda   #%10011111  ; 100% attenuation (volume off)
            sta   GMCPORTB    ; turn off volume
            bsr   WDELAY      ; write delay
            lda   #%10111111  ; 100% attenuation (volume off)
            sta   GMCPORTB    ; turn off volume
            bsr   WDELAY      ; write delay
            lda   #%11011111  ; 100% attenuation (volume off)
            sta   GMCPORTB    ; turn off volume
            bsr   WDELAY      ; write delay
            lda   #%11111111  ; 100% attenuation (volume off)
            sta   GMCPORTB    ; turn off volume
            bsr   WDELAY      ; write delay

                              ; enable CART sound on MUX
            lda   #$34        ; MUX SEL 1
            sta   $FF01       ; MUX Select Lo
            lda   #$3F        ; MUX SEL 2
            sta   $FF03       ; MUX Select Hi
            lda   #$38        ; Enable SNDEN
            sta   $FF23       ; SNDEN

                              ; MAIN
            clrb
            ldy   #GMCNOTES
PLAYGMC:
            lda   b,y         ; load lower 4 bits of note
            ora   #%10000000  ; add latch bit
            sta   GMCPORTB    ; write to GMC register
            bsr   WDELAY      ; write delay
            incb              ; move to next value
            lda   b,y         ; load it from table
            anda  #$3F        ; form GMC data message with six bits
            sta   GMCPORTB    ; write the upper six bits of note
            bsr   WDELAY      ; write delay
            lda   #%10010000  ; 0% attention (volume full)
            sta   GMCPORTB    ; write attenuation message to GMC
            bsr   BDELAY      ; big delay while note sounds
            incb              ; move to next item in table
            cmpb  #24         ; have we read all 12 x 10bit notes?
            bne   PLAYGMC     ; no keep playing notes
                              
                              ; TEARDOWN
            lda   #%10011111  ; 100% attenuation (volume off)
            sta   GMCPORTB    ; turn off volume
            bsr   WDELAY      ; write delay
            lda   #%10000000  ; empty note register upper 6 bits
            sta   GMCPORTB    ; write it
            bsr   WDELAY      ; write delay
            lda   #%00000000  ; empty note register lower 4 bits
            sta   GMCPORTB    ; write that too
            rts

BDELAY:
            ldx   #$4000
            bra   WDELAY2
WDELAY:
            ldx   #$08
WDELAY2:
            leax  -1,X
            bne   WDELAY2
            rts

GMCNOTES:                     ; Tone Periods at 4MHz clock
            fcb   $0D,$1D     ; C4  261.626 Hz Middle C
            fcb   $02,$1C     ; C#4 277.183 Hz
            fcb   $09,$1A     ; D4  293.665 Hz
            fcb   $01,$19     ; D#4 311.127 Hz
            fcb   $0B,$17     ; E4  329.628 Hz
            fcb   $05,$16     ; F4  349.228 Hz
            fcb   $01,$15     ; F#4 369.994 Hz
            fcb   $0E,$13     ; G4  391.995 Hz
            fcb   $0C,$12     ; G#4 415.305 Hz
            fcb   $0C,$11     ; A4  440.000 Hz
            fcb   $0C,$10     ; A#4 466.164 Hz
            fcb   $0D,$0F     ; B4  493.883 Hz

            END   GMCTEST

;*********************************************************************
;* End of testgmc.asm
;*********************************************************************

RTS

This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website.More information about cookies