Skip to content

Commit

Permalink
Merge pull request #47 from jsmolina/feature/alvin_is_great
Browse files Browse the repository at this point in the history
make ay play in 128k (alvin is great!)
  • Loading branch information
jsmolina authored Nov 25, 2018
2 parents 1bf854e + f8de0c4 commit 9b4229d
Show file tree
Hide file tree
Showing 24 changed files with 3,209 additions and 156 deletions.
18 changes: 15 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
VT_SOUND_LIB_SDCC_IY := ./ay

compile:
zcc +zx --opt-code-size -v -startup=31 -DWFRAMES=3 -clib=sdcc_iy -Cz--screen=screen.scr -SO3 --max-allocs-per-node200000 @zproject.lst -pragma-include:zpragma.inc -o misifu -L$(VT_SOUND_LIB_SDCC_IY) -lvt_sound -create-app
echo "Done"
zcc +zx -v -m -startup=31 -clib=sdcc_iy -SO3 --max-allocs-per-node200000 @zproject.lst -pragma-include:zpragma.inc -o misifu -lay/vt_sound_6.lib
ls *.bin
appmake +zx -b screen.scr --org 16384 --noloader --blockname screen -o screen.tap
appmake +zx -b misifu_CODE.bin --org 24500 --noloader --blockname code -o code.tap
appmake +zx -b misifu_BANK_6.bin --org 49152 --noloader --blockname bank6 -o bank6.tap
rm misifu.tap
cat loader.tap screen.tap code.tap bank6.tap > misifu.tap
echo "Done!"

develop:
zcc +zx --opt-code-size -v -clib=sdcc_iy -Cz--screen=screen.scr -startup=31 -DWFRAMES=3 -O3 @zproject.lst -o misifu -pragma-include:zpragma.inc -L$(VT_SOUND_LIB_SDCC_IY) -lvt_sound -create-app
zcc +zx -v -m -startup=31 -clib=sdcc_iy -O3 --max-allocs-per-node200000 @zproject.lst -pragma-include:zpragma.inc -o misifu -lay/vt_sound_6.lib
ls *.bin
appmake +zx -b screen.scr --org 16384 --noloader --blockname screen -o screen.tap
appmake +zx -b misifu_CODE.bin --org 24500 --noloader --blockname code -o code.tap
appmake +zx -b misifu_BANK_6.bin --org 49152 --noloader --blockname bank6 -o bank6.tap
rm misifu.tap
cat loader.tap screen.tap code.tap bank6.tap > misifu.tap
echo "Done"

sprites: prota dogsprites bincat clothes auxiliar
Expand Down
Empty file modified ay/alley_cat.pt3
100644 → 100755
Empty file.
4 changes: 2 additions & 2 deletions ay/ay.lst
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
misifu_ay
ay_music.c
misifu_ay
ay_music
67 changes: 67 additions & 0 deletions ay/ay_music.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
; void ay_vt_init(const void *module_address) __z88dk_fastcall

SECTION code_crt_common

PUBLIC _ay_vt_init

EXTERN VT_INIT
EXTERN asm_z80_push_di, asm0_z80_pop_ei
EXTERN enable_bank_n, restore_bank_0

_ay_vt_init:

call asm_z80_push_di
push ix
push iy

ld a,0x80
ld i,a ; point I at uncontended bank

ex de,hl ; de = module address
ld a,6
call enable_bank_n ; bank 6 in top 16k, stack moved
ex de,hl ; hl = module address
call VT_INIT
call restore_bank_0 ; bank 0 in top 16k, stack restored

ld a,0xd0
ld i,a ; restore I

pop iy
pop ix
jp asm0_z80_pop_ei


; void ay_vt_mute(void)

SECTION code_crt_common

PUBLIC _ay_vt_mute

EXTERN VT_MUTE
EXTERN asm_z80_push_di, asm0_z80_pop_ei
EXTERN enable_bank_n, restore_bank_0

_ay_vt_mute:

call asm_z80_push_di

ld a,0x80
ld i,a ; point I at uncontended bank

ld a,6
call enable_bank_n ; bank 6 in top 16k, stack moved
call VT_MUTE
call restore_bank_0 ; bank 0 in top 16k, stack restored

ld a,0xd0
ld i,a ; restore I

jp asm0_z80_pop_ei
11 changes: 0 additions & 11 deletions ay/ay_music.c

This file was deleted.

20 changes: 9 additions & 11 deletions ay/ay_music.h
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
#ifndef _AY_MUSIC
#define _AY_MUSIC


#include "vt_sound.h"

extern void initialize_ay();

extern void keep_playing();

#endif
#ifndef _AY_MUSIC
#define _AY_MUSIC

extern unsigned char music_module[];

extern void ay_vt_init(const void *module_address) __z88dk_fastcall;
extern void ay_vt_mute(void);

#endif
12 changes: 6 additions & 6 deletions ay/misifu_ay.asm
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
SECTION rodata_user

PUBLIC _music_module

_music_module:
BINARY "alley_cat.pt3"
SECTION BANK_6

PUBLIC _music_module

_music_module:
BINARY "alley_cat.pt3"
9 changes: 9 additions & 0 deletions ay/readme.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
The vt_sound library places code and data into sections "code_user" and "data_user".

We'd like to move that to "BANK_6" so that AY code exists in a separate memory bank.
This is done by getting zobjcopy to rename the sections in the "vt_sound.lib" file.

zobjcopy vt_sound.lib --section code_user=BANK_6 --section data_user=BANK_6 --global "VT_INIT" --global "VT_MUTE" --global "_vt_play" --global "_vt_play_isr_enabled" vt_sound_6.lib

Linking the program against "vt_sound_6.lib" will now place all AY-related code into
BANK_6.
166 changes: 83 additions & 83 deletions ay/vt_sound.h
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,83 +1,83 @@
/*******************************************************************************
* Stefan Bylund 2016
*
* C API for calling the Vortex Tracker II (VT) player in PT3PROM.asm.
* The VT player supports playing of Pro Tracker 3.x (PT3) modules.
*
* The module(s) to be played is created in the following way:
*
* 1. If the module is a PT3 module, it can be played directly by the VT player.
* 2. If the module is not a PT3 module but a module in another format supported
* by Vortex Tracker II, open the module in Vortex Tracker II and save it as
* a PT3 module.
* 3. Create an assembler source file for loading the PT3 module(s).
* Define a read-only data section and load the PT3 module(s) using the
* BINARY directive. Associate each PT3 module with a public label starting
* with an underscore, e.g. _music_module.
*
* How to use:
*
* 1. Make the PT3 module(s) available to your C program by declaring external
* references to their public labels (but without the leading underscore) as
* created in step 3 above, e.g. "extern uint8_t music_module[];".
* 2. Call vt_init(<module_address>) to initialize the VT player with the
* specified module.
* 3. Call vt_play() each 1/50 second or install the vt_play_isr() function as
* an IM2 interrupt service routine. The module will now start playing in the
* background.
******************************************************************************/

#ifndef _VT_SOUND_H
#define _VT_SOUND_H

#include <stdint.h>

/*
* Returns a pointer to the VT player's setup byte.
* Set bit 0 to disable looping; bit 7 is set after each loop.
*/
extern uint8_t *vt_get_setup(void);

/*
* Initializes the VT player with the specified module.
*
* If this function is called during playing of the module, it mutes the sound
* and reinitializes the VT player with the specified module to be played from
* its beginning.
*/
extern void vt_init(const void *module_address) __z88dk_fastcall;

/*
* Plays one snippet of the module. Call this function each 1/50 second to play
* the module continuously, e.g. from your interrupt service routine.
*/
extern void vt_play(void);

/*
* This function is tailored for installation as a self-contained IM2 interrupt
* service routine to play the module in the background.
*/
extern void vt_play_isr(void);

/*
* Enables (enabled = 1) or disables (enabled = 0) the vt_play_isr() interrupt
* service routine. The vt_play_isr() interrupt service routine is initially
* enabled.
*/
extern void vt_set_play_isr_enabled(int enabled) __z88dk_fastcall;

/*
* Mutes the sound. Call vt_play() to continue playing again.
*
* If the vt_play_isr() interrupt service routine is used, call
* vt_set_play_isr_enabled(0) before calling vt_mute() to mute the sound.
* Call vt_set_play_isr_enabled(1) to continue playing again.
*/
extern void vt_mute(void);

