+/* Project 16 Source Code~\r
+ * Copyright (C) 2012-2015 sparky4 & pngwen & andrius4669\r
+ *\r
+ * This file is part of Project 16.\r
+ *\r
+ * Project 16 is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 3 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * Project 16 is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program. If not, see <http://www.gnu.org/licenses/>, or\r
+ * write to the Free Software Foundation, Inc., 51 Franklin Street,\r
+ * Fifth Floor, Boston, MA 02110-1301 USA.\r
+ *\r
+ */\r
#include <stdio.h>\r
+#include <conio.h>\r
#include "lib/types.h"\r
#include "lib/text.h"\r
\r
-main() {\r
+void main(int argc, char *argv[])\r
+{\r
int i;\r
int j;\r
- char l[16];\r
+ char l[16];\r
char c;\r
- word s, o;\r
+ word s, o, t, w;\r
word addr = (word) l;\r
textInit();\r
\r
printf("Character: ");\r
scanf("%c", &c);\r
\r
- s=romFonts[ROM_FONT_8x16].seg;\r
- o=romFonts[ROM_FONT_8x16].off;\r
+ switch(*argv[1])\r
+ {\r
+ case 0:\r
+ t=0;\r
+ w=14;\r
+ break;\r
+ case 1:\r
+ t=1;\r
+ w=8;\r
+ break;\r
+ case 2:\r
+ t=2;\r
+ w=8;\r
+ break;\r
+ case 3:\r
+ t=3;\r
+ w=16;\r
+ break;\r
+ default:\r
+ t=3;\r
+ w=16;\r
+ }\r
+\r
+\r
+ s=romFonts[t].seg;\r
+ o=romFonts[t].off;\r
\r
//load the letter 'A'\r
__asm {\r
SHL BX, 1\r
SHL BX, 1\r
ADD SI, BX ;the address of A\r
- MOV CX, 16\r
+ MOV CX, w\r
L1: MOV AX, ES:SI\r
MOV DS:DI, AX\r
INC SI\r
}\r
\r
//render the letter in ascii art\r
- for(i=0; i<16; i++) {\r
+ for(i=0; i<w; i++) {\r
j=1<<8;\r
while(j) {\r
printf("%c", l[i] & j ? '*':' ');\r
-/* Project 16 Source Code~
- * Copyright (C) 2012-2015 sparky4 & pngwen & andrius4669
- *
- * This file is part of Project 16.
- *
- * Project 16 is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * Project 16 is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>, or
- * write to the Free Software Foundation, Inc., 51 Franklin Street,
- * Fifth Floor, Boston, MA 02110-1301 USA.
- *
- */
-
-#include <stdio.h>
-#include <dos.h>
+/* Project 16 Source Code~\r
+ * Copyright (C) 2012-2015 sparky4 & pngwen & andrius4669\r
+ *\r
+ * This file is part of Project 16.\r
+ *\r
+ * Project 16 is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 3 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * Project 16 is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program. If not, see <http://www.gnu.org/licenses/>, or\r
+ * write to the Free Software Foundation, Inc., 51 Franklin Street,\r
+ * Fifth Floor, Boston, MA 02110-1301 USA.\r
+ *\r
+ */\r
+\r
+#include <stdio.h>\r
+#include <dos.h>\r
#include <string.h>\r
#include "src/lib/modex16.h"\r
-#include "src/lib/bitmap.h"
-#include "src/lib/planar.c"\r
+#include "src/lib/bitmap.h"\r
+#include "src/lib/planar.h"\r
\r
word far* clockw= (word far*) 0x046C; /* 18.2hz clock */\r
\r
-/*
+/*\r
void\r
-DrawPBuf(page_t *page, int x, int y, planar_buf_t *p, byte sprite)
+DrawPBuf(page_t *page, int x, int y, planar_buf_t *p, byte sprite)\r
{\r
byte plane;\r
word px, py;\r
modexSelectPlane(PLANE(plane+x));\r
for(px = plane; px < p->width; px+=4) {\r
offset=px;\r
- for(py=0; py<p->height/2; py++) {
+ for(py=0; py<p->height/2; py++) {\r
SELECT_ALL_PLANES();\r
if(!sprite || p->plane[offset])\r
page->data = p->plane;\r
- //offset+=p->width;
+ //offset+=p->width;\r
//offset++;\r
}\r
}\r
}\r
}\r
-*/
+*/\r
\r
void main() {\r
- bitmap_t bmp;
+ bitmap_t bmp;\r
planar_buf_t *p;\r
- int i;
+ int i;\r
page_t page;\r
- word start;
+ word start;\r
int plane;\r
float t1, t2;\r
\r
page=modexDefaultPage();\r
\r
-//0000 bmp = bitmapLoadPcx("data/koishi~~.pcx");
-// bmp = bitmapLoadPcx("data/chikyuu.pcx");
- bmp = bitmapLoadPcx("data/koishi^^.pcx");
-// bmp = bitmapLoadPcx("16/PCX_LIB/chikyuu.pcx");
+//0000 bmp = bitmapLoadPcx("data/koishi~~.pcx");\r
+// bmp = bitmapLoadPcx("data/chikyuu.pcx");\r
+ bmp = bitmapLoadPcx("data/koishi^^.pcx");\r
+// bmp = bitmapLoadPcx("16/PCX_LIB/chikyuu.pcx");\r
p = planar_buf_from_bitmap(&bmp);\r
modexEnter();\r
\r
/* clear and draw one sprite and one bitmap */\r
modexClearRegion(&page, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 1);\r
\r
- /* non sprite comparison */
+ /* non sprite comparison */\r
start = *clockw;\r
for(i=0; i<100 ;i++) {\r
oldDrawBmp(VGA, 20, 20, &bmp, 0);\r
\r
start = *clockw;\r
for(i=0; i<100 ;i++) {\r
-//0000 modexDrawBmp(&page, 20, 20, &bmp);
+//0000 modexDrawBmp(&page, 20, 20, &bmp);\r
modexDrawBmp(&page, 0, 0, &bmp);\r
}\r
t1 = (*clockw-start) /18.2;\r
\r
start = *clockw;\r
for(i=0; i<100; i++) {\r
-//0000 modexCopyPageRegion(&page, &page, 20, 20, 128, 20, 64, 64);
+//0000 modexCopyPageRegion(&page, &page, 20, 20, 128, 20, 64, 64);\r
modexCopyPageRegion(&page, &page, 0, 0, 0, 0, 320, 240);\r
}\r
t2 = (*clockw-start)/18.2;\r
\r
start = *clockw;\r
for(i=0; i<100 ;i++) {\r
-//0000 modexDrawSprite(&page, 20, 20, &bmp);
+//0000 modexDrawSprite(&page, 20, 20, &bmp);\r
modexDrawSprite(&page, 0, 0, &bmp);\r
- }
- //_fmemset(MK_FP(0xA000, 0), (int)p->plane, SCREEN_WIDTH*(SCREEN_HEIGHT*2));
- modexDrawBmp(&page, 0, 0, &bmp);
- while(!kbhit())
- {
- //DrawPBuf(&page, 0, 0, p, 0);
- }
+ }\r
+ //_fmemset(MK_FP(0xA000, 0), (int)p->plane, SCREEN_WIDTH*(SCREEN_HEIGHT*2));\r
+ modexDrawBmp(&page, 0, 0, &bmp);\r
+ while(!kbhit())\r
+ {\r
+ //DrawPBuf(&page, 0, 0, p, 0);\r
+ }\r
modexLeave();\r
-
- printf("\n%d\n", sizeof(p->plane));
- printf("%d\n", sizeof(bmp));
-
- for(i=0; i<(320*240); i++)
- {
- fprintf(stdout, "%d", bmp.data[i]);
- if(i%320==0) fprintf(stdout, "\n");
+\r
+ printf("\n%d\n", sizeof(p->plane));\r
+ printf("%d\n", sizeof(bmp));\r
+\r
+ for(i=0; i<(320*240); i++)\r
+ {\r
+ fprintf(stdout, "%d", bmp.data[i]);\r
+ if(i%320==0) fprintf(stdout, "\n");\r
}\r
printf("CPU to VGA: %f\n", t1);\r
printf("VGA to VGA: %f\n", t2);\r
--- /dev/null
+/* Project 16 Source Code~
+ * Copyright (C) 2012-2015 sparky4 & pngwen & andrius4669
+ *
+ * This file is part of Project 16.
+ *
+ * Project 16 is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Project 16 is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>, or
+ * write to the Free Software Foundation, Inc., 51 Franklin Street,
+ * Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ */
+
+#include "text.h"
+
+/* this array holds the rom font descriptors */
+font_t romFonts[4];
+
+
+static void getRomFontAddr(char fontNum, int index) {
+ word fontSeg;
+ word fontOff;
+
+ __asm {
+ PUSH BP
+ MOV AX, 0x1130 ;I can haz font info plz?
+ MOV BH, fontNum ; where ur fontNum
+ INT 0x10 ;kthxbae
+ MOV AX, ES ;save teh segmentz
+ MOV BX, BP ;and all the base!
+ POP BP ;u can haz ur frame back!
+ MOV fontSeg, AX ;Storage
+ MOV fontOff, BX ;Storage
+ }
+ romFonts[index].seg = fontSeg;
+ romFonts[index].off = fontOff;
+
+}
+
+/* This function initializes the text engine */
+void textInit() {
+ getRomFontAddr(0x02, ROM_FONT_8x14);
+ getRomFontAddr(0x03, ROM_FONT_8x8_LOW);
+ getRomFontAddr(0x04, ROM_FONT_8x8_HIGH);
+ getRomFontAddr(0x06, ROM_FONT_8x16);
+ romFonts[ROM_FONT_8x14].charSize=14;
+ romFonts[ROM_FONT_8x8_LOW].charSize=8;
+ romFonts[ROM_FONT_8x8_HIGH].charSize=8;
+ romFonts[ROM_FONT_8x16].charSize=16;
+}
--- /dev/null
+/* Project 16 Source Code~
+ * Copyright (C) 2012-2015 sparky4 & pngwen & andrius4669
+ *
+ * This file is part of Project 16.
+ *
+ * Project 16 is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Project 16 is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>, or
+ * write to the Free Software Foundation, Inc., 51 Franklin Street,
+ * Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ */
+/*
+ * This is the text subsystem for project 16.
+ * These functions provide for the rendering of text strings
+ * using the BIOS fonts.
+ * They copy the font characters directly to VGA.
+ */
+#ifndef TEXT_H
+#define TEXT_H
+#include "types.h"
+
+/* font information type */
+typedef struct font {
+ word seg; //segment for the font
+ word off; //offset in the segment for the font
+ byte charSize; //bytes in each character
+} font_t;
+
+/* storage for the rom fonts */
+extern font_t romFonts[4];
+#define ROM_FONT_8x14 0
+#define ROM_FONT_8x8_LOW 1
+#define ROM_FONT_8x8_HIGH 2
+#define ROM_FONT_8x16 3
+
+/* This function initializes the text engine */
+void textInit();
+
+#endif