/* Project 16 Source Code~\r
- * Copyright (C) 2012-2015 sparky4 & pngwen & andrius4669\r
+ * Copyright (C) 2012-2016 sparky4 & pngwen & andrius4669 & joncampbell123\r
*\r
* This file is part of Project 16.\r
*\r
//#include "lib/16text.h"\r
#include "lib/modex16.h"\r
\r
+#include <hw/cpu/cpu.h>\r
+#include <hw/dos/dos.h>\r
+#include <hw/vga/vga.h>\r
+\r
+global_game_variables_t gvar;\r
+\r
void main(int argc, char near *argv[])\r
{\r
//JMOJI\r
static byte e;\r
//word ri;\r
- byte pee[2];\r
- page_t screen;\r
+ byte pee[6]; // must be large enough for sprintf("%zc",...) and sprintf("%u",(byte value))\r
static byte ibmlogo[]="IIIIIII BBBBBBBBB MMMMM MMMMM\n\\r
IIIIIII BBBBBBBBBBB MMMMMM MMMMMM\n\\r
III BBB BBB MMMMMM MMMMMM\n\\r
IIIIIII BBBBBBBBBBB MMMM MMM MMMM\n\\r
IIIIIII BBBBBBBBB MMMM M MMMM\n\\r
";\r
- static byte rose[]=" :. ,..\\r
- .' :~.':_.,\\r
- .' ::.::'.'\\r
- : ::' .:\\r
- `.: .: .:/\\r
- `::--.:'.::'\\r
- |. _:===-'\\r
- / /\\r
- ,---.---. __,','\\r
- (~`. \ ) )','.,---..\\r
- `v`\ | ,' .-'.:,'_____ `.\\r
- )|/.-~.--~~--. ~~~-. \\\r
- _/-'_.-~ ""---.._`.|\\r
- _.-~~_.-~ ""'\\r
- _..--~~_.(~~\\r
- __...---~~~_..--~~\\r
-,'___...---~~~\\r
+ static byte rose[]=" :. ,..\n\\r
+ .' :~.':_.,\n\\r
+ .' ::.::'.'\n\\r
+ : ::' .:\n\\r
+ `.: .: .:/\n\\r
+ `::--.:'.::'\n\\r
+ |. _:===-'\n\\r
+ / /\n\\r
+ ,---.---. __,','\n\\r
+ (~`. \ ) )','.,---..\n\\r
+ `v`\ | ,' .-'.:,'_____ `.\n\\r
+ )|/.-~.--~~--. ~~~-. \ \n\\r
+ _/-'_.-~ ""---.._`.|\n\\r
+ _.-~~_.-~ ""'\n\\r
+ _..--~~_.(~~\n\\r
+ __...---~~~_..--~~\n\\r
+,'___...---~~~\n\\r
";\r
// static byte *rosa;\r
- static word chx, chy, colpee;\r
+ static word chx, chy, colpee, addr;\r
textInit();\r
- modexEnter();\r
+\r
+ // DOSLIB: check our environment\r
+ probe_dos();\r
+\r
+ // DOSLIB: what CPU are we using?\r
+ // NTS: I can see from the makefile Sparky4 intends this to run on 8088 by the -0 switch in CFLAGS.\r
+ // So this code by itself shouldn't care too much what CPU it's running on. Except that other\r
+ // parts of this project (DOSLIB itself) rely on CPU detection to know what is appropriate for\r
+ // the CPU to carry out tasks. --J.C.\r
+ cpu_probe();\r
+\r
+ // DOSLIB: check for VGA\r
+ if (!probe_vga()) {\r
+ printf("VGA probe failed\n");\r
+ return;\r
+ }\r
+ // hardware must be VGA or higher!\r
+ if (!(vga_state.vga_flags & VGA_IS_VGA)) {\r
+ printf("This program requires VGA or higher graphics hardware\n");\r
+ return;\r
+ }\r
+ VGAmodeX(1, 1, &gvar);\r
/* setup camera and screen~ */\r
- screen = modexDefaultPage();\r
- screen.width += (16*2);\r
- screen.height += (16*2);\r
+ gvar.video.page[0] = modexDefaultPage(&gvar.video.page[0]);\r
+ gvar.video.page[0].width += (16*2);\r
+ gvar.video.page[0].height += (16*2);\r
+ modexShowPage(&gvar.video.page[0]);\r
+ // NTS: We're in Mode-X now. printf() is useless. Do not use printf(). Or INT 10h text printing. Or DOS console output.\r
//modexprint(16, 16, 1, 15, "wwww");\r
//getch();\r
chx=0;\r
chy=0;\r
colpee=32;\r
+// bios_cls();\r
+ /* position the cursor to home */\r
+// vga_moveto(0,0);\r
+// vga_sync_bios_cursor();\r
for(e=0x00; e<=0xFE; e++)\r
{\r
- if(chx+8>(SCREEN_WIDTH/2)-16)\r
+ if(chx+8>(gvar.video.page[0].width/2))\r
{\r
chx=0;\r
chy+=8;\r
sprintf(pee,"%u", colpee);\r
- modexprint(&screen, 200, 200, 1, 47, 0, &pee);\r
+ modexprint(&gvar.video.page[0], 200, 200, 1, 47, 0, &pee);\r
//getch();\r
}\r
- modexprint(&screen, chx, chy, 1, 0, colpee, &e);\r
- chx+=9;\r
+ sprintf(pee, "%zc", e);\r
+ modexprint(&gvar.video.page[0], chx, chy, 1, 0, colpee, &e);\r
+ chx+=8;\r
colpee++;\r
if(colpee>=32+24) colpee=32;\r
}\r
- //modexprint(100, 100, 1, 47, 0, "wwww");\r
getch();\r
+ modexprint(&gvar.video.page[0], gvar.video.page[0].width - (8*16)/*HACK: The rose ASCII is too wide for 320x240 so offset it to make sure the petals are visible*/, 8, 1, 45, 0, &rose);\r
+ getch();\r
+ //modexprint(100, 100, 1, 47, 0, "wwww");\r
// modexprint(0, 0, 1, 0, colpee, &rose);\r
- modexprint(&screen, 0, 0, 0, 0, colpee, &ibmlogo);\r
+//++++ modexprint(&gvar.video.page[0], 0, 0, 0, 0, colpee, &ibmlogo);\r
+// modexprintbig(&gvar.video.page[0], 0, 0, 1, colpee, 0, "IBM");\r
// modexprint(0, 0, 1, 0, colpee, ROSE);\r
- getch();\r
- modexLeave();\r
+//++++ getch();\r
+ VGAmodeX(0, 1, &gvar);\r
// rosa=malloc(sizeof(ROSE));\r
// (*rosa)=(byte)ROSE;\r
printf("\n%s\n", rose);\r