screen13 palette: is there a bug, or i'm struggling on it?

DOS specific questions.
nitrofurano
Posts: 57
Joined: Dec 08, 2010 14:55
Location: Portugal
Contact:

screen13 palette: is there a bug, or i'm struggling on it?

Postby nitrofurano » Jun 05, 2012 18:54

hi! i'm trying to use this palette on screen 13
Image

the code is

Code: Select all

#include "fbgfx.bi"
dim as integer i,j,r,g,b,c
screen 13: setmouse ,,0 : cls :'- 320x200 256 colours
for for g=0 to 7:for r=0 to 7:for b=0 to 3
  c=(g*32)+(r*4)+b
  palette c,(r*&h080000)+(g*&h000800)+(b*&h000010)
  next:next:next
line (0,0)-(319,199),15,bf
for i=0 to 15
for j=0 to 15
  line (i*20+2,j*12+2)-(i*20+15,j*12+7),j*16+i,b
  line (i*20+2+2,j*12+2+2)-(i*20+15+2,j*12+7+2),j*16+i,bf
  next:next
sleep


and i'm only getting this (it's a linked imageshack thumbnail below):
Image


do someone know what is happening? thanks! :)
fxm
Posts: 7738
Joined: Apr 22, 2009 12:46
Location: Paris suburb, FRANCE

Re: screen13 palette: is there a bug, or i'm struggling on i

Postby fxm » Jun 05, 2012 21:26

I did not exactly understood what you are trying to do as drawing palette, but a fastest try:

Code: Select all

#include "fbgfx.bi"
dim as integer i,j,k,r,g,b,c
screen 13: setmouse ,,0 : cls :'- 320x200 256 colours
for g=0 to 7:for r=0 to 7:for b=0 to 3
  c=(g*32)+(r*4)+b
  palette c,r*&h8 Or (g*&h8 Shl 8) Or (b*&h10 Shl 16)
  next:next:next
for i=0 to 7
for j=0 to 7
for k=0 to 3
  line (j*40+k*10,i*25)-((j+1)*40+(k+1)*10,(i+1)*25),i*32+j*4+k,bf
  next:next:next
sleep
nitrofurano
Posts: 57
Joined: Dec 08, 2010 14:55
Location: Portugal
Contact:

Re: screen13 palette: is there a bug, or i'm struggling on i

Postby nitrofurano » Jun 05, 2012 23:02

thanks, but the result still looks weird...

Image
fxm
Posts: 7738
Joined: Apr 22, 2009 12:46
Location: Paris suburb, FRANCE

Re: screen13 palette: is there a bug, or i'm struggling on i

Postby fxm » Jun 06, 2012 7:08

It works under Windows XP, both compiled with '-target win32' and '-target dos', and the result is like your reference palette.
Image
codeFoil
Posts: 255
Joined: Dec 22, 2011 4:45
Location: United States
Contact:

Re: screen13 palette: is there a bug, or i'm struggling on i

Postby codeFoil » Jun 06, 2012 7:51

Or it could be DOSBox's VGA emulation.
nitrofurano
Posts: 57
Joined: Dec 08, 2010 14:55
Location: Portugal
Contact:

Re: screen13 palette: is there a bug, or i'm struggling on i

Postby nitrofurano » Jun 06, 2012 10:41

codeFoil wrote:Or it could be DOSBox's VGA emulation.


but, well, if it were a DOSBox VGA emulation problem, wound't this affect all those VGA games there as well, for example? this is what i'm seeing so weird...
fxm
Posts: 7738
Joined: Apr 22, 2009 12:46
Location: Paris suburb, FRANCE

Re: screen13 palette: is there a bug, or i'm struggling on i

Postby fxm » Jun 06, 2012 14:38

I lightly modified my previous program to be compatible of QuickBasic, and it works very well on QuickBasic!

Code: Select all

DIM i AS INTEGER
DIM j AS INTEGER
DIM r AS INTEGER
DIM b AS INTEGER
DIM c AS INTEGER
SCREEN 13
FOR g = 0 TO 7: FOR r = 0 TO 7: FOR b = 0 TO 3
  c = (g * 32) + (r * 4) + b
  PALETTE c, r * &H8 + g * &H8 * &H100 + b * &H10 * &H10000
  NEXT: NEXT: NEXT
FOR i = 0 TO 7
FOR j = 0 TO 7
FOR k = 0 TO 3
  LINE (j * 40 + k * 10, i * 25)-((j + 1) * 40 + (k + 1) * 10, (i + 1) * 25), i * 32 + j * 4 + k, BF
  NEXT: NEXT: NEXT
SLEEP
nitrofurano
Posts: 57
Joined: Dec 08, 2010 14:55
Location: Portugal
Contact:

Re: screen13 palette: is there a bug, or i'm struggling on i

Postby nitrofurano » Jun 06, 2012 15:39

maybe we found a bug on the Freebasic (or at least the DOS version of it)

Image
fxm
Posts: 7738
Joined: Apr 22, 2009 12:46
Location: Paris suburb, FRANCE

Re: screen13 palette: is there a bug, or i'm struggling on i

Postby fxm » Jun 06, 2012 16:36

nitrofurano wrote:maybe we found a bug on the Freebasic (or at least the DOS version of it)

Image

My below full compatible program works well:
- On QuickBasic and under Windows XP
- On QuickBasic and under DosBox 0.74 (under Windows XP)
- On FreeBasic compiled with -target win32 under Windows XP
- On FreeBasic Compiled with -target dos under Windows XP

