[A89] Re: A tale of much horror
[Prev][Next][Index][Thread]
[A89] Re: A tale of much horror
AAARRGH! Why won't this work?!?
// C Source File
// Created 9/1/2003; 9:13:03 PM
#define USE_TI89 // Compile for TI-89
#define USE_TI92PLUS // Compile for TI-92 Plus
#define USE_V200 // Compile for V200
#define ENABLE_ERROR_RETURN // Enable Returning Errors to AMS
#define OPTIMIZE_ROM_CALLS // Use ROM Call Optimization
#define MIN_AMS 205 // Compile for AMS 2.05 or higher
#define SAVE_SCREEN // Save/Restore LCD Contents
#include <tigcclib.h> // Include All Header Files
#include "ExtGraph.h"
void scroll(char *src, char *dest, short nr_lines, short src_line_len, short dest_line_len) {
short addr;
short i;
int start, fin;
for(i=0; i<nr_lines; i++) {
start = i*(src_line_len>>3); fin = i*(src_line_len>>3)+(dest_line_len>>3);
for(addr=start; addr<fin; addr++) {
*dest++ = *src+addr;
}
*dest += (src_line_len - dest_line_len)>>3;
}
}
// Main Function
void _main(void)
{
unsigned short sprite[] = {
0b0111111111111110,
0b0100000000000010,
0b0110000000110110,
0b0100000000000010,
0b0111111111111110,
};
char *ptr = malloc(16*60);
memset(ptr, 0, 16*60);
PortSet(ptr, 240*2-1, 15);
int i=0;
for(i=0; i<240*2-16; i+=16) {
Sprite16(i, 0, 5, sprite, ptr, SPRT_XOR);
}
PortSet(LCD_MEM, 239, 127);
clrscr();
short x = 0;
scroll(ptr, LCD_MEM, 16, 240*2, 240);
while(1) {
if(_keytest (RR_LEFT) && x > 0) {
x--;
clrscr();
scroll(ptr+x, LCD_MEM, 16, 240*2, 240);
}
if(_keytest (RR_RIGHT) && x < 240) {
x++;
clrscr();
scroll(ptr+x, LCD_MEM, 16, 240*2, 240);
}
if(_keytest (RR_CLEAR)) {
free(ptr);
exit(0);
}
}
}
This small program is supposed to test the scroll() function, which grabs a clip from a buffer and puts it to another buffer. Whenever I try this, I don't get an error, but I get garbage displayed on the video buffer. CAN SOMEONE TELL ME WHAT'S WRONG???
Jude Nelson
Follow-Ups: