]> 4ch.mooo.com Git - 16.git/commitdiff
tesuto is vrl draw now ww
authorsparky4 <sparky4@cock.li>
Fri, 18 Mar 2016 15:15:19 +0000 (10:15 -0500)
committersparky4 <sparky4@cock.li>
Fri, 18 Mar 2016 15:15:19 +0000 (10:15 -0500)
makefile
src/tesuto.c
src/tesuto.h [new file with mode: 0755]

index b1ca6b2ee32aa66763ec5b4933f0093a9a7ea43b..b9a57562d71e03555105224f683ad22d5eb34172 100755 (executable)
--- a/makefile
+++ b/makefile
@@ -112,14 +112,14 @@ scroll.$(OBJ): $(SRC)scroll.c
 
 
 # NOTE: dos86h = 16-bit huge memory model. memory model must match!
-tesuto.exe: tesuto.$(OBJ) dl_vga.lib
+tesuto.exe: tesuto.$(OBJ) dl_vga.lib 16_head.$(OBJ)
 #      %write tmp.cmd option quiet option map=tesuto.map $(DOSLIB_LDFLAGS_DOS16H) file tesuto.obj name tesuto.exe
 #      %write tmp.cmd library $(DOSLIBDIR)/hw/cpu/dos86h/cpu.lib
 #      %write tmp.cmd library $(DOSLIBDIR)/hw/dos/dos86h/dos.lib
 #      @wlink @tmp.cmd
-       wcl $(WCLQ) tesuto.$(OBJ) dl_vga.lib
+       wcl $(FLAGS) $(WCLQ) tesuto.$(OBJ) dl_vga.lib 16_head.$(OBJ)
 tesuto.$(OBJ): $(SRC)tesuto.c
-       wcl $(WCLQ) -c $(SRC)tesuto.c
+       wcl $(FLAGS) $(WCLQ) -c $(SRC)tesuto.c
 #tesuto.exe: tesuto.$(OBJ)
 #      wcl $(WCLQ) -mh -d2 tesuto.$(OBJ)
 #tesuto.$(OBJ): $(SRC)tesuto.c
index b05591daa850d4dd335d8b64edf4033fd4750c15..82965a8193d9a37f9fd60e741291dca6376e6a1a 100755 (executable)
+#include "src/tesuto.h"\r
+/*\r
 #include <stdio.h>\r
+#include <conio.h> // this is where Open Watcom hides the outp() etc. functions\r
+#include <ctype.h>\r
+#include <stdlib.h>\r
+#include <unistd.h>\r
+#include <assert.h>\r
+#include <fcntl.h>\r
+#include <math.h>\r
+#include <dos.h>\r
+*/\r
 \r
-/*typedef unsigned char far *VGA_RAM_PTR;\r
-VGA_RAM_PTR vga_graphics_ram = (VGA_RAM_PTR)MK_FP(0xA000,0x0000);\r
-unsigned char vga_stride = 80; // 80 x 4 = 320 for 320-pixel wide modes\r
+#pragma pack(push,1)\r
+struct vrl_header {\r
+       uint8_t                 vrl_sig[4];             // +0x00  "VRL1"\r
+       uint8_t                 fmt_sig[4];             // +0x04  "VGAX"\r
+       uint16_t                height;                 // +0x08  Sprite height\r
+       uint16_t                width;                  // +0x0A  Sprite width\r
+       int16_t                 hotspot_x;              // +0x0C  Hotspot offset (X) for programmer's reference\r
+       int16_t                 hotspot_y;              // +0x0E  Hotspot offset (Y) for programmer's reference\r
+};                                                     // =0x10\r
+#pragma pack(pop)\r
 \r
-static inline void vga_write_sequencer(unsigned char i,unsigned char c) {\r
-    outp(0x3C4,i);\r
-    outp(0x3C5,c);\r
-}*/\r
+static unsigned char palette[768];\r
 \r
