sega16Thanks man, I will take a look on the thread you informed. My game is being programmed in assembly.
I`m glad you guys are enjoying my game!
@theloon
Yes, I tested it on real hardware using my Everdrive flashcart, and it works great, I loved how the graphics looked on a good old CRT tv
I`m not very good with bex, actually the only thing I ever performed was a "Hello World"
. But I see that you can put
assembly code on bex code, so I think the code I will post might work.
First, you need to download TFM Music maker 1x (very easy to find) on shiru`s site
Second, you must compile the z80 driver available in the directory replayers\smd\z80 using sjasm (please use version 39 since the most recent will not work with the code provided by Shiru), see the file compile.bat for refference
Then, you will have to include the z80drv.bin file in your game:
asm
DriverZ80: ;TLabel for beginning of driver
binclude "z80drv.bin"
DriverZ80end: ;Label to end of driver
asm end
After including the driver to your project, you must open a module on TFM maker, save as TFD, and convert it to TFC using tfmcom.exe that comes with TFM maker. After the convertion, you must include the music file in your game:
asm
GameBgm:
binclude "mymusic.tfc"
GameBgm_end:
asm end
Finally, you must include in your code the subroutine that copies the driver to z80 and plays the music.
asm
;===============================
; PlayMusic
; Loads z80 Driver into memory and plays a music
; original created by SHIRU
; Parameters:
; D0: Music source address (0 to stop music)
;
;
Playmusic:
move.w #$100,Z80_BUSREQ ;busreq on
move.w #$100,Z80_RESET ;reset off
lea $a01ffc,a0 ;#1ffc in Z80 RAM
move.b d0,(a0)+ ;write 4-byte addr in Z80 RAM
lsr.l #8,d0
move.b d0,(a0)+
lsr.l #8,d0
move.b d0,(a0)+
lsr.l #8,d0
move.b d0,(a0)+
lea DriverZ80,a0 ;copy Z80 driver to Z80 RAM
lea $a00000,a1
move.l #DriverZ80end,d0
move.l #DriverZ80,d1
sub.l d1,d0
copyLoop:
move.b (a0)+,(a1)+
subq.w #1,d0
bne copyLoop
move.w #$0,Z80_RESET ;reset on
move.w #$0,Z80_BUSREQ ;busreq off
move.w #$100,Z80_RESET ;reset off
rts
;===============================
end asm
Then, when you want to play the music:
asm
move.l #GameBgm, D0 ;Move the music start address to D0
bsr Playmusic
end asm
If you want to stop the music move #0 to D0 instead of an address. You can call this subroutine
always when you need to play other music.
Hope it helps, any doubt let me know