/*
* Returns a pointer to the VT player's current position pointer word.
*/
extern uint16_t *vt_get_cur_pos(void);

#endif
/*******************************************************************************
* Stefan Bylund 2016
*
* C API for calling the Vortex Tracker II (VT) player in PT3PROM.asm.
* The VT player supports playing of Pro Tracker 3.x (PT3) modules.
*
* The module(s) to be played is created in the following way:
*
* 1. If the module is a PT3 module, it can be played directly by the VT player.
* 2. If the module is not a PT3 module but a module in another format supported
* by Vortex Tracker II, open the module in Vortex Tracker II and save it as
* a PT3 module.
* 3. Create an assembler source file for loading the PT3 module(s).
* Define a read-only data section and load the PT3 module(s) using the
* BINARY directive. Associate each PT3 module with a public label starting
* with an underscore, e.g. _music_module.
*
* How to use:
*
* 1. Make the PT3 module(s) available to your C program by declaring external
* references to their public labels (but without the leading underscore) as
* created in step 3 above, e.g. "extern uint8_t music_module[];".
* 2. Call vt_init(<module_address>) to initialize the VT player with the
* specified module.
* 3. Call vt_play() each 1/50 second or install the vt_play_isr() function as
* an IM2 interrupt service routine. The module will now start playing in the
* background.
******************************************************************************/

#ifndef _VT_SOUND_H
#define _VT_SOUND_H

#include <stdint.h>

/*
* Returns a pointer to the VT player's setup byte.
* Set bit 0 to disable looping; bit 7 is set after each loop.
*/
extern uint8_t *vt_get_setup(void);

/*
* Initializes the VT player with the specified module.
*
* If this function is called during playing of the module, it mutes the sound
* and reinitializes the VT player with the specified module to be played from
* its beginning.
*/
extern void vt_init(const void *module_address) __z88dk_fastcall;

/*
* Plays one snippet of the module. Call this function each 1/50 second to play
* the module continuously, e.g. from your interrupt service routine.
*/
extern void vt_play(void);

/*
* This function is tailored for installation as a self-contained IM2 interrupt
* service routine to play the module in the background.
*/
extern void vt_play_isr(void);

/*
* Enables (enabled = 1) or disables (enabled = 0) the vt_play_isr() interrupt
* service routine. The vt_play_isr() interrupt service routine is initially
* enabled.
*/
extern void vt_set_play_isr_enabled(int enabled) __z88dk_fastcall;

/*
* Mutes the sound. Call vt_play() to continue playing again.
*
* If the vt_play_isr() interrupt service routine is used, call
* vt_set_play_isr_enabled(0) before calling vt_mute() to mute the sound.
* Call vt_set_play_isr_enabled(1) to continue playing again.
*/
extern void vt_mute(void);

/*
* Returns a pointer to the VT player's current position pointer word.
*/
extern uint16_t *vt_get_cur_pos(void);

#endif
Empty file modified ay/vt_sound.lib
100644 → 100755
Empty file.
Binary file added ay/vt_sound_6.lib
Binary file not shown.
Binary file added bas2tap
Binary file not shown.
Binary file added bas2tap.exe
Binary file not shown.
9 changes: 4 additions & 5 deletions defines.c
Original file line number Diff line number Diff line change
Expand Up @@ -334,11 +334,10 @@ void print_room_walls(uint8_t paper_color) {

}

void page(uint8_t bank) {
GLOBAL_ZX_PORT_7FFD = 0x10+bank;
IO_7FFD = 0x10 + bank;
}

// void page(uint8_t bank) {
// GLOBAL_ZX_PORT_7FFD = 0x10+bank;
// IO_7FFD = 0x10 + bank;
// }

void check_keys()
{
Expand Down
2 changes: 1 addition & 1 deletion defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ extern void loose_a_live();
extern void reset_misifu_position();

// reference: https://github.com/z88dk/z88dk/blob/master/include/_DEVELOPMENT/sdcc/arch/zx/sp1.h#L83
extern void page(uint8_t bank);
// extern void page(uint8_t bank);

extern void check_keys();

Expand Down
Loading

0 comments on commit 9b4229d

Please sign in to comment.