-void main()\r
-{\r
-       printf("pee\n");\r
+void draw_vrl_modex(unsigned int x,unsigned int y,struct vrl_header *hdr,unsigned char *data,unsigned int datasz) {\r
+       unsigned int vram_offset = (y * vga_stride) + (x >> 2);\r
+       unsigned char *fence = data + datasz;\r
+       unsigned char vga_plane = (x & 3);\r
+       unsigned char run,skip,b;\r
+       unsigned char far *draw;\r
+\r
+       while (data < fence) {\r
+               /* start of another vertical strip */\r
+               draw = vga_graphics_ram + vram_offset;\r
+               vga_write_sequencer(0x02/*map mask*/,1 << vga_plane);\r
+\r
+               while (data < fence) {\r
+                       run = *data++;\r
+                       if (run == 0xFF) break;\r
+                       skip = *data++;\r
+                       draw += skip * vga_stride;\r
+                       if (run & 0x80) {\r
+                               b = *data++;\r
+                               while (run > 0x80) {\r
+                                       *draw = b;\r
+                                       draw += vga_stride;\r
+                                       run--;\r
+                               }\r
+                       }\r
+                       else {\r
+                               while (run > 0) {\r
+                                       *draw = *data++;\r
+                                       draw += vga_stride;\r
+                                       run--;\r
+                               }\r
+                       }\r
+               }\r
+\r
+               /* end of a vertical strip. next line? */\r
+               if ((++vga_plane) == 4) {\r
+                       vram_offset++;\r
+                       vga_plane = 0;\r
+               }\r
+       }\r
+\r
+       vga_write_sequencer(0x02/*map mask*/,0xF);\r
+}\r
+\r
+int main(int argc,char **argv) {\r
+       struct vrl_header *vrl_header;\r
+       unsigned char *buffer;\r
+       unsigned int bufsz;\r
+       int fd;\r
+\r
+       if (argc < 3) {\r
+               fprintf(stderr,"drawvrl <VRL file> <palette file>\n");\r
+               return 1;\r
+       }\r
+\r
+       fd = open(argv[1],O_RDONLY|O_BINARY);\r
+       if (fd < 0) {\r
+               fprintf(stderr,"Unable to open '%s'\n",argv[1]);\r
+               return 1;\r
+       }\r
+       {\r
+               unsigned long sz = lseek(fd,0,SEEK_END);\r
+               if (sz < sizeof(vrl_header)) return 1;\r
+               if (sz >= 65535UL) return 1;\r
+\r
+               bufsz = (unsigned int)sz;\r
+               buffer = malloc(bufsz);\r
+               if (buffer == NULL) return 1;\r
+\r
+               lseek(fd,0,SEEK_SET);\r
+               if ((unsigned int)read(fd,buffer,bufsz) < bufsz) return 1;\r
+\r
+               vrl_header = (struct vrl_header*)buffer;\r
+               if (memcmp(vrl_header->vrl_sig,"VRL1",4) || memcmp(vrl_header->fmt_sig,"VGAX",4)) return 1;\r
+               if (vrl_header->width == 0 || vrl_header->height == 0) return 1;\r
+       }\r
+       close(fd);\r
+\r
+       probe_dos();\r
+       if (!probe_vga()) {\r
+               printf("VGA probe failed\n");\r
+               return 1;\r
+       }\r
+       int10_setmode(19);\r
+       update_state_from_vga();\r
+       vga_enable_256color_modex(); // VGA mode X\r
+\r
+       /* load color palette */\r
+       fd = open(argv[2],O_RDONLY|O_BINARY);\r
+       if (fd >= 0) {\r
+               unsigned int i;\r
+\r
+               read(fd,palette,768);\r
+               close(fd);\r
+\r
+               vga_palette_lseek(0);\r
+               for (i=0;i < 256;i++) vga_palette_write(palette[(i*3)+0]>>2,palette[(i*3)+1]>>2,palette[(i*3)+2]>>2);\r
+       }\r
+\r
+       draw_vrl_modex(0,0,vrl_header,buffer+sizeof(*vrl_header),bufsz-sizeof(*vrl_header));\r
+       while (getch() != 13);\r
+\r
+       {\r
+               unsigned int i;\r
+\r
+               for (i=1;i < 320;i++)\r
+                       draw_vrl_modex(i,0,vrl_header,buffer+sizeof(*vrl_header),bufsz-sizeof(*vrl_header));\r
+       }\r
+       while (getch() != 13);\r
+\r
+       {\r
+               unsigned int i;\r
+\r
+               for (i=1;i < 200;i++)\r
+                       draw_vrl_modex(i,i,vrl_header,buffer+sizeof(*vrl_header),bufsz-sizeof(*vrl_header));\r
+       }\r
+       while (getch() != 13);\r
+\r
+       int10_setmode(3);\r
+       buffer = NULL;\r
+       free(buffer);\r
+       bufsz = 0;\r
+       return 0;\r
 }\r
diff --git a/src/tesuto.h b/src/tesuto.h
new file mode 100755 (executable)
index 0000000..ea627b6
--- /dev/null
@@ -0,0 +1,15 @@
+#ifndef __TESUTO_H__
+#define __TESUTO_H__
+
+#include "src/lib/16_head.h"
+#include "src/lib/doslib/hw/vga/vga.h"
+
+typedef unsigned char far *VGA_RAM_PTR;
+VGA_RAM_PTR vga_graphics_ram = (VGA_RAM_PTR)MK_FP(0xA000,0x0000);
+unsigned char vga_stride = 80; // 80 x 4 = 320 for 320-pixel wide modes
+
+static inline void vga_write_sequencer(unsigned char i,unsigned char c) {
+    outp(0x3C4,i);
+    outp(0x3C5,c);
+}
+#endif