📄 dcvideo.c
字号:
/*
dcVideo.c
some simple graphic routines thrown together for use with
libdream.
i've tried to comment as much as possible.
reach me at programming forum on, www.dcemulation.com
jmp@r0
*/
#include "dcVideo.h"
//#include "malloc.h"
#include "draw.h"
#include "miscfunc.h"
/*
dcVideoBlit parameters:
destination x position, destination y position, source x position, y source position,
source width, source height, pointer to dcbitmap structure, pointer to destination videoram.
it works only with 320x240, but simply change the '320' references within code to make it
work with 640x480 etc, or even better, put in some checks and make it a general blit routine ^_^.
*/
/* void *malloc(unsigned int size)
{
static void *ptr = (void *) (0x8c100000);
void *tmp = ptr;
ptr +=size;
if(((int)ptr) & 3)
{
ptr += 4 - (((int)ptr) & 3);
}
return tmp;
}*/
void dcVideoBlit(int xDestination, int yDestination, int xSource, int ySource, int wSource, int hSource, dcBitmap *bitmapSource, unsigned short *bitmapDestination)
{
unsigned short *bitmapData;
short xCounter, yCounter;
/* pointer to source image data. */
bitmapData = bitmapSource->Data;
/* calculate destination ram address. */
bitmapDestination += xDestination + (yDestination*640);
/* shuffle those words. */
for(yCounter = 0 ; yCounter < hSource ; yCounter++)
{
for(xCounter = 0 ; xCounter < wSource ; xCounter++)
{
*bitmapDestination++ = *bitmapData++;
}
/* point at next line of destination bitmap. */
bitmapDestination += 640 - wSource;
/* point at next line of source bitmap. */
bitmapData += bitmapSource->Width - wSource;
}
}
dcBitmap *create_bitmap(int width, int height)
{
int number_of_bytes;
dcBitmap *buffer;
buffer = (dcBitmap*)malloc(sizeof(dcBitmap));
buffer->Width = width;
buffer->Height = height;
number_of_bytes = buffer->Width * buffer->Height;
buffer->Data = (unsigned short *)malloc(number_of_bytes *2);
return buffer;
}
void clear_bitmap(dcBitmap *bmp, int r, int g, int b)
{
int x,y,width,height;
width = bmp->Width;
height = bmp->Height;
for (y=0; y<height; y++)
{
for (x=0; x<width; x++)
{
bmp->Data[y*width+x] = rgb_combine(r, g, b);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -