From: Robert Lowe Date: Mon, 22 Jun 2015 04:17:38 +0000 (-0400) Subject: Added the start of the text system library. X-Git-Url: http://4ch.mooo.com/gitweb/?a=commitdiff_plain;h=077782026074116470d9637507d988ffcc29ef58;p=16.git Added the start of the text system library. Currently, all it does is find the locations of the BIOS fonts. ftest.c is a little program that renders the 8x16 font in ascii art. --- diff --git a/FTEST.EXE b/FTEST.EXE new file mode 100644 index 00000000..d9af81d7 Binary files /dev/null and b/FTEST.EXE differ diff --git a/makefile b/makefile index d1183b0e..32cd4308 100644 --- a/makefile +++ b/makefile @@ -1,7 +1,7 @@ #-zk0u = translate kanji to unicode... wwww #-zk0 = kanji support~ #-zkl = current codepage - + MFLAGS=-mh# -zm CFLAGS=-zkl -wo -x#### -mc# -zdp# -zp16 -zq OFLAGS=-ot -ox -ob -oh -or# -om -ol -ol+ @@ -10,17 +10,17 @@ REMOVECOMMAND=del DIRSEP=\ SRC=src$(DIRSEP) SRCLIB=$(SRC)lib$(DIRSEP) -JSMNLIB=$(SRCLIB)jsmn$(DIRSEP) -EXMMLIB=$(SRCLIB)exmm$(DIRSEP) +JSMNLIB=$(SRCLIB)jsmn$(DIRSEP) +EXMMLIB=$(SRCLIB)exmm$(DIRSEP) WCPULIB=$(SRCLIB)wcpu$(DIRSEP) -all: 16.exe test.exe pcxtest.exe test2.exe scroll.exe palettec.exe maptest.exe maptest0.exe emsdump.exe emmtest.exe fmemtest.exe - -# -#executables -# -16.exe: 16.obj modex16.obj dos_kb.obj bitmap.obj mapread.obj jsmn.obj lib_head.obj scroll16.obj#planar.obj wcpu.obj - wcl $(FLAGS) 16.obj modex16.obj dos_kb.obj bitmap.obj mapread.obj jsmn.obj lib_head.obj scroll16.obj#planar.obj wcpu.obj +all: 16.exe test.exe pcxtest.exe test2.exe scroll.exe palettec.exe maptest.exe maptest0.exe emsdump.exe emmtest.exe fmemtest.exe ftest.exe + +# +#executables +# +16.exe: 16.obj modex16.obj dos_kb.obj bitmap.obj mapread.obj jsmn.obj lib_head.obj scroll16.obj#planar.obj wcpu.obj + wcl $(FLAGS) 16.obj modex16.obj dos_kb.obj bitmap.obj mapread.obj jsmn.obj lib_head.obj scroll16.obj#planar.obj wcpu.obj scroll.exe: scroll.obj modex16.obj dos_kb.obj bitmap.obj planar.obj mapread.obj jsmn.obj wcpu.obj wcl $(FLAGS) scroll.obj modex16.obj dos_kb.obj bitmap.obj planar.obj mapread.obj jsmn.obj wcpu.obj# 16/lib/x/modex.lib @@ -32,32 +32,41 @@ test.exe: test.obj modex16.obj bitmap.obj lib_head.obj test2.exe: test2.obj modex16.obj bitmap.obj planar.obj lib_head.obj wcl $(FLAGS) test2.obj modex16.obj bitmap.obj planar.obj lib_head.obj +ftest.exe: text.obj ftest.obj + wcl $(FLAGS) ftest.obj text.obj + +text.obj: $(SRCLIB)text.c + wcl -c $(SRCLIB)text.c + +ftest.obj: $(SRC)ftest.c + wcl -c $(SRC)ftest.c + pcxtest.exe: pcxtest.obj modex16.obj bitmap.obj planar.obj lib_head.obj - wcl $(FLAGS) pcxtest.obj modex16.obj bitmap.obj planar.obj lib_head.obj - + wcl $(FLAGS) pcxtest.obj modex16.obj bitmap.obj planar.obj lib_head.obj + palettec.exe: palettec.obj modex16.obj wcl $(FLAGS) palettec.obj modex16.obj maptest.exe: maptest.obj mapread.obj jsmn.obj modex16.obj bitmap.obj lib_head.obj wcl $(FLAGS) maptest.obj mapread.obj jsmn.obj modex16.obj bitmap.obj lib_head.obj - + maptest0.exe: maptest0.obj fmapread.obj farjsmn.obj# modex16.obj bitmap.obj lib_head.obj - wcl $(FLAGS) $(MFLAGS) maptest0.obj fmapread.obj farjsmn.obj# modex16.obj bitmap.obj lib_head.obj - -emmtest.exe: emmtest.obj memory.obj - wcl $(FLAGS) $(MFLAGS) emmtest.obj memory.obj - -emsdump.exe: emsdump.obj memory.obj - wcl $(FLAGS) $(MFLAGS) emsdump.obj memory.obj - -fmemtest.exe: fmemtest.obj# memory.obj - wcl $(FLAGS) $(MFLAGS) fmemtest.obj# memory.obj - -# -#executable's objects -# + wcl $(FLAGS) $(MFLAGS) maptest0.obj fmapread.obj farjsmn.obj# modex16.obj bitmap.obj lib_head.obj + +emmtest.exe: emmtest.obj memory.obj + wcl $(FLAGS) $(MFLAGS) emmtest.obj memory.obj + +emsdump.exe: emsdump.obj memory.obj + wcl $(FLAGS) $(MFLAGS) emsdump.obj memory.obj + +fmemtest.exe: fmemtest.obj# memory.obj + wcl $(FLAGS) $(MFLAGS) fmemtest.obj# memory.obj + +# +#executable's objects +# 16.obj: $(SRC)16.h $(SRC)16.c - wcl $(FLAGS) -c $(SRC)16.c + wcl $(FLAGS) -c $(SRC)16.c test.obj: $(SRC)test.c $(SRCLIB)modex16.h wcl $(FLAGS) -c $(SRC)test.c @@ -66,28 +75,28 @@ test2.obj: $(SRC)test2.c $(SRCLIB)modex16.h wcl $(FLAGS) -c $(SRC)test2.c pcxtest.obj: $(SRC)pcxtest.c $(SRCLIB)modex16.h - wcl $(FLAGS) -c $(SRC)pcxtest.c - + wcl $(FLAGS) -c $(SRC)pcxtest.c + palettec.obj: $(SRC)palettec.c - wcl $(FLAGS) -c $(SRC)palettec.c + wcl $(FLAGS) -c $(SRC)palettec.c + +maptest.obj: $(SRC)maptest.c $(SRCLIB)modex16.h + wcl $(FLAGS) -c $(SRC)maptest.c -maptest.obj: $(SRC)maptest.c $(SRCLIB)modex16.h - wcl $(FLAGS) -c $(SRC)maptest.c - maptest0.obj: $(SRC)maptest0.c# $(SRCLIB)modex16.h - wcl $(FLAGS) $(MFLAGS) -c $(SRC)maptest0.c - + wcl $(FLAGS) $(MFLAGS) -c $(SRC)maptest0.c + emmtest.obj: $(SRC)emmtest.c wcl $(FLAGS) $(MFLAGS) -c $(SRC)emmtest.c - + emsdump.obj: $(SRC)emsdump.c - wcl $(FLAGS) $(MFLAGS) -c $(SRC)emsdump.c - + wcl $(FLAGS) $(MFLAGS) -c $(SRC)emsdump.c + fmemtest.obj: $(SRC)fmemtest.c - wcl $(FLAGS) $(MFLAGS) -c $(SRC)fmemtest.c - -# -#non executable objects libraries + wcl $(FLAGS) $(MFLAGS) -c $(SRC)fmemtest.c + +# +#non executable objects libraries # modex16.obj: $(SRCLIB)modex16.h $(SRCLIB)modex16.c wcl $(FLAGS) -c $(SRCLIB)modex16.c @@ -99,17 +108,17 @@ bitmap.obj: $(SRCLIB)bitmap.h $(SRCLIB)bitmap.c wcl $(FLAGS) -c $(SRCLIB)bitmap.c planar.obj: $(SRCLIB)planar.h $(SRCLIB)planar.c - wcl $(FLAGS) -c $(SRCLIB)planar.c - + wcl $(FLAGS) -c $(SRCLIB)planar.c + scroll16.obj: $(SRCLIB)scroll16.h $(SRCLIB)scroll16.c - wcl $(FLAGS) -c $(SRCLIB)scroll16.c - + wcl $(FLAGS) -c $(SRCLIB)scroll16.c + wcpu.obj: $(WCPULIB)wcpu.h $(WCPULIB)wcpu.c - wcl $(FLAGS) -c $(WCPULIB)wcpu.c + wcl $(FLAGS) -c $(WCPULIB)wcpu.c mapread.obj: $(SRCLIB)mapread.h $(SRCLIB)mapread.c - wcl $(FLAGS) -c $(SRCLIB)mapread.c - + wcl $(FLAGS) -c $(SRCLIB)mapread.c + fmapread.obj: $(SRCLIB)fmapread.h $(SRCLIB)fmapread.c wcl $(FLAGS) $(MFLAGS) -c $(SRCLIB)fmapread.c @@ -117,16 +126,16 @@ lib_head.obj: $(SRCLIB)lib_head.h $(SRCLIB)lib_head.c wcl $(FLAGS) -c $(SRCLIB)lib_head.c jsmn.obj: $(JSMNLIB)jsmn.h $(JSMNLIB)jsmn.c - wcl $(FLAGS) -c $(JSMNLIB)jsmn.c - + wcl $(FLAGS) -c $(JSMNLIB)jsmn.c + farjsmn.obj: $(JSMNLIB)farjsmn.h $(JSMNLIB)farjsmn.c wcl $(FLAGS) $(MFLAGS) -c $(JSMNLIB)farjsmn.c - + memory.obj: $(EXMMLIB)memory.h $(EXMMLIB)memory.c - wcl $(FLAGS) $(MFLAGS) -c $(EXMMLIB)memory.c - -# -#other~ + wcl $(FLAGS) $(MFLAGS) -c $(EXMMLIB)memory.c + +# +#other~ # clean: .symbolic # @$(REMOVECOMMAND) *.obj diff --git a/src/FTEST.C b/src/FTEST.C new file mode 100644 index 00000000..5f7efa80 --- /dev/null +++ b/src/FTEST.C @@ -0,0 +1,56 @@ +#include +#include "lib/types.h" +#include "lib/text.h" + +main() { + int i; + int j; + char l[16]; + char c; + word s, o; + word addr = (word) l; + textInit(); + + //print the addresses of the fonts + printf("ROM FONT Addresses\n"); + for(i=0; i<4; i++) { + printf("%d: %x:%x\n", i, romFonts[i].seg, romFonts[i].off); + } + + printf("Character: "); + scanf("%c", &c); + + s=romFonts[ROM_FONT_8x16].seg; + o=romFonts[ROM_FONT_8x16].off; + + //load the letter 'A' + __asm { + MOV DI, addr + MOV SI, o + MOV ES, s + SUB BH, BH + MOV BL, c ; the letter + SHL BX, 1 + SHL BX, 1 + SHL BX, 1 + SHL BX, 1 + ADD SI, BX ;the address of A + MOV CX, 16 + L1: MOV AX, ES:SI + MOV DS:DI, AX + INC SI + INC DI + DEC CX + JNZ L1 + } + + //render the letter in ascii art + for(i=0; i<16; i++) { + j=1<<8; + while(j) { + printf("%c", l[i] & j ? '*':' '); + j>>=1; + } + printf("\n"); + } +} diff --git a/src/lib/TEXT.C b/src/lib/TEXT.C new file mode 100644 index 00000000..107f8e94 --- /dev/null +++ b/src/lib/TEXT.C @@ -0,0 +1,37 @@ +#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; +} diff --git a/src/lib/TEXT.H b/src/lib/TEXT.H new file mode 100644 index 00000000..98c3b904 --- /dev/null +++ b/src/lib/TEXT.H @@ -0,0 +1,28 @@ +/* + * 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 diff --git a/src/lib/types.h b/src/lib/types.h index fa880848..2055c20c 100644 --- a/src/lib/types.h +++ b/src/lib/types.h @@ -1,37 +1,37 @@ -/* 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 , or - * write to the Free Software Foundation, Inc., 51 Franklin Street, - * Fifth Floor, Boston, MA 02110-1301 USA. - * - */ +/* 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 , or + * write to the Free Software Foundation, Inc., 51 Franklin Street, + * Fifth Floor, Boston, MA 02110-1301 USA. + * + */ /* * Just some handy typedefs that make it easier to think about the low * level code - */ - -#ifndef _TYPE_H_ -#define _TYPE_H_ + */ + +#ifndef _TYPE_H_ +#define _TYPE_H_ typedef unsigned char byte; typedef unsigned short word; typedef unsigned long dword; typedef signed char sbyte; typedef signed short sword; -typedef signed long sdword; - -#endif/*_TYPE_H_*/ +typedef signed long sdword; + +#endif/*_TYPE_H_*/