/* * JoeyLib * Copyright (C) 2018 Scott Duensing * * 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 #include #include #include "joey.h" #ifdef JOEY_IIGS segment "testapp"; #endif // Font hacking! __attribute__((__format__ (__printf__, 4, 0))) void printAt(jlStaT *font, jint16 cx, jint16 cy, const char *what, ...) { jint16 x; jint16 y; 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); for (counter=0; counter<(int)strlen(msg); counter++) { x = (msg[counter] - ' ') % 40; y = (msg[counter] - ' ') / 40; jlDrawBlit8x8(font, x, y, counter + cx, cy); } } int main(void) { jlStaT *kanga = NULL; jlStaT *font = NULL; jlVecT *vec = NULL; jint16 y; jlUtilStartup("JoeyLib Test"); jlVecLoad(vec, "nowhere"); jlVecDisplay(vec, 0, 0); jlDisplayPresent(); jlKeyWaitForAny(); jlStaLoad(kanga, "kanga"); jlStaLoad(font, "font"); jlStaDisplay(kanga); jlDrawColor(1); jlDrawBox(0, 0, 319, 199); jlSoundMusicPlay("music"); jlPaletteSet(15, 15, 15, 15); while (!jlKeyPressed()) { y = 17; printAt(font, 1, y++, "X = %d ", jlGameGetAxis(0)); printAt(font, 1, y++, "Y = %d ", jlGameGetAxis(1)); printAt(font, 1, y++, "T = %d ", jlUtilTimer()); jlDisplayPresent(); } jlKeyRead(); jlSoundMusicStop(); jlStaFree(font); jlStaFree(kanga); jlUtilShutdown(); }