Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- DECLARE SUB EchoInit ' ECHO INITALIZATION
- EchoZ80Reset ' Reset Z80
- EchoZ80request ' Request Z80 Bus
- POKE &hA01FFF, 1 ' Write init command number so that this is the first command executed by echo
- reload VoiceList ' Instrument Pointer List gets loaded
- EchoWriteAdressParam ' Write the address of the pointer list to Z80 memory
- i=0 ' i = amount of bytes written
- reload Z80ProgEnd ' Load the end of the driver binary into Dataptr&()
- a& = dataptr&() ' Use that as an ending marker for the transfer operation
- reload Z80Prog ' Load the adress of the Z80 driver
- WHILE dataptr&() < a& ' (LOOP) Copy the driver into the start of Z80 memory
- READ byt ' Read next byte of the binary
- POKE 10485760+i, byt ' Write it to Z80 memory
- i=i+1 ' increase counter
- WEND ' Do this until the full binary is loaded
- EchoZ80Reset ' Reset Z80
- EchoZ80Release ' Release Z80 Bus
- END SUB
- ' SUB: ECHOGETSTATUS
- '
- ' Returns the status of Echo (see docs for that)
- DECLARE FUNCTION EchoGetStatus AS INTEGER
- EchoZ80Request
- RETURN PEEK(&hA01FF0)
- EchoZ80Release
- END FUNCTION
- ' SUB: ECHOZ80REQUEST
- '
- ' Requests the Z80 Bus
- DECLARE SUB EchoZ80Request
- pokeint &hA11100,&h0100 ' Request Z80 Bus
- END SUB
- ' SUB: ECHOZ80RELEASE
- '
- ' Releases the Z80 Bus
- DECLARE SUB EchoZ80Release
- pokeint &hA11100,&h0000 ' Release Z80 Bus
- END SUB
- DECLARE SUB EchoZ80Reset
- pokeint &hA11200,&h0000 ' Assert reset line
- asm ' These nops make the 68k wait until the Z80 is operational
- nop ; before releasing its RESET LINE
- nop
- nop
- nop
- nop
- nop
- nop
- nop
- nop
- nop
- END asm
- pokeint &hA11200,&h0100 ' Release reset line
- END SUB
- ' SUB: ECHOSENDCOMMAND
- '
- ' Sends a command to Echo
- DECLARE SUB EchoSendCommand(Command AS INTEGER)
- EchoZ80Request
- WHILE PEEK(&hA01FFF) > 0
- EchoZ80Release ' If Echo is not ready, let it continue for a while
- f = &hFF
- WHILE f > 0
- f--
- WEND
- EchoZ80Request
- WEND
- POKE &hA01FFF, Command
- EchoZ80Release
- END SUB
- ' SUB: ECHOSENDCOMMANDEX
- '
- ' Sends a command with an adress parameter to Echo
- DECLARE SUB EchoSendCommandEx(Command AS INTEGER)
- EchoSendCommand Command
- EchoZ80Request
- EchoWriteAdressParam
- EchoZ80Release
- END SUB
- ' SUB: ECHOWRITEADRESSPARAM
- '
- ' Writes an adress parameter for a command into Z80 RAM
- DECLARE SUB EchoWriteAdressParam
- regmove.l 0, d1 ' Clear d1 register of the 68K
- ParamAdress& = dataptr&() ' Get adress from DataPtr&()
- regmove.l ParamAdress&, d0 ' Move the adress into d0 register
- asm ' Because this is complicated, we will use assembly for this
- clr.l d1
- move.b d0, ($A01FFD)
- lsr.l #7, d0
- lsr.b #1, d0
- bset.l #7, d0
- move.b d0, ($A01FFE)
- lsr.w #8, d0
- move.w d0, d1
- lsr.w #1, d1
- AND.b #$7F, d0
- AND.b #$80, d1
- OR.b d1, d0
- move.b d0, ($A01FFC)
- END asm
- END SUB
- ' SUB: ECHO COMMANDS
- '
- ' See their comment for information on what they actually do
- DECLARE SUB EchoPlayBGM ' Tells Echo to play the BGM
- EchoSendCommandEx 4
- END SUB
- DECLARE SUB EchoStopBGM ' Tells Echo to stop the BGM
- EchoSendCommand 5
- END SUB
- DECLARE SUB EchoPlaySFX ' Tells Echo to play the SFX
- EchoSendCommandEx 2
- END SUB
- DECLARE SUB EchoStopSFX ' Tells Echo to stop the SFX
- EchoSendCommand 3
- END SUB
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement