Whoa. Bad memory fubar in jlImgCreate(). Fixed.
This commit is contained in:
parent
a6004882dd
commit
91f0b44a33
3 changed files with 16 additions and 16 deletions
|
@ -132,23 +132,17 @@ void jlDrawSurfaceSet(jlSurfaceT target) {
|
||||||
|
|
||||||
|
|
||||||
int jlGameGetAxis(byte which) {
|
int jlGameGetAxis(byte which) {
|
||||||
static bool xRead = true;
|
|
||||||
static bool yRead = true;
|
|
||||||
static jint16 paddles = 0;
|
static jint16 paddles = 0;
|
||||||
jint16 r;
|
jint16 r;
|
||||||
|
|
||||||
if (which == 0) {
|
if (which == 0) {
|
||||||
if (xRead) {
|
if (xRead) {
|
||||||
paddles = asmJoy();
|
paddles = asmJoy();
|
||||||
xRead = true;
|
|
||||||
yRead = false;
|
|
||||||
}
|
}
|
||||||
r = paddles & 0x00ff;
|
r = paddles & 0x00ff;
|
||||||
} else {
|
} else {
|
||||||
if (yRead) {
|
if (yRead) {
|
||||||
paddles = asmJoy();
|
paddles = asmJoy();
|
||||||
xRead = false;
|
|
||||||
yRead = true;
|
|
||||||
}
|
}
|
||||||
r = (paddles & 0xff00) >> 8;
|
r = (paddles & 0xff00) >> 8;
|
||||||
}
|
}
|
||||||
|
@ -174,7 +168,7 @@ bool _jlImgCreate(jlImgT **img) {
|
||||||
}
|
}
|
||||||
*img = t;
|
*img = t;
|
||||||
}
|
}
|
||||||
memset(t, 0, sizeof(jlImgT));
|
t = (jlImgT *)*img;
|
||||||
t->id[0] = 'I';
|
t->id[0] = 'I';
|
||||||
t->id[1] = 'M';
|
t->id[1] = 'M';
|
||||||
t->id[2] = 'G';
|
t->id[2] = 'G';
|
||||||
|
|
|
@ -428,7 +428,7 @@ bool _jlImgCreate(jlImgT **img) {
|
||||||
}
|
}
|
||||||
*img = t;
|
*img = t;
|
||||||
}
|
}
|
||||||
memset(t, 0, sizeof(jlImgT));
|
t = (jlImgT *)*img;
|
||||||
t->id[0] = 'I';
|
t->id[0] = 'I';
|
||||||
t->id[1] = 'M';
|
t->id[1] = 'M';
|
||||||
t->id[2] = 'G';
|
t->id[2] = 'G';
|
||||||
|
|
|
@ -77,7 +77,7 @@ void help(jlSurfaceT source, jlStnT *stencil, jint16 sx, jint16 sy, jint16 tx, j
|
||||||
|
|
||||||
// Font hacking!
|
// Font hacking!
|
||||||
__attribute__((__format__ (__printf__, 5, 0)))
|
__attribute__((__format__ (__printf__, 5, 0)))
|
||||||
void printAt(jlImgT *font, jlStnT *stencil, jint16 cx, jint16 cy, const char *what, ...) {
|
void fontPrint(jlImgT *font, jlStnT *stencil, jint16 cx, jint16 cy, const char *what, ...) {
|
||||||
jint16 x;
|
jint16 x;
|
||||||
jint16 y;
|
jint16 y;
|
||||||
jint16 tx;
|
jint16 tx;
|
||||||
|
@ -127,8 +127,8 @@ void blitTest(void) {
|
||||||
jlDrawClear();
|
jlDrawClear();
|
||||||
jlPaletteSet(15, 15, 15, 15);
|
jlPaletteSet(15, 15, 15, 15);
|
||||||
|
|
||||||
printAt(font, NULL, 1, 2, "%s", "Blitting without stencil buffer.");
|
fontPrint(font, NULL, 1, 2, "%s", "Blitting without stencil buffer.");
|
||||||
printAt(font, stencil, 1, 4, "%s", "Blitting with stencil buffer.");
|
fontPrint(font, stencil, 1, 4, "%s", "Blitting with stencil buffer.");
|
||||||
jlDisplayPresent();
|
jlDisplayPresent();
|
||||||
jlKeyWaitForAny();
|
jlKeyWaitForAny();
|
||||||
|
|
||||||
|
@ -136,7 +136,7 @@ void blitTest(void) {
|
||||||
while (!jlKeyPressed()) {
|
while (!jlKeyPressed()) {
|
||||||
for (x=0; x<319-8; x++) {
|
for (x=0; x<319-8; x++) {
|
||||||
jlDrawBlit8x8(jlImgSurfaceGet(font), 8, 0, x, y);
|
jlDrawBlit8x8(jlImgSurfaceGet(font), 8, 0, x, y);
|
||||||
printAt(font, NULL, 1, 6, "Drawing at %d x %d ", x, y);
|
fontPrint(font, NULL, 1, 6, "Drawing at %d x %d ", x, y);
|
||||||
jlDisplayPresent();
|
jlDisplayPresent();
|
||||||
jlDrawBlit8x8(jlImgSurfaceGet(font), 0, 0, x, y);
|
jlDrawBlit8x8(jlImgSurfaceGet(font), 0, 0, x, y);
|
||||||
jlUtilSleep(1);
|
jlUtilSleep(1);
|
||||||
|
@ -154,6 +154,8 @@ void blitTest(void) {
|
||||||
|
|
||||||
void exerciseAPI(void) {
|
void exerciseAPI(void) {
|
||||||
|
|
||||||
|
jlImgT *screen = NULL;
|
||||||
|
|
||||||
jlDrawColorSet(0);
|
jlDrawColorSet(0);
|
||||||
jlDrawClear();
|
jlDrawClear();
|
||||||
jlDrawColorSet(15);
|
jlDrawColorSet(15);
|
||||||
|
@ -161,6 +163,10 @@ void exerciseAPI(void) {
|
||||||
jlDrawPixelSet(10, 10);
|
jlDrawPixelSet(10, 10);
|
||||||
assert(jlDrawPixelGet(10, 10) == 15);
|
assert(jlDrawPixelGet(10, 10) == 15);
|
||||||
|
|
||||||
|
// Should be able to grab the screen twice without allocation issues.
|
||||||
|
jlImgCreate(screen);
|
||||||
|
jlImgCreate(screen);
|
||||||
|
jlImgFree(screen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -214,7 +220,7 @@ void lineTest(void) {
|
||||||
|
|
||||||
while (!jlKeyPressed()) {
|
while (!jlKeyPressed()) {
|
||||||
y = 17;
|
y = 17;
|
||||||
printAt(font, NULL, 1, y++, "Drawing %s ", what);
|
fontPrint(font, NULL, 1, y++, "Drawing %s ", what);
|
||||||
|
|
||||||
jlDrawColorSet((byte)color);
|
jlDrawColorSet((byte)color);
|
||||||
if (phase < 2) {
|
if (phase < 2) {
|
||||||
|
@ -299,7 +305,7 @@ void musicTest(void) {
|
||||||
jlSoundModPlay("music");
|
jlSoundModPlay("music");
|
||||||
|
|
||||||
while (!jlKeyPressed()) {
|
while (!jlKeyPressed()) {
|
||||||
printAt(font, NULL, 1, 1, "%dx%d %d %d ", jlGameGetAxis(0), jlGameGetAxis(1), jlGameGetButton(0), jlGameGetButton(1));
|
fontPrint(font, NULL, 1, 1, "%dx%d %d %d ", jlGameGetAxis(0), jlGameGetAxis(1), jlGameGetButton(0), jlGameGetButton(1));
|
||||||
jlDisplayPresent();
|
jlDisplayPresent();
|
||||||
}
|
}
|
||||||
jlKeyRead();
|
jlKeyRead();
|
||||||
|
@ -370,10 +376,10 @@ int main(void) {
|
||||||
jlUtilStartup("JoeyLib Test");
|
jlUtilStartup("JoeyLib Test");
|
||||||
|
|
||||||
//blitTest();
|
//blitTest();
|
||||||
//exerciseAPI();
|
exerciseAPI();
|
||||||
//grid();
|
//grid();
|
||||||
//lineTest();
|
//lineTest();
|
||||||
musicTest();
|
//musicTest();
|
||||||
//showStencil();
|
//showStencil();
|
||||||
|
|
||||||
jlUtilShutdown();
|
jlUtilShutdown();
|
||||||
|
|
Loading…
Add table
Reference in a new issue