From 5bc7b6ceb8766da1f537b30a9027db6d10999157 Mon Sep 17 00:00:00 2001 From: sparky4 Date: Fri, 10 Feb 2017 09:58:00 -0600 Subject: [PATCH] something is badly broken in palette experiment --- TEST.L16 | 4 ++-- data/16t.pal | Bin 0 -> 24 bytes src/lib/16_vl.c | 16 ++++++++++++++++ src/lib/16_vl.h | 1 + src/lib/scroll16.c | 2 +- src/test.c | 11 ++++++----- 6 files changed, 26 insertions(+), 8 deletions(-) create mode 100755 data/16t.pal diff --git a/TEST.L16 b/TEST.L16 index 2171f5a1..a3040c14 100755 --- a/TEST.L16 +++ b/TEST.L16 @@ -792,7 +792,7 @@ p[]=740 qp=765 p[]-qp=1505 qqqqqqqq Project 16 test.exe. This is just a test file! -version Feb 10 2017 09:25:47 +version Feb 10 2017 09:28:45 VL_PrintmodexmemInfo: Virtual Screen: 352x272 Tile: 22x17=((Virtual Screen)/16) Screen: 320x240 Tile: 20x15=((Screen)/16) @@ -801,7 +801,7 @@ VL_PrintmodexmemInfo: [1]=(a000:5d80) size=23936 w=352 h=272 sw=320 sh=240 pi=1408 [2]=(a000:bb00) size=8448 w=352 h=96 sw=352 sh=96 pi=1408 [3]=(a000:dc00) size=8448 w=352 h=96 sw=352 sh=96 pi=1408 -tx=1 ty=1 player.d=2 +tx=1 ty=1 player.d=3 ==== 0 paloffset= 255 diff --git a/data/16t.pal b/data/16t.pal new file mode 100755 index 0000000000000000000000000000000000000000..e900d9954cbc9d95d705505fa0e5b58dab72bb2e GIT binary patch literal 24 Ucmey*00jR*5QIPkh{eDF0Fs3Z^#A|> literal 0 HcmV?d00001 diff --git a/src/lib/16_vl.c b/src/lib/16_vl.c index 13d8c9bb..ec5c9f0a 100755 --- a/src/lib/16_vl.c +++ b/src/lib/16_vl.c @@ -703,6 +703,22 @@ void VL_LoadPalFile(const char *filename, byte *palette) } } +void VL_LoadPalFilewithoffset(const char *filename, byte *palette, word o) +{ + int fd; + + fd = open(filename,O_RDONLY|O_BINARY); + if (fd >= 0) { + word i; + + read(fd,palette, PAL_SIZE); + close(fd); + + vga_palette_lseek(o); + for (i=o;i < 256-o;i++) vga_palette_write(palette[(i*3)+0]>>2,palette[(i*3)+1]>>2,palette[(i*3)+2]>>2); + } +} + void modexSavePalFile(char *filename, byte *pal) { diff --git a/src/lib/16_vl.h b/src/lib/16_vl.h index 49457d2b..e2c28a32 100755 --- a/src/lib/16_vl.h +++ b/src/lib/16_vl.h @@ -125,6 +125,7 @@ void modexPalSave(byte *palette); byte *modexNewPal(); void modexLoadPalFile(char *filename, byte **palette); void VL_LoadPalFile(const char *filename, byte *palette); +void VL_LoadPalFilewithoffset(const char *filename, byte *palette, word o); void modexSavePalFile(char *filename, byte *palette); /* fixed palette functions */ diff --git a/src/lib/scroll16.c b/src/lib/scroll16.c index 65f2f5e7..e198367c 100755 --- a/src/lib/scroll16.c +++ b/src/lib/scroll16.c @@ -583,7 +583,7 @@ mapDrawTile(tiles_t *t, word i, page_t *page, word x, word y) case 0: #endif #ifndef TILERENDER - if(!pagenorendermap) modexClearRegion(page, x, y, t->tileWidth, t->tileHeight, i); + if(!pagenorendermap) modexClearRegion(page, x, y, t->tileWidth, t->tileHeight, i+1); #else modexDrawBmpRegion (page, x, y, rx, ry, t->tileWidth, t->tileHeight, i); /* then the sprite. note modding ram ptr means we just draw to (x&3,0) */ diff --git a/src/test.c b/src/test.c index ceca4f24..6d130170 100755 --- a/src/test.c +++ b/src/test.c @@ -30,7 +30,7 @@ #define HGQ 55 static word far* clockw= (word far*) 0x046C; /* 18.2hz clock */ -static byte palette[PAL_SIZE]; +static byte *palette;//[PAL_SIZE]; void main(int argc, char *argv[]) { @@ -84,7 +84,7 @@ void main(int argc, char *argv[]) Startup16(&gvar); /* save the palette */ - //====pal = modexNewPal(); + palette = modexNewPal(); //====modexPalSave(pal); //====modexFadeOff(1, pal); //====modexPalBlack(); @@ -94,16 +94,17 @@ void main(int argc, char *argv[]) EN_initplayer(&player, 0, &gvar.video); VGAmodeX(1, 1, &gvar); - //====modexPalBlack(); + modexPalBlack(); /* load our palette */ VL_LoadPalFile("data/16.pal", &gvar.video.palette); bmp1.offset=(paloffset/3); VL_palette(&bmp1, &gvar.video.palette, &paloffset, 0, 0); - VL_LoadPalFile("data/default.pal", &palette); + //VL_LoadPalFilewithoffset("data/default.pal", &palette, paloffset); + modexLoadPalFile("data/16t.pal", &palette); bmp2.offset=(paloffset/3); - VL_palette(&bmp2, &palette, &paloffset, 0, 0); + VL_palette(&bmp2, palette, &paloffset, 0, 0); //====modexLoadPalFile("data/default.pal", &pal2); /* overscan show */ -- 2.39.2