Compare commits

...
Sign in to create a new pull request.

11 commits

23 changed files with 30237 additions and 0 deletions

456
audioplayer/player.c Normal file
View file

@ -0,0 +1,456 @@
/*
* JoeyLib Based Example Audio Player
* Copyright (C) 2020 Scott Duensing <scott@kangaroopunch.com>
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*/
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#include <assert.h>
#define JOEY_MAIN
#include "joey.h"
#ifdef JOEY_IIGS
segment "audioapp";
#endif
#ifdef DMALLOC
#define DMALLOC_FUNC_CHECK
#include "dmalloc.h"
#endif
void help(jlSurfaceT source, jlStnT *stencil, jint16 sx, jint16 sy, jint16 tx, jint16 ty) {
int mo; // Mask offset
int x;
int y;
byte b; // Mask bit index
printf("\n");
mo = ((sy & 0x1f) * 8 * 40) + (sx & 0x3f); // This is in tiles
printf("Offset: %04x sx: %02x sy: %02x\n", mo, sx, sy);
for (y=0; y<8; y++) {
b = 7;
printf("Byte: %02x ", stencil->pixels[mo]);
for (x=0; x<4; x++) {
if ((stencil->pixels[mo] & (1 << b--)) != 0) {
printf("X");
} else {
printf(".");
}
if ((stencil->pixels[mo] & (1 << b--)) != 0) {
printf("X");
} else {
printf(".");
}
}
mo += 40;
printf("\n");
}
jlDrawBlit8x8a(source, stencil, sx, sy, tx, ty);
}
// Font hacking!
__attribute__((__format__ (__printf__, 5, 0)))
void fontPrint(jlImgT *font, jlStnT *stencil, jint16 cx, jint16 cy, const char *what, ...) {
jint16 x;
jint16 y;
jint16 tx;
jint16 ty;
jint16 counter;
char msg[40]; // Very short messages (screen width). Be careful!
va_list va;
va_start(va, what);
vsprintf(msg, what, va);
va_end(va);
tx = cx * 8;
ty = cy * 8;
for (counter=0; counter<(int)strlen(msg); counter++) {
x = (msg[counter] % 40) * 8;
y = (msg[counter] / 40) * 8;
if (stencil) {
#ifdef JOEY_PC
help(jlImgSurfaceGet(font), stencil, x, y, tx, ty);
#else
jlDrawBlit8x8a(jlImgSurfaceGet(font), stencil, x, y, tx, ty);
#endif
} else {
jlDrawBlit8x8(jlImgSurfaceGet(font), x, y, tx, ty);
}
tx += 8;
}
}
void blitTest(void) {
jlImgT *font = NULL;
jlStnT *stencil = NULL;
jint16 y;
jint16 x;
if (!jlImgLoad(font, "font")) jlUtilDie("Unable to load font.img!");
if (!jlStnLoad(stencil, "font")) jlUtilDie("Unable to load font.stn!");
jlImgDisplay(font);
jlDisplayPresent();
jlKeyWaitForAny();
jlDrawColorSet(1);
jlDrawClear();
jlPaletteSet(15, 15, 15, 15);
fontPrint(font, NULL, 1, 2, "%s", "Blitting without stencil buffer.");
fontPrint(font, stencil, 1, 4, "%s", "Blitting with stencil buffer.");
jlDisplayPresent();
jlKeyWaitForAny();
y = 91;
while (!jlKeyPressed()) {
for (x=0; x<319-8; x++) {
jlDrawBlit8x8(jlImgSurfaceGet(font), 8, 0, x, y);
fontPrint(font, NULL, 1, 6, "Drawing at %d x %d ", x, y);
jlDisplayPresent();
jlDrawBlit8x8(jlImgSurfaceGet(font), 0, 0, x, y);
jlUtilSleep(1);
if (jlKeyPressed()) {
break;
}
}
}
jlKeyRead();
jlStnFree(stencil);
jlImgFree(font);
}
void exerciseAPI(void) {
jlImgT *screen = NULL;
jlDrawColorSet(0);
jlDrawClear();
jlDrawColorSet(15);
jlDrawPixelSet(10, 10);
assert(jlDrawPixelGet(10, 10) == 15);
// Should be able to grab the screen twice without allocation issues.
jlImgCreate(screen);
jlImgCreate(screen);
jlImgFree(screen);
}
void grid(void) {
int i;
jlDrawColorSet(0);
jlDrawClear();
jlDrawColorSet(15);
for (i=0; i<320; i+=8) {
jlDrawLine(i, 0, i, 199);
}
for (i=0; i<200; i+=8) {
jlDrawLine(0, i, 319, i);
}
while (!jlKeyPressed()) {
jlDisplayPresent();
}
jlKeyRead();
}
void lineTest(void) {
jlImgT *kanga = NULL;
jlImgT *font = NULL;
jint16 y;
jint16 phase = 0;
jint16 x2 = 0;
jint16 y2 = 0;
jint16 ox = 0;
jint16 oy = 0;
jint16 op = 0;
jint16 color = 15;
jint16 nextColor = 1;
char what[32];
if (!jlImgLoad(kanga, "kanga")) jlUtilDie("Unable to load kanga.img!");
if (!jlImgLoad(font, "font")) jlUtilDie("Unable to load font.img!");
jlImgDisplay(kanga);
jlDrawColorSet(1);
jlDrawBox(0, 0, 319, 199);
//jlSoundMusicPlay("music");
jlPaletteSet(15, 15, 15, 15);
strcpy(what, "Left to Right");
while (!jlKeyPressed()) {
y = 17;
fontPrint(font, NULL, 1, y++, "Drawing %s ", what);
jlDrawColorSet((byte)color);
if (phase < 2) {
jlDrawLine(x2, y2, 319-x2, 199-y2);
} else {
jlDrawLine(319-x2, 199-y2, x2, y2);
}
ox = x2;
oy = y2;
op = phase;
switch (phase) {
// Left, Y incrementing
case 0:
y2++;
if (y2 == 199) {
strcpy(what, "Bottom to Top");
phase = 1;
}
break;
// Bottom, X incrementing
case 1:
x2++;
if (x2 == 319) {
strcpy(what, "Right to Left");
phase = 2;
}
break;
// Right, Y decrementing
case 2:
y2--;
if (y2 == 0) {
strcpy(what, "Top to Bottom");
phase = 3;
}
break;
// Top, X decrementing
case 3:
x2--;
if (x2 == 0) {
strcpy(what, "Left to Right");
phase = 0;
}
break;
}
jlDisplayPresent();
jlDrawColorSet((byte)0);
if (op < 2) {
jlDrawLine(ox, oy, 319-ox, 199-oy);
} else {
jlDrawLine(319-ox, 199-oy, ox, oy);
}
color = nextColor;
nextColor++;
if (nextColor > 15) {
nextColor = 1;
}
}
jlKeyRead();
jlImgFree(font);
jlImgFree(kanga);
}
void musicTest(void) {
jlImgT *kanga = NULL;
jlImgT *font = NULL;
if (!jlImgLoad(kanga, "kanga")) jlUtilDie("Unable to load kanga.img!");
if (!jlImgLoad(font, "font")) jlUtilDie("Unable to load font.img!");
jlImgDisplay(kanga);
jlDisplayPresent();
jlSoundModPlay("music");
while (!jlKeyPressed()) {
fontPrint(font, NULL, 1, 1, "%dx%d %d %d ", jlGameGetAxis(0), jlGameGetAxis(1), jlGameGetButton(0), jlGameGetButton(1));
jlDisplayPresent();
}
jlKeyRead();
jlSoundModStop();
jlImgFree(font);
jlImgFree(kanga);
}
void showStencil(void) {
jlStnT *stencil = NULL;
jint16 y;
jint16 x;
jint16 count;
juint16 index;
byte bit;
if (!jlStnLoad(stencil, "font")) jlUtilDie("Unable to load font.stn!");
jlDrawColorSet(0);
jlDrawClear();
jlDrawColorSet(15);
// Draw stencil to screen linerally
index = -1;
count = 0;
for (y=0; y<200; y++) {
for (x=0; x<320; x++) {
count--;
if (count < 0) {
count = 7;
index++;
bit = stencil->pixels[index];
}
if (bit & (1 << count)) {
jlDrawPixelSet(x, y);
}
}
jlDisplayPresent();
}
jlKeyWaitForAny();
jlDrawColorSet(0);
jlDrawClear();
jlDrawColorSet(15);
// Draw stencil by pixel location - this fails on the IIgs
for (y=0; y<200; y++) {
for (x=0; x<320; x++) {
index = (y * 320 + x);
count = 7 - (index % 8);
index /= 8;
bit = stencil->pixels[index];
if (bit & (1 << count)) {
jlDrawPixelSet(x, y);
}
}
jlDisplayPresent();
}
jlKeyWaitForAny();
}
void stencilTest(void) {
jlImgT *kangaI = NULL;
jlImgT *biffI = NULL;
jlStnT *biffS = NULL;
jint16 y;
jint16 x;
jint16 i;
jint16 j;
if (!jlImgLoad(kangaI, "kanga")) jlUtilDie("Unable to load kanga.img!");
if (!jlImgLoad(biffI, "biff")) jlUtilDie("Unable to load biff.img!");
if (!jlStnLoad(biffS, "biff")) jlUtilDie("Unable to load biff.stn!");
jlImgDisplay(kangaI);
y = 50;
while (!jlKeyPressed()) {
// Draw Biff & grab background
for (x=0; x<319-32; x++) {
for (i=0; i<3; i++) {
for (j=0; j<4; j++) {
jlDrawSurfaceSet(jlImgSurfaceGet(biffI));
jlDrawBlit8x8(JOEY_DISPLAY, x + (j * 8), y + (i * 8), j * 8 + 32, i * 8 + 32);
jlDrawSurfaceSet(JOEY_DISPLAY);
jlDrawBlit8x8a(jlImgSurfaceGet(biffI), biffS, j * 8, i * 8, x + (j * 8), y + (i * 8));
}
}
jlDisplayPresent();
// Erase Biff
for (i=0; i<3; i++) {
for (j=0; j<4; j++) {
jlDrawBlit8x8(jlImgSurfaceGet(biffI), j * 8 + 32, i * 8 + 32, x + (j * 8), y + (i * 8));
}
}
// Check for early quit
if (jlKeyPressed()) {
break;
}
}
}
jlKeyRead();
jlStnFree(biffS);
jlImgFree(biffI);
jlImgFree(kangaI);
}
void timerTest(void) {
jlImgT *font = NULL;
if (!jlImgLoad(font, "font")) jlUtilDie("Unable to load font.img!");
jlDrawColorSet(0);
jlDrawClear();
while (!jlKeyPressed()) {
fontPrint(font, NULL, 1, 1, "Timer: %d ", jlUtilTimer());
jlDisplayPresent();
}
jlKeyRead();
jlImgFree(font);
}
int main(void) {
jlUtilStartup("JoeyLib Audio");
//blitTest();
//exerciseAPI();
//grid();
//lineTest();
//musicTest();
//showStencil();
stencilTest();
//timerTest();
jlUtilShutdown();
}

