Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Colors only shown... sometimes?
#1
Hi,

I'm using print64.bas, and the code I'm using to show a command menu is as follows:

Code:
const COLOR_BLACK            as ubyte = 0
const COLOR_BLUE              as ubyte = 1
const COLOR_RED              as ubyte = 2
const COLOR_MAGENTA          as ubyte = 3
const COLOR_GREEN            as ubyte = 4
const COLOR_CYAN              as ubyte = 5
const COLOR_YELLOW            as ubyte = 6
const COLOR_WHITE            as ubyte = 7


sub cursor_to(row as ubyte, col as ubyte)
    printat64( row, col )
end sub


sub cprint(s as string)
    print64( s )
end sub


sub lf()
    cprint( CR )
end sub


sub set_colors(i as ubyte, p as ubyte)
    paper( p )
    ink( i )
end sub


sub set_default_colors()
    set_colors( COLOR_WHITE, COLOR_BLACK )
end sub


sub set_highlighted_colors()
    set_colors( COLOR_CYAN, COLOR_BLACK )
end sub


sub set_action_colors()
    set_colors( COLOR_YELLOW, COLOR_BLACK )
end sub


sub print_word_marked_initial(word as string)
    set_action_colors()
    cprint( word( 0 ) )
    set_default_colors()
    cprint( word( 1 to ) )
end sub


sub print_cmds()
' Print basic options
cursor_to( SCR_FIRST_LINE_CMDS, 0 )
print_word_marked_initial( "Inv " )
print_word_marked_initial( "Mira alrededor " )
cprint( "E" ): print_word_marked_initial( "xamina... " )
print_word_marked_initial( "Norte " )
print_word_marked_initial( "Sur " )
print_word_marked_initial( "Este " )
print_word_marked_initial( "Oeste " )
print_word_marked_initial( "Arriba " )
cprint( "A" )
        print_word_marked_initial( "bajo" )
        lf()

' Print object manipulation options
print_word_marked_initial( "Coge... " )
print_word_marked_initial( "Deja... " )
cprint( "Em" ): print_word_marked_initial( "puja... " )
print_word_marked_initial( "Tira de... " )
print_word_marked_initial( "Rompe... " )
end sub

Well, the code should be straightforward. I also know it should work because I ported it from C, the same source code I used wtith z88dk. Unfortunately, it does not work, or it does not always work... (check the image).

What could be wrong?

-- Baltasar


Attached Files
.png   speccy_reveni_cmds.png (Size: 4.33 KB / Downloads: 164)
-- Baltasar
Reply
#2
The thing here is that you're using print64, which "simulates" 64 columns, but this is not real. The ZX Spectrum hardware still uses 32 columns (for attributes). So if you change an ATTR color on an even column (0, 2, 4...) and print something, and change again the color for an odd column, the attr will be overwritten every time by the odd column.
---
Boriel
Reply
#3
Yep, I figured that myself creating a program that writes using print64() with many colors. I've changed my strategy since then (I'm going to use icons). The strange thing is that this program is a port of a program compiled with z88dk using a similar library, in which attributes were not a problem. Now that I know the limitations of print64(), I wonder how do they do it.
-- Baltasar
Reply
#4
This is not a limitation of print64, but of the ZX Spectrum hardware.
What computer were you using?? If it was a REAL (not emulated) ZX Spectrum then the library must be doing something like nirvana engine (sincronizing with the vertical CRT sync to mimic 2 attributes per cell).
---
Boriel
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)