mirror of
https://github.com/deater/dos33fsprogs.git
synced 2025-02-05 21:34:30 +00:00
tfv: minimal sprite implementation
This commit is contained in:
parent
a8970f761b
commit
225dc6f4cc
@ -595,3 +595,51 @@ int basic_vlin(int y1, int y2, int at) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
short gr_addr_lookup[48]={
|
||||
0x400,0x480,0x500,0x580,0x600,0x680,0x700,0x780,
|
||||
0x428,0x4a8,0x528,0x5a8,0x628,0x6a8,0x728,0x7a8,
|
||||
0x450,0x4d0,0x550,0x5d0,0x650,0x6d0,0x750,0x7d0,
|
||||
};
|
||||
|
||||
int grsim_put_sprite(unsigned char *sprite_data, int xpos, int ypos) {
|
||||
|
||||
int i,j,xsize,ysize;
|
||||
unsigned char *ptr;
|
||||
short address;
|
||||
ptr=sprite_data;
|
||||
xsize=*ptr;
|
||||
ptr++;
|
||||
ysize=*ptr;
|
||||
ptr++;
|
||||
|
||||
for(j=0;j<ysize;j++) {
|
||||
address=gr_addr_lookup[(ypos+j)/2];
|
||||
address+=xpos;
|
||||
for(i=0;i<xsize;i++) {
|
||||
if (*ptr) ram[address]=*ptr;
|
||||
ptr++;
|
||||
address++;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int gr_copy(short source, short dest) {
|
||||
|
||||
short dest_addr,source_addr;
|
||||
int i,j;
|
||||
|
||||
for(i=0;i<8;i++) {
|
||||
source_addr=gr_addr_lookup[i]+0x400;
|
||||
dest_addr=gr_addr_lookup[i];
|
||||
|
||||
for(j=0;j<120;j++) {
|
||||
ram[dest_addr+j]=ram[source_addr+j];
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -11,4 +11,5 @@ int bload(char *filename, int address);
|
||||
int scrn(unsigned char xcoord, unsigned char ycoord);
|
||||
int grsim_unrle(unsigned char *rle_data, int address);
|
||||
int home(void);
|
||||
|
||||
int grsim_put_sprite(unsigned char *sprite_data, int xpos, int ypos);
|
||||
int gr_copy(short source, short dest);
|
||||
|
24
gr-sim/tfv.c
24
gr-sim/tfv.c
@ -32,23 +32,45 @@ static unsigned char title_rle[]=
|
||||
|
||||
};
|
||||
|
||||
static unsigned char test_sprite[]={
|
||||
0x8,0x4,
|
||||
0x55,0x50,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x55,0x55,0x55,0x00,0x00,0x00,0x00,0x00,
|
||||
0xff,0x1f,0x4f,0x2f,0xff,0x22,0x20,0x00,
|
||||
0x5f,0x5f,0x5f,0x5f,0xff,0xf2,0xf2,0xf2,
|
||||
};
|
||||
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
|
||||
int ch;
|
||||
int x,y;
|
||||
|
||||
grsim_init();
|
||||
|
||||
/* Title Screen */
|
||||
grsim_unrle(title_rle,0x400);
|
||||
grsim_unrle(title_rle,0x800);
|
||||
gr_copy(0x800,0x400);
|
||||
|
||||
grsim_update();
|
||||
|
||||
x=20; y=21;
|
||||
color_equals(0);
|
||||
|
||||
while(1) {
|
||||
|
||||
ch=grsim_input();
|
||||
|
||||
if (ch=='q') break;
|
||||
if (ch=='i') if (y>0) y-=2;
|
||||
if (ch=='m') if (y<39) y+=2;
|
||||
if (ch=='j') if (x>0) x--;
|
||||
if (ch=='k') if (x<39) x++;
|
||||
|
||||
gr_copy(0x800,0x400);
|
||||
grsim_put_sprite(test_sprite,x,y);
|
||||
|
||||
grsim_update();
|
||||
|
||||
usleep(100000);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user