View file

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

View file

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 17 KiB

BIN
joeylib/data/font.xcf (Stored with Git LFS) Normal file

Binary file not shown.

BIN
joeylib/data/kanga.xcf (Stored with Git LFS) Normal file

Binary file not shown.

BIN
joeylib/data/music.mod (Stored with Git LFS) Normal file

Binary file not shown.

Binary file not shown.

29445
joeylib/src/iigs/blit.asm Normal file

File diff suppressed because it is too large Load diff

101
joeylib/src/iigs/song.c Normal file
View file

@ -0,0 +1,101 @@
/*
JoeyLib NTP Player
*/
#include "song.h"
/*
jlSongT - A pointer to single song, including its instruments
*/
typedef struct
{
} jlSong_t;
typedef jlSong_t* jlSongT;
/*
Startup Song Library
*/
void jlSongStartup()
{
}
/*
Shutdown Song Library
*/
void jlSongShutdown()
{
}
/*
jlSongLoad - Loads a song into memory, and into DOC RAM, so that it's ready
to play
*/
jlSongT jlSongLoad(const char* pSongPath)
{
jlSongT result = NULL;
return result;
}
/*
jlSongLoadAt - Load a song from memory into DOC RAM
DO NOT FREE THIS MEMORY UNTIL AFTER A CALL TO jlSongFree
*/
jlSongT jlSongLoadAt(const char* pSongInRAM)
{
jlSongT result = NULL;
return result;
}
/*
jlSongPlay
jlSongT song - song handle
jlBool bLoop - Play once, or Loop continuously
*/
void jlSongPlay(jlSongT song, jlBool bLoop)
{
}
/*
Stop the current song
*/
void jlSongStop(jlSongT song)
{
}
/*
bPaused to TRUE to pause the song
bPaused to FALSE to result song from where it is
*/
void jlSongSetPause(jlSongT song, jlBool bPaused)
{
}
/*
Volume from 0 which is silent, to 255 which is the loudest
*/
void jlSongSetVolume(jlSongT song, U8 volume)
{
}
/*
// 0x100 is a tempo of 1x, and is the default
// 0x080 will run the tempo at half speed
// 0x200 will run the tempo at 2X
*/
void jlSongSetTempo(jlSongT song, U16 tempo)
{
}
/*
Release memory and resources
*/
void jlSongFree(jlSontT song)
{
}
#endif /* JL_SONG_H */

78
joeylib/src/iigs/song.h Normal file
View file

@ -0,0 +1,78 @@
/*
JoeyLib NTP Player
*/
#ifndef JL_SONG_H
#define JL_SONG_H 1
#endif
/*
jlSongT - A pointer to single song, including its instruments
*/
typedef struct
{
} jlSong_t;
typedef jlSong_t* jlSongT;
/*
Startup Song Library
*/
void jlSongStartup();
/*
Shutdown Song Library
*/
void jlSongShutdown();
/*
jlSongLoad - Loads a song into memory, and into DOC RAM, so that it's ready
to play
*/
jlSongT jlSongLoad(const char* pSongPath);
/*
jlSongLoadAt - Load a song from memory into DOC RAM
DO NOT FREE THIS MEMORY UNTIL AFTER A CALL TO jlSongFree
*/
jlSongT jlSongLoadAt(const char* pSongInRAM);
/*
jlSongPlay
jlSongT song - song handle
jlBool bLoop - Play once, or Loop continuously
*/
void jlSongPlay(jlSongT song, jlBool bLoop);
/*
Stop the current song
*/
void jlSongStop(jlSongT song);
/*
bPaused to TRUE to pause the song
bPaused to FALSE to result song from where it is
*/
void jlSongSetPause(jlSongT song, jlBool bPaused);
/*
Volume from 0 which is silent, to 255 which is the loudest
*/
void jlSongSetVolume(jlSongT song, U8 volume);
/*
// 0x100 is a tempo of 1x, and is the default
// 0x080 will run the tempo at half speed
// 0x200 will run the tempo at 2X
*/
void jlSongSetTempo(jlSongT song, U16 tempo);
/*
Release memory and resources
*/
void jlSongFree(jlSontT song);
#endif /* JL_SONG_H */

91
joeylib/src/iigs/sound.c Normal file
View file

@ -0,0 +1,91 @@
/*
JoeyLib Sound for the IIgs
*/
#include "sound.h"
#ifndef NULL
#define NULL 0
#endif
/* Call this before any other Sound Function */
void jlSoundStartup()
{
}
/* Call this when done, for proper shutdown */
void jlSoundShutdown()
{
}
/*
Load .jla Sound Bank into memory, or into DOC RAM
*/
jlSoundT jlSoundLoad(const char* pSoundBankPath)
{
jlSoundT result = NULL;
return result;
}
/*
Load .jla Sound Bank from memory, into DOC RAM
DO NOT FREE THIS MEMORY (pointers in the library will point into it)
it may be free after the jlSoundFree hsa been called
*/
jlSoundT jlSoundLoadAt(const char* pBankInRAM)
{
jlSoundT result = NULL;
return result;
}
/*
Returns back an index into the audio definition table, which is required
in order to call jlSoundPlay
Returns -1 if the sound isn't found
*/
signed short jlSoundFind(jlSoundT soundbank, const char* sfxName)
{
signed short result = -1;
return result;
}
/*
Play a Sound
*/
void jlSoundPlay(jlSoundT soundbank, signed short audio_index)
{
}
/*
Return the number of SFX in this Bank
*/
signed short jlSoundGetNumSFX(jlSoundT soundbank)
{
signed short result = 0;
return result;
}
/*
Return a C string name of the sound effect with this index
DO NOT FREE THIS POINTER
*/
char *jlSoundGetName(signed short audio_index)
{
char* pResult = NULL;
return pResult;
}
/*
Called when you are done with this soundbank
*/
void jlSoundFree(jlSoundT soundbank)
{
}

