Skip to content

Commit

Permalink
map 1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
CasterWx committed Oct 19, 2019
1 parent 299f374 commit b2e1315
Show file tree
Hide file tree
Showing 17 changed files with 354 additions and 86 deletions.
Binary file modified antz.img
Binary file not shown.
171 changes: 109 additions & 62 deletions include/bmp.h

Large diffs are not rendered by default.

3 changes: 0 additions & 3 deletions main/bootpack.c
Original file line number Diff line number Diff line change
Expand Up @@ -274,9 +274,6 @@ void HariMain(void)

init_palette();

while (timerctl.count/100<5)
to_show();


print_area(binfo->vram, binfo->scrnx , COL8_FFFFFF , 0 , 0 , binfo->scrnx, binfo->scrny);
init_screen8(binfo->vram, binfo->scrnx, binfo->scrny);
Expand Down
6 changes: 3 additions & 3 deletions task/timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ void inthandler20(int *esp)
if((timerctl.flag==1)){
// img
int fkx,fky;
print_string(binfo->vram, binfo->scrnx, 0, 0, 40, "LV.1 ***");
print_area(binfo->vram, binfo->scrnx,55, 0, 0, binfo->scrnx, binfo->scrny);
to_show();
// print_area(binfo->vram, binfo->scrnx,55, 0, 0, binfo->scrnx, binfo->scrny);

header();
}
Expand All @@ -60,7 +60,7 @@ void header(){
print_area(binfo->vram, binfo->scrnx,12, pyx-35, pyy+20, pyx-20, pyy+30);

// 剑
print_area(binfo->vram, binfo->scrnx,15, pyx-30, pyy-25, pyx-25, pyy+40);
print_area(binfo->vram, binfo->scrnx,53, pyx-30, pyy-25, pyx-25, pyy+40);

// body
print_area(binfo->vram, binfo->scrnx,150, pyx-20, pyy+15, pyx+20, pyy+40);
Expand Down
24 changes: 6 additions & 18 deletions thun/thun.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,16 @@ void to_printf_dijkstra(){

void to_show(){
struct BOOTINFO *binfo = (struct BOOTINFO *) ADR_BOOTINFO;
int i, x, y , m , n;
int x, y ;
int k ; // 1024x768
for (y = 0; y < 60; y++) { //10800
k = 0 ;
for (y = 0; y < 60; y++) { //10800 108 * 13
for (x = 0; x < 108; x++){
// 16 + bmp_r[k]/43 + 6* (bmp_g[k]/43) + 36* (bmp_b[k]/43); 24色RGB转换公式
/**
* 取得为bmp[y][x],接下来需要在(x*10,y*13)~(x*10+10,y*13+13)区间填充这个颜色。
**/
for(m=y*13; m<y*13+13; m++){
for(n=x*10; n<x*10+10; n++){
// int fy1 = (((x*10+10)-n)/10)*bmp[y+1][x] + ((n-x*10)/10)*bmp[y+1][x+1];
// int fy2 = (((x*10+10)-n)/10)*bmp[y][x] + ((n-x*10)/10)*bmp[y][x+1];
// int rgbnum = ((m-y*13)/(13))*fy1 + ((y*13+13-m)/13)*fy2 ;
double fy1 = (((double)(x*10.0+10.0)-n)/10.0)*bmp[y+1][x] + ((double)(n-x*10.0)/10.0)*bmp[y+1][x+1];
double fy2 = (((double)(x*10.0+10)-n)/10.0)*bmp[y][x] + ((double)(n-x*10.0)/10.0)*bmp[y][x+1];
int rgbnum = (int)(((double)(m-y*13.0)/(13.0))*fy1 + ((double)(y*13.0+13.0-m)/13.0)*fy2 );
print_area(binfo->vram, binfo->scrnx,rgbnum,n,m,n,m);
}
}
// 16 + bmp_r[k]/43 + 6* (bmp_g[k]/43) + 36* (bmp_b[k]/43) ;
print_area(binfo->vram, binfo->scrnx,bmp[k],x*10,y*13,x*10+10,y*13+13);
k++;
}
}

}


Expand Down
Binary file added tools/1.bmp
Binary file not shown.
Binary file added tools/11.bmp
Binary file not shown.
Binary file added tools/11.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tools/12.bmp
Binary file not shown.
Binary file added tools/122.bmp
Binary file not shown.
Binary file added tools/24.bmp
Binary file not shown.
Binary file added tools/24.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
113 changes: 113 additions & 0 deletions tools/img.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>

typedef unsigned long DWORD;
typedef int BOOL;
typedef unsigned char BYTE;
typedef unsigned short WORD;

typedef struct tagBITMAPINFOHEADER{
DWORD biSize;
long biWidth;
long biHeight;
WORD biPlanes;
WORD biBitCount;
DWORD biCompression;
DWORD biSizeImage;
long biXPelsPerMeter;
long biYPelsPerMeter;
DWORD biClrUsed;
DWORD biClrImportant;
} BITMAPINFOHEADER;

int ReadBmp(const char* szFileName);
int GetDIBColor(int X, int Y, BYTE *r, BYTE *g, BYTE *b);

BITMAPINFOHEADER bih;

BYTE *Buffer = NULL;

long LineByteWidth;
int main(void)
{
int x, y;
BYTE r, g, b;
int n;
char szfilename[255] = "122.bmp";
if (ReadBmp(szfilename) == 0)
{
printf("failure to read file %s", szfilename);
return 1;
}
printf("Width: %ld\n", bih.biWidth);
printf("Height: %ld\n", bih.biHeight);
printf("BitCount: %d\n\n", (int)bih.biBitCount);
for(int i=0;i<bih.biWidth;i++){
for(int j=0;j<bih.biHeight;j++){
if (GetDIBColor(i, j, &r, &g, &b) == 1){
int rgb = (((int)r/43)+(((int)g/43)*6)+(((int)b/43)*36) + 16);
printf("%d,", rgb);
}
else{
printf("input error.\n");
}
}
printf("\n");
}

free(Buffer);
return 0;
}

int ReadBmp(const char* szFileName)
{
FILE *file;
WORD bfh[7];
long dpixeladd;
if (NULL == (file = fopen(szFileName, "rb")))
{
return 0;
}
printf("%s\n", szFileName);
fread(&bfh, sizeof(WORD), 7, file);
if (bfh[0] != (WORD)(((WORD)'B')|('M'<<8)))
{
fclose(file);
return 0;
}
fread(&bih, sizeof(BITMAPINFOHEADER), 1, file);
if (bih.biBitCount < 24)
{
fclose(file);
return 0;
}
dpixeladd = bih.biBitCount / 8;
LineByteWidth = bih.biWidth * (dpixeladd);
if ((LineByteWidth % 4) != 0)
LineByteWidth += 4 - (LineByteWidth % 4);
if ((Buffer = (BYTE*)malloc(sizeof(BYTE)* LineByteWidth * bih.biHeight)) != NULL)
{
fread(Buffer, LineByteWidth * bih.biHeight, 1, file);
fclose(file);
return 1;
}
fclose(file);
return 0;
}

int GetDIBColor(int X, int Y, BYTE *r, BYTE *g, BYTE *b)
{
int dpixeladd;
BYTE *ptr;
if (X < 0 || X >= bih.biWidth || Y < 0 || Y >= bih.biHeight)
{
return 0;
}
dpixeladd = bih.biBitCount / 8;
ptr = Buffer + X * dpixeladd + (bih.biHeight - 1 - Y) * LineByteWidth;
*b = *ptr;
*g = *(ptr + 1);
*r = *(ptr + 2);
return 1;
}
88 changes: 88 additions & 0 deletions tools/img.dsp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 35 additions & 0 deletions tools/img.plg
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<html>
<body>
<pre>
<h1>Build Log</h1>
<h3>
--------------------Configuration: img - Win32 Debug--------------------
</h3>
<h3>Command Lines</h3>
Creating temporary file "C:\Users\ADMINI~1\AppData\Local\Temp\RSP1F1.tmp" with contents
[
/nologo /MLd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /Fp"Debug/img.pch" /YX /Fo"Debug/" /Fd"Debug/" /FD /GZ /c
"C:\Users\Administrator\IdeaProjects\AntzGame\tools\img.cpp"
]
Creating command line "cl.exe @C:\Users\ADMINI~1\AppData\Local\Temp\RSP1F1.tmp"
Creating temporary file "C:\Users\ADMINI~1\AppData\Local\Temp\RSP1F2.tmp" with contents
[
kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /incremental:yes /pdb:"Debug/img.pdb" /debug /machine:I386 /out:"Debug/img.exe" /pdbtype:sept
.\Debug\img.obj
]
Creating command line "link.exe @C:\Users\ADMINI~1\AppData\Local\Temp\RSP1F2.tmp"
<h3>Output Window</h3>
Compiling...
img.cpp
C:\Users\Administrator\IdeaProjects\AntzGame\tools\img.cpp(34) : warning C4101: 'x' : unreferenced local variable
C:\Users\Administrator\IdeaProjects\AntzGame\tools\img.cpp(34) : warning C4101: 'y' : unreferenced local variable
C:\Users\Administrator\IdeaProjects\AntzGame\tools\img.cpp(36) : warning C4101: 'n' : unreferenced local variable
Linking...



<h3>Results</h3>
img.exe - 0 error(s), 3 warning(s)
</pre>
</body>
</html>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit b2e1315

Please sign in to comment.