From: Jonathan Campbell Date: Fri, 18 Mar 2016 10:07:24 +0000 (-0700) Subject: Merge remote-tracking branch 'upstream/master' X-Git-Url: http://4ch.mooo.com/gitweb/?a=commitdiff_plain;h=f1b47ff4240cf37aaf64b01f7f57a4d908058857;hp=b673eb589dee543a4dd0cbe2eb6fda1994e99aca;p=16.git Merge remote-tracking branch 'upstream/master' --- diff --git a/dlmkfile b/dlmkfile new file mode 100755 index 00000000..e47a14cc --- /dev/null +++ b/dlmkfile @@ -0,0 +1,56 @@ +# do not use GNU make. +# Only use Open Watcom WMAKE + +all: cpu16.exe cpu16h.exe cpu32.exe + +clean: .symbolic + rm -v *.exe *.obj *.map + +DOSLIBDIR=.. +!include $(DOSLIBDIR)/extdep.mak + +# library deps 16-bit large +$(DOSLIBDIR)/hw/cpu/dos86l/cpu.lib: + cd $(DOSLIBDIR)/hw/cpu && ./make.sh +$(DOSLIBDIR)/hw/dos/dos86l/dos.lib: + cd $(DOSLIBDIR)/hw/dos && ./make.sh + +# library deps 16-bit huge +$(DOSLIBDIR)/hw/cpu/dos86h/cpu.lib: + cd $(DOSLIBDIR)/hw/cpu && ./make.sh +$(DOSLIBDIR)/hw/dos/dos86h/dos.lib: + cd $(DOSLIBDIR)/hw/dos && ./make.sh + +# library deps 32-bit flat +$(DOSLIBDIR)/hw/cpu/dos386f/cpu.lib: + cd $(DOSLIBDIR)/hw/cpu && ./make.sh +$(DOSLIBDIR)/hw/dos/dos386f/dos.lib: + cd $(DOSLIBDIR)/hw/dos && ./make.sh + +# NOTE: dos86l = 16-bit large memory model. memory model must match! +cpu16.exe: cpu16.obj $(DOSLIBDIR)/hw/cpu/dos86l/cpu.lib $(DOSLIBDIR)/hw/dos/dos86l/dos.lib + %write tmp.cmd option quiet option map=cpu16.map $(DOSLIB_LDFLAGS_DOS16L) file cpu16.obj name cpu16.exe + %write tmp.cmd library $(DOSLIBDIR)/hw/cpu/dos86l/cpu.lib + %write tmp.cmd library $(DOSLIBDIR)/hw/dos/dos86l/dos.lib + @wlink @tmp.cmd +cpu16.obj: cpu.c + wcl $(FLAGS) -fo=cpu16.obj -ml $(DOSLIB_CFLAGS_DOS16L) -c cpu.c + +# NOTE: dos86h = 16-bit huge memory model. memory model must match! +cpu16h.exe: cpu16h.obj $(DOSLIBDIR)/hw/cpu/dos86h/cpu.lib $(DOSLIBDIR)/hw/dos/dos86h/dos.lib + %write tmp.cmd option quiet option map=cpu16h.map $(DOSLIB_LDFLAGS_DOS16H) file cpu16h.obj name cpu16h.exe + %write tmp.cmd library $(DOSLIBDIR)/hw/cpu/dos86h/cpu.lib + %write tmp.cmd library $(DOSLIBDIR)/hw/dos/dos86h/dos.lib + @wlink @tmp.cmd +cpu16h.obj: cpu.c + wcl $(FLAGS) -fo=cpu16h.obj -mh $(DOSLIB_CFLAGS_DOS16H) -c cpu.c + +# NOTE: dos386f = 32-bit flat memory model. memory model must match! +cpu32.exe: cpu32.obj $(DOSLIBDIR)/hw/cpu/dos386f/cpu.lib $(DOSLIBDIR)/hw/dos/dos386f/dos.lib + %write tmp.cmd option quiet option map=cpu32.map $(DOSLIB_LDFLAGS_DOS32) file cpu32.obj name cpu32.exe + %write tmp.cmd library $(DOSLIBDIR)/hw/cpu/dos386f/cpu.lib + %write tmp.cmd library $(DOSLIBDIR)/hw/dos/dos386f/dos.lib + @wlink @tmp.cmd +cpu32.obj: cpu.c + wcl386 $(FLAGS) -fo=cpu32.obj -mf $(DOSLIB_CFLAGS_DOS32) -c cpu.c + diff --git a/makefile b/makefile index 935fbefd..8d1771e3 100755 --- a/makefile +++ b/makefile @@ -58,6 +58,7 @@ MODEXLIB=$(SRCLIB)modex16$(DIRSEP) MODEXLIB_=$(SRCLIB)modex$(DIRSEP) VGMSNDLIB=$(SRCLIB)vgmsnd$(DIRSEP) DOSLIB=$(SRCLIB)doslib$(DIRSEP) +DOSLIBDIR=$(SRCLIB)doslib WCPULIB=$(SRCLIB)wcpu$(DIRSEP) WLIBQ=-q @@ -82,11 +83,15 @@ DOSLIBOBJ = adlib.$(OBJ) 8254.$(OBJ) 8259.$(OBJ) dos.$(OBJ) cpu.$(OBJ) GFXLIBOBJS = modex16.$(OBJ) bitmap.$(OBJ) planar.$(OBJ) 16text.$(OBJ) bakapee.$(OBJ) scroll16.$(OBJ) 16render.$(OBJ) 16planar.$(OBJ) +DOSLIBLIBS=dl_vga.lib dl_cpu.lib dl_dos.lib + TESTEXEC = exmmtest.exe test.exe pcxtest.exe pcxtest2.exe test2.exe palettec.exe maptest.exe fmemtest.exe fonttest.exe fontgfx.exe scroll.exe vgmtest.exe inputest.exe palettel.exe planrpcx.exe # tsthimem.exe #testemm.exe testemm0.exe fonttes0.exe miditest.exe sega.exe sountest.exe EXEC = 16.exe bakapi.exe $(TESTEXEC) tesuto.exe +!include $(DOSLIBDIR)/extdep.mak + all: $(EXEC) #$(16LIBOBJS) => 16.lib bug.... @@ -107,10 +112,20 @@ scroll.exe: scroll.$(OBJ) mapread.$(OBJ) jsmn.$(OBJ) $(16LIBOBJS) gfx.lib scroll.$(OBJ): $(SRC)scroll.c wcl $(FLAGS) -c $(SRC)scroll.c -tesuto.exe: tesuto.$(OBJ) - wcl $(WCLQ) -mh -d2 tesuto.$(OBJ) + +# NOTE: dos86h = 16-bit huge memory model. memory model must match! +tesuto.exe: tesuto.$(OBJ) $(DOSLIBLIBS) 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 $(FLAGS) $(WCLQ) tesuto.$(OBJ) $(DOSLIBLIBS) 16_head.$(OBJ) tesuto.$(OBJ): $(SRC)tesuto.c - wcl $(WCLQ) -mh -d2 -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 +# wcl $(WCLQ) -mh -d2 -c $(SRC)tesuto.c #sega.exe: sega.$(OBJ) # wcl $(FLAGS) sega.$(OBJ) @@ -282,6 +297,17 @@ doslib.lib: $(DOSLIBOBJ) # $(SRCLIB)cpu.lib vgmsnd.lib: $(VGMSNDOBJ) wlib -b $(WLIBQ) vgmsnd.lib $(VGMSNDOBJ) + +# library deps 16-bit huge +dl_vga.lib: + cd $(DOSLIBDIR)/hw/vga/dos86h && ./make.sh + +dl_cpu.lib: + cd $(DOSLIBDIR)/hw/cpu/dos86h && ./make.sh + +dl_dos.lib: + cd $(DOSLIBDIR)/hw/dos/dos86h && ./make.sh + modex16.$(OBJ): $(SRCLIB)modex16.h $(SRCLIB)modex16.c wcl $(FLAGS) -c $(SRCLIB)modex16.c @@ -395,12 +421,14 @@ clean: .symbolic @$(REMOVECOMMAND) *.$(OBJ) @$(REMOVECOMMAND) 16.lib @$(REMOVECOMMAND) gfx.lib - @$(REMOVECOMMAND) doslib.lib @$(REMOVECOMMAND) vgmsnd.lib + @$(REMOVECOMMAND) $(DOSLIBLIBS) @wlib -n $(WLIBQ) 16.lib @wlib -n $(WLIBQ) gfx.lib - @wlib -n $(WLIBQ) doslib.lib @wlib -n $(WLIBQ) vgmsnd.lib + @wlib -n $(WLIBQ) dl_cpu.lib + @wlib -n $(WLIBQ) dl_dos.lib + @wlib -n $(WLIBQ) dl_vga.lib @$(REMOVECOMMAND) *.16 @$(REMOVECOMMAND) *.16W @$(REMOVECOMMAND) *.16B diff --git a/src/lib/doslib b/src/lib/doslib index 36710d8b..3cd32ddb 160000 --- a/src/lib/doslib +++ b/src/lib/doslib @@ -1 +1 @@ -Subproject commit 36710d8b91d259ed353e537c17a387e737924469 +Subproject commit 3cd32ddbcd4e7802b346c08bf8dfa93c51229e89 diff --git a/src/tesuto.c b/src/tesuto.c index b05591da..82965a81 100755 --- a/src/tesuto.c +++ b/src/tesuto.c @@ -1,15 +1,150 @@ +#include "src/tesuto.h" +/* #include +#include // this is where Open Watcom hides the outp() etc. functions +#include +#include +#include +#include +#include +#include +#include +*/ -/*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 +#pragma pack(push,1) +struct vrl_header { + uint8_t vrl_sig[4]; // +0x00 "VRL1" + uint8_t fmt_sig[4]; // +0x04 "VGAX" + uint16_t height; // +0x08 Sprite height + uint16_t width; // +0x0A Sprite width + int16_t hotspot_x; // +0x0C Hotspot offset (X) for programmer's reference + int16_t hotspot_y; // +0x0E Hotspot offset (Y) for programmer's reference +}; // =0x10 +#pragma pack(pop) -static inline void vga_write_sequencer(unsigned char i,unsigned char c) { - outp(0x3C4,i); - outp(0x3C5,c); -}*/ +static unsigned char palette[768]; -void main() -{ - printf("pee\n"); +void draw_vrl_modex(unsigned int x,unsigned int y,struct vrl_header *hdr,unsigned char *data,unsigned int datasz) { + unsigned int vram_offset = (y * vga_stride) + (x >> 2); + unsigned char *fence = data + datasz; + unsigned char vga_plane = (x & 3); + unsigned char run,skip,b; + unsigned char far *draw; + + while (data < fence) { + /* start of another vertical strip */ + draw = vga_graphics_ram + vram_offset; + vga_write_sequencer(0x02/*map mask*/,1 << vga_plane); + + while (data < fence) { + run = *data++; + if (run == 0xFF) break; + skip = *data++; + draw += skip * vga_stride; + if (run & 0x80) { + b = *data++; + while (run > 0x80) { + *draw = b; + draw += vga_stride; + run--; + } + } + else { + while (run > 0) { + *draw = *data++; + draw += vga_stride; + run--; + } + } + } + + /* end of a vertical strip. next line? */ + if ((++vga_plane) == 4) { + vram_offset++; + vga_plane = 0; + } + } + + vga_write_sequencer(0x02/*map mask*/,0xF); +} + +int main(int argc,char **argv) { + struct vrl_header *vrl_header; + unsigned char *buffer; + unsigned int bufsz; + int fd; + + if (argc < 3) { + fprintf(stderr,"drawvrl \n"); + return 1; + } + + fd = open(argv[1],O_RDONLY|O_BINARY); + if (fd < 0) { + fprintf(stderr,"Unable to open '%s'\n",argv[1]); + return 1; + } + { + unsigned long sz = lseek(fd,0,SEEK_END); + if (sz < sizeof(vrl_header)) return 1; + if (sz >= 65535UL) return 1; + + bufsz = (unsigned int)sz; + buffer = malloc(bufsz); + if (buffer == NULL) return 1; + + lseek(fd,0,SEEK_SET); + if ((unsigned int)read(fd,buffer,bufsz) < bufsz) return 1; + + vrl_header = (struct vrl_header*)buffer; + if (memcmp(vrl_header->vrl_sig,"VRL1",4) || memcmp(vrl_header->fmt_sig,"VGAX",4)) return 1; + if (vrl_header->width == 0 || vrl_header->height == 0) return 1; + } + close(fd); + + probe_dos(); + if (!probe_vga()) { + printf("VGA probe failed\n"); + return 1; + } + int10_setmode(19); + update_state_from_vga(); + vga_enable_256color_modex(); // VGA mode X + + /* load color palette */ + fd = open(argv[2],O_RDONLY|O_BINARY); + if (fd >= 0) { + unsigned int i; + + read(fd,palette,768); + close(fd); + + vga_palette_lseek(0); + for (i=0;i < 256;i++) vga_palette_write(palette[(i*3)+0]>>2,palette[(i*3)+1]>>2,palette[(i*3)+2]>>2); + } + + draw_vrl_modex(0,0,vrl_header,buffer+sizeof(*vrl_header),bufsz-sizeof(*vrl_header)); + while (getch() != 13); + + { + unsigned int i; + + for (i=1;i < 320;i++) + draw_vrl_modex(i,0,vrl_header,buffer+sizeof(*vrl_header),bufsz-sizeof(*vrl_header)); + } + while (getch() != 13); + + { + unsigned int i; + + for (i=1;i < 200;i++) + draw_vrl_modex(i,i,vrl_header,buffer+sizeof(*vrl_header),bufsz-sizeof(*vrl_header)); + } + while (getch() != 13); + + int10_setmode(3); + buffer = NULL; + free(buffer); + bufsz = 0; + return 0; } diff --git a/src/tesuto.h b/src/tesuto.h new file mode 100755 index 00000000..e2bdeae7 --- /dev/null +++ b/src/tesuto.h @@ -0,0 +1,18 @@ +#ifndef __TESUTO_H__ +#define __TESUTO_H__ + +#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" + + +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