56
joeylib/src/iigs/sound.h Normal file
View file

@ -0,0 +1,56 @@
/*
JoeyLib Sound Header File, with Sound Function Prototypes
*/
#ifndef JL_SOUND_H
#define JL_SOUND_H
typedef struct
{
} jlSound_t;
/* jlSoundT - A pointer to a sound bank / collection of sounds */
typedef jlSound_t* jlSoundT;
/* Call this before any other Sound Function */
void jlSoundStartup();
/* Call this when done, for proper shutdown */
void jlSoundShutdown();
/*
Load .jla Sound Bank into memory, or into DOC RAM
*/
jlSoundT jlSoundLoad(const char* pSoundBankPath);
/*
Load .jla Sound Bank from memory, into DOC RAM
DO NOT FREE THIS MEMORY (pointers in the library will point into it)
it may be free after the jlSoundFree hsa been called
*/
jlSoundT jlSoundLoadAt(const char* pBankInRAM);
/*
Returns back an index into the audio definition table, which is required
in order to call jlSoundPlay
*/
signed short jlSoundFind(jlSoundT soundbank, const char* sfxName);
/*
Play a Sound
*/
void jlSoundPlay(jlSoundT soundbank, signed short audio_index);
/*
Return the number of SFX in this Bank
*/
signed short jlSoundGetNumSFX(jlSoundT soundbank);
/*
Return a C string name of the sound effect with this index
DO NOT FREE THIS POINTER
*/
char *jlSoundGetName(signed short audio_index);
/*
Called when you are done with this soundbank
*/
void jlSoundFree(jlSoundT soundbank);
#endif /* JL_SOUND_H */

View file

@ -0,0 +1 @@
MACRO &lab _pushpage &lab lcla &addr &addr seta 254 lcla &loop &loop seta 128 .ploop pei &addr &addr seta &addr-2 &loop seta &loop-1 aif &loop,^ploop MEND macro &lab asl4 &lab lcla &ct &ct seta 4 .top asl a &ct seta &ct-1 aif &ct>0,^top mend macro &lab _auxON &lab lda >$00C068 ora #$0030 sta >$00C068 mend macro &lab _auxOFF &lab lda >$00C068 and #$FFCF sta >$00C068 mend macro &lab _shadowON &lab lda >$00C035 and #$FFF7 sta >$00C035 mend macro &lab _shadowOFF &lab lda >$00C035 ora #$0008 sta >$00C035 mend

Binary file not shown.

Binary file not shown.