]> 4ch.mooo.com Git - 16.git/commitdiff
update tesuto.c to latest VRL demo code. sprite drawing just got a bit faster.
authorJonathan Campbell <jonathan@castus.tv>
Fri, 18 Mar 2016 11:00:49 +0000 (04:00 -0700)
committerJonathan Campbell <jonathan@castus.tv>
Fri, 18 Mar 2016 11:00:49 +0000 (04:00 -0700)
also stretching is demonstrated. good luck Sparky.

src/tesuto.c
src/tesuto.h

index 82965a8193d9a37f9fd60e741291dca6376e6a1a..f309c143405349b6f9d2191995a1d41ef8a2c81f 100755 (executable)
@@ -1,75 +1,10 @@
 #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
-#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 unsigned char palette[768];\r
 \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
+       struct vrl1_vgax_header *vrl_header;\r
+       vrl1_vgax_offset_t *vrl_lineoffs;\r
        unsigned char *buffer;\r
        unsigned int bufsz;\r
        int fd;\r
@@ -86,7 +21,7 @@ int main(int argc,char **argv) {
        }\r
        {\r
                unsigned long sz = lseek(fd,0,SEEK_END);\r
-               if (sz < sizeof(vrl_header)) return 1;\r
+               if (sz < sizeof(*vrl_header)) return 1;\r
                if (sz >= 65535UL) return 1;\r
 \r
                bufsz = (unsigned int)sz;\r
@@ -96,7 +31,7 @@ int main(int argc,char **argv) {
                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
+               vrl_header = (struct vrl1_vgax_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
@@ -123,14 +58,18 @@ int main(int argc,char **argv) {
                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
+       /* preprocess the sprite to generate line offsets */\r
+       vrl_lineoffs = vrl1_vgax_genlineoffsets(vrl_header,buffer+sizeof(*vrl_header),bufsz-sizeof(*vrl_header));\r
+       if (vrl_lineoffs == NULL) return 1;\r
+\r
+       draw_vrl1_vgax_modex(0,0,vrl_header,vrl_lineoffs,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
+                       draw_vrl1_vgax_modex(i,0,vrl_header,vrl_lineoffs,buffer+sizeof(*vrl_header),bufsz-sizeof(*vrl_header));\r
        }\r
        while (getch() != 13);\r
 \r
@@ -138,13 +77,30 @@ int main(int argc,char **argv) {
                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
+                       draw_vrl1_vgax_modex(i,i,vrl_header,vrl_lineoffs,buffer+sizeof(*vrl_header),bufsz-sizeof(*vrl_header));\r
+       }\r
+       while (getch() != 13);\r
+\r
+       {\r
+               unsigned int i;\r
+\r
+               for (i=(2 << 6)/*200%*/;i >= (1 << 4)/*25%*/;i--)\r
+                       draw_vrl1_vgax_modexstretch(0,0,i,vrl_header,vrl_lineoffs,buffer+sizeof(*vrl_header),bufsz-sizeof(*vrl_header));\r
+       }\r
+       while (getch() != 13);\r
+       {\r
+               unsigned int i;\r
+\r
+               for (i=(2 << 6)/*200%*/;i >= (1 << 4)/*25%*/;i--)\r
+                       draw_vrl1_vgax_modexystretch(0,0,i,i,vrl_header,vrl_lineoffs,buffer+sizeof(*vrl_header),bufsz-sizeof(*vrl_header));\r
        }\r
        while (getch() != 13);\r
 \r
        int10_setmode(3);\r
+       free(vrl_lineoffs);\r
        buffer = NULL;\r
        free(buffer);\r
        bufsz = 0;\r
        return 0;\r
 }\r
+\r
index 8703081de59879c4690222b33df0fcc9d128dcb3..ffa164042e0c64f4a4d75191c45b22496dffec17 100755 (executable)
@@ -3,16 +3,8 @@
 
 #include "src/lib/16_head.h"
 #include "src/lib/doslib/hw/cpu/cpu.h"
-#include "src/lib/doslib/hw/vga/vga.h"
 #include "src/lib/doslib/hw/dos/dos.h"
+#include "src/lib/doslib/hw/vga/vga.h"
+#include "src/lib/doslib/hw/vga/vrl.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