Code: Select all

DIM i AS INTEGER
DIM j AS INTEGER
DIM r AS INTEGER
DIM b AS INTEGER
DIM c AS INTEGER
DIM g AS INTEGER
DIM k AS INTEGER
SCREEN 13
FOR g = 0 TO 7: FOR r = 0 TO 7: FOR b = 0 TO 3
  c = (g * 32) + (r * 4) + b
  PALETTE c, r * &H8 + g * &H8 * &H100 + b * &H10 * &H10000
  NEXT: NEXT: NEXT
FOR i = 0 TO 7
FOR j = 0 TO 7
FOR k = 0 TO 3
  LINE (j * 40 + k * 10, i * 25)-((j + 1) * 40 + (k + 1) * 10, (i + 1) * 25), i * 32 + j * 4 + k, BF
  NEXT: NEXT: NEXT
SLEEP

Image
It is incomprehensible!
Last edited by fxm on Jun 06, 2012 19:13, edited 1 time in total.
frisian
Posts: 234
Joined: Oct 08, 2009 17:25

Re: screen13 palette: is there a bug, or i'm struggling on i

Postby frisian » Jun 06, 2012 17:07

nitrofurano wrote:hi! i'm trying to use this palette on screen 13
Image

the code is

for i=0 to 15
for j=0 to 15
line (i*20+2,j*12+2)-(i*20+15,j*12+7),j*16+i,b
line (i*20+2+2,j*12+2+2)-(i*20+15+2,j*12+7+2),j*16+i,bf
next:next

do someone know what is happening? thanks! :)

If you look closely to the image you see that it is made of 32 color blocks in a row and 8 blocks in a column and not 16*16 blocks.

simple program that displays 32*8 blocks

Code: Select all

Screen 13

Dim As Integer g,r,b,c
For g=0 To 7
   For r = 0 To 7
      For b =0 To 3
         c =g*32+r*4+b
         Palette c,r*32,g*32,b*64
      Next
   Next
Next


Dim As Integer i,j
For i= 0 To 31
   For j= 0 To 7
      Line(i*10,j*10)-(i*10+9,j*10+9),j*32+i,bf
   Next
Next

Sleep
End
fxm
Posts: 7738
Joined: Apr 22, 2009 12:46
Location: Paris suburb, FRANCE

Re: screen13 palette: is there a bug, or i'm struggling on i

Postby fxm » Jun 06, 2012 17:43

Yes, nitrofurano could try this other form of the instruction 'Palette':
Palette [Get] [index, r, g, b]
nitrofurano
Posts: 57
Joined: Dec 08, 2010 14:55
Location: Portugal
Contact:

Re: screen13 palette: is there a bug, or i'm struggling on i

Postby nitrofurano » Jun 06, 2012 22:23

still with problems...
maybe what is causing this is the compiled code is too fast for dosbox emulation? - this is weird because i tried even adding 'screensync' command in the code, into that loop...

Image
DOS386
Posts: 798
Joined: Jul 02, 2005 20:55

There IS a BUG in PALETTE command for DOS target

Postby DOS386 » Jun 16, 2012 9:31

nitrofurano wrote:someone know what is happening? thanks!


Didn't test your code, but maybe you just re-discovered this old BUG ?

http://www.freebasic.net/wiki/wikka.php?wakka=GfxLib
http://www.freebasic.net/wiki/wikka.php ... yPgPalette
nitrofurano
Posts: 57
Joined: Dec 08, 2010 14:55
Location: Portugal
Contact:

Re: There IS a BUG in PALETTE command for DOS target

Postby nitrofurano » Jun 16, 2012 15:15

DOS386 wrote:
nitrofurano wrote:someone know what is happening? thanks!


Didn't test your code, but maybe you just re-discovered this old BUG ?

http://www.freebasic.net/wiki/wikka.php?wakka=GfxLib
http://www.freebasic.net/wiki/wikka.php ... yPgPalette


it seems to be, thanks, btw i tried your assembly code in this example below, and the problem persists

Image

Code: Select all

#define co 14

type uint32  as uinteger
type uint8   as ubyte

'' note the horrible "tt"-typo below :-(
sub palete (byval aa as uint8, byval bb as uint32)
  asm
    mov dl, 0xc8
    mov dh, 3     '' mov dx, 0x03c8
    mov al, [aa]
    out dx, al    '' index
    inc edx       '' mov dx, 0x03c9
    mov eax,[bb]
    out dx, al    '' r
    shr eax,8
    out dx, al    '' g
    shr eax,8
    out dx, al    '' b
    end asm
  end sub

screen 13:setmouse ,,0:cls
dim as integer g,r,b,c
for g=0 to 7
  for r = 0 to 7
    for b =0 to 3
      c =g*32+r*4+b
      'palette c,r*32,g*32,b*64
      'palete c,(r*(32*65536))+(g*(32*256))+(b*64)
      'palete c,(r*(1*65536))+(g*(1*256))+(b*2)
      palete c,(r*(4*65536))+(g*(4*256))+(b*8)
      next
    next
  next

dim as integer i,j
for i= 0 to 31
  for j= 0 to 7
    line(i*10,j*25)-(i*10+9,j*25+24),j*32+i,bf
    next
  next

sleep
end

'- http://www.freebasic.net/forum/viewtopic.php?f=4&t=19980
'- http://www.freebasic.net/forum/viewtopic.php?t=12691

Return to “DOS”

Who is online

Users browsing this forum: No registered users and 1 guest