wwww
リビジョン | 2c1fce4c0aa30b61960d00e1f95c01214106fe56 (tree) |
---|---|
日時 | 2016-03-19 00:15:19 |
作者 | sparky4 <sparky4@cock...> |
コミッター | sparky4 |
tesuto is vrl draw now ww
@@ -112,14 +112,14 @@ scroll.$(OBJ): $(SRC)scroll.c | ||
112 | 112 | |
113 | 113 | |
114 | 114 | # NOTE: dos86h = 16-bit huge memory model. memory model must match! |
115 | -tesuto.exe: tesuto.$(OBJ) dl_vga.lib | |
115 | +tesuto.exe: tesuto.$(OBJ) dl_vga.lib 16_head.$(OBJ) | |
116 | 116 | # %write tmp.cmd option quiet option map=tesuto.map $(DOSLIB_LDFLAGS_DOS16H) file tesuto.obj name tesuto.exe |
117 | 117 | # %write tmp.cmd library $(DOSLIBDIR)/hw/cpu/dos86h/cpu.lib |
118 | 118 | # %write tmp.cmd library $(DOSLIBDIR)/hw/dos/dos86h/dos.lib |
119 | 119 | # @wlink @tmp.cmd |
120 | - wcl $(WCLQ) tesuto.$(OBJ) dl_vga.lib | |
120 | + wcl $(FLAGS) $(WCLQ) tesuto.$(OBJ) dl_vga.lib 16_head.$(OBJ) | |
121 | 121 | tesuto.$(OBJ): $(SRC)tesuto.c |
122 | - wcl $(WCLQ) -c $(SRC)tesuto.c | |
122 | + wcl $(FLAGS) $(WCLQ) -c $(SRC)tesuto.c | |
123 | 123 | #tesuto.exe: tesuto.$(OBJ) |
124 | 124 | # wcl $(WCLQ) -mh -d2 tesuto.$(OBJ) |
125 | 125 | #tesuto.$(OBJ): $(SRC)tesuto.c |
@@ -1,15 +1,150 @@ | ||
1 | +#include "src/tesuto.h" | |
2 | +/* | |
1 | 3 | #include <stdio.h> |
4 | +#include <conio.h> // this is where Open Watcom hides the outp() etc. functions | |
5 | +#include <ctype.h> | |
6 | +#include <stdlib.h> | |
7 | +#include <unistd.h> | |
8 | +#include <assert.h> | |
9 | +#include <fcntl.h> | |
10 | +#include <math.h> | |
11 | +#include <dos.h> | |
12 | +*/ | |
2 | 13 | |
3 | -/*typedef unsigned char far *VGA_RAM_PTR; | |
4 | -VGA_RAM_PTR vga_graphics_ram = (VGA_RAM_PTR)MK_FP(0xA000,0x0000); | |
5 | -unsigned char vga_stride = 80; // 80 x 4 = 320 for 320-pixel wide modes | |
14 | +#pragma pack(push,1) | |
15 | +struct vrl_header { | |
16 | + uint8_t vrl_sig[4]; // +0x00 "VRL1" | |
17 | + uint8_t fmt_sig[4]; // +0x04 "VGAX" | |
18 | + uint16_t height; // +0x08 Sprite height | |
19 | + uint16_t width; // +0x0A Sprite width | |
20 | + int16_t hotspot_x; // +0x0C Hotspot offset (X) for programmer's reference | |
21 | + int16_t hotspot_y; // +0x0E Hotspot offset (Y) for programmer's reference | |
22 | +}; // =0x10 | |
23 | +#pragma pack(pop) | |
6 | 24 | |
7 | -static inline void vga_write_sequencer(unsigned char i,unsigned char c) { | |
8 | - outp(0x3C4,i); | |
9 | - outp(0x3C5,c); | |
10 | -}*/ | |
25 | +static unsigned char palette[768]; | |
11 | 26 | |
12 | -void main() | |
13 | -{ | |
14 | - printf("pee\n"); | |
27 | +void draw_vrl_modex(unsigned int x,unsigned int y,struct vrl_header *hdr,unsigned char *data,unsigned int datasz) { | |
28 | + unsigned int vram_offset = (y * vga_stride) + (x >> 2); | |
29 | + unsigned char *fence = data + datasz; | |
30 | + unsigned char vga_plane = (x & 3); | |
31 | + unsigned char run,skip,b; | |
32 | + unsigned char far *draw; | |
33 | + | |
34 | + while (data < fence) { | |
35 | + /* start of another vertical strip */ | |
36 | + draw = vga_graphics_ram + vram_offset; | |
37 | + vga_write_sequencer(0x02/*map mask*/,1 << vga_plane); | |
38 | + | |
39 | + while (data < fence) { | |
40 | + run = *data++; | |
41 | + if (run == 0xFF) break; | |
42 | + skip = *data++; | |
43 | + draw += skip * vga_stride; | |
44 | + if (run & 0x80) { | |
45 | + b = *data++; | |
46 | + while (run > 0x80) { | |
47 | + *draw = b; | |
48 | + draw += vga_stride; | |
49 | + run--; | |
50 | + } | |
51 | + } | |
52 | + else { | |
53 | + while (run > 0) { | |
54 | + *draw = *data++; | |
55 | + draw += vga_stride; | |
56 | + run--; | |
57 | + } | |
58 | + } | |
59 | + } | |
60 | + | |
61 | + /* end of a vertical strip. next line? */ | |
62 | + if ((++vga_plane) == 4) { | |
63 | + vram_offset++; | |
64 | + vga_plane = 0; | |
65 | + } | |
66 | + } | |
67 | + | |
68 | + vga_write_sequencer(0x02/*map mask*/,0xF); | |
69 | +} | |
70 | + | |
71 | +int main(int argc,char **argv) { | |
72 | + struct vrl_header *vrl_header; | |
73 | + unsigned char *buffer; | |
74 | + unsigned int bufsz; | |
75 | + int fd; | |
76 | + | |
77 | + if (argc < 3) { | |
78 | + fprintf(stderr,"drawvrl <VRL file> <palette file>\n"); | |
79 | + return 1; | |
80 | + } | |
81 | + | |
82 | + fd = open(argv[1],O_RDONLY|O_BINARY); | |
83 | + if (fd < 0) { | |
84 | + fprintf(stderr,"Unable to open '%s'\n",argv[1]); | |
85 | + return 1; | |
86 | + } | |
87 | + { | |
88 | + unsigned long sz = lseek(fd,0,SEEK_END); | |
89 | + if (sz < sizeof(vrl_header)) return 1; | |
90 | + if (sz >= 65535UL) return 1; | |
91 | + | |
92 | + bufsz = (unsigned int)sz; | |
93 | + buffer = malloc(bufsz); | |
94 | + if (buffer == NULL) return 1; | |
95 | + | |
96 | + lseek(fd,0,SEEK_SET); | |
97 | + if ((unsigned int)read(fd,buffer,bufsz) < bufsz) return 1; | |
98 | + | |
99 | + vrl_header = (struct vrl_header*)buffer; | |
100 | + if (memcmp(vrl_header->vrl_sig,"VRL1",4) || memcmp(vrl_header->fmt_sig,"VGAX",4)) return 1; | |
101 | + if (vrl_header->width == 0 || vrl_header->height == 0) return 1; | |
102 | + } | |
103 | + close(fd); | |
104 | + | |
105 | + probe_dos(); | |
106 | + if (!probe_vga()) { | |
107 | + printf("VGA probe failed\n"); | |
108 | + return 1; | |
109 | + } | |
110 | + int10_setmode(19); | |
111 | + update_state_from_vga(); | |
112 | + vga_enable_256color_modex(); // VGA mode X | |
113 | + | |
114 | + /* load color palette */ | |
115 | + fd = open(argv[2],O_RDONLY|O_BINARY); | |
116 | + if (fd >= 0) { | |
117 | + unsigned int i; | |
118 | + | |
119 | + read(fd,palette,768); | |
120 | + close(fd); | |
121 | + | |
122 | + vga_palette_lseek(0); | |
123 | + for (i=0;i < 256;i++) vga_palette_write(palette[(i*3)+0]>>2,palette[(i*3)+1]>>2,palette[(i*3)+2]>>2); | |
124 | + } | |
125 | + | |
126 | + draw_vrl_modex(0,0,vrl_header,buffer+sizeof(*vrl_header),bufsz-sizeof(*vrl_header)); | |
127 | + while (getch() != 13); | |
128 | + | |
129 | + { | |
130 | + unsigned int i; | |
131 | + | |
132 | + for (i=1;i < 320;i++) | |
133 | + draw_vrl_modex(i,0,vrl_header,buffer+sizeof(*vrl_header),bufsz-sizeof(*vrl_header)); | |
134 | + } | |
135 | + while (getch() != 13); | |
136 | + | |
137 | + { | |
138 | + unsigned int i; | |
139 | + | |
140 | + for (i=1;i < 200;i++) | |
141 | + draw_vrl_modex(i,i,vrl_header,buffer+sizeof(*vrl_header),bufsz-sizeof(*vrl_header)); | |
142 | + } | |
143 | + while (getch() != 13); | |
144 | + | |
145 | + int10_setmode(3); | |
146 | + buffer = NULL; | |
147 | + free(buffer); | |
148 | + bufsz = 0; | |
149 | + return 0; | |
15 | 150 | } |
@@ -0,0 +1,15 @@ | ||
1 | +#ifndef __TESUTO_H__ | |
2 | +#define __TESUTO_H__ | |
3 | + | |
4 | +#include "src/lib/16_head.h" | |
5 | +#include "src/lib/doslib/hw/vga/vga.h" | |
6 | + | |
7 | +typedef unsigned char far *VGA_RAM_PTR; | |
8 | +VGA_RAM_PTR vga_graphics_ram = (VGA_RAM_PTR)MK_FP(0xA000,0x0000); | |
9 | +unsigned char vga_stride = 80; // 80 x 4 = 320 for 320-pixel wide modes | |
10 | + | |
11 | +static inline void vga_write_sequencer(unsigned char i,unsigned char c) { | |
12 | + outp(0x3C4,i); | |
13 | + outp(0x3C5,c); | |
14 | +} | |
15 | +#endif |