1
QB64 Discussion / Re: Question about text attributes in SCREEN 0
« on: March 04, 2019, 02:53:09 pm »Sounds to me as if you're looking for the _MEM commands:Code: QB64: [Select]
SCREEN 0 PRINT "Hello World" SLEEP 'so we can see the original text SLEEP 'so we can see the change, as we changed the "H" to CHR$(4) --- "" 'If you notice, we actually changed the FOURTH characcter's color to red (the second "l" in "Hello World". 'This makes sense once you realize that memory is mapped starting at 0,0; whereas LOCATE starts at 1,1 in SCREEN 0. 'To work with any particular point for SCREEN 0 memory, we need to remember: '1) Screen Information is stored in 2 bytes -- First Byte is the character. ' Second Byte is the color code. '2) To convert the screen coordinates to memory coordinates, use the simple formula: ' CharacterMemoryPosition = ((Column -1) * _WIDTH + Row -1)) * 2 ' ColorMemoryPosition = ((Column -1) * _WIDTH + Row -1)) * 2 + 1 '3) Next tip is to always remember to add the value to m.Offset which is QB64's way to track where the screen information starts in memory 'So to make Row 2, Column 1 become a "W", we'd do the following: SLEEP 'so we can wait and see the W appear where we want it 'And to change that W to being blue, we'd do the following: SLEEP 'to see the change one step at a time
VERY BIG THANKS.
This is exactly what I'm looking for.
THANKS AGAIN.
But. Are You raelly sure that:
CharacterMemoryPosition = ((Column - 1) * _WIDTH + Row - 1) * 2
ColorMemoryPosition = ((Column - 1) * _WIDTH + Row - 1) * 2 + 1
not:
CharacterMemoryPosition = (Column - 1 + _WIDTH * (Row - 1)) * 2
ColorMemoryPosition = (Column - 1 * _WIDTH * (Row - 1)) * 2 + 1
Row and Column swapped?