The following warnings occurred:
Warning [2] Undefined array key 0 - Line: 1677 - File: showthread.php PHP 8.2.31 (Linux)
File Line Function
/inc/class_error.php 157 errorHandler->error
/showthread.php 1677 errorHandler->error_callback
/showthread.php 916 buildtree




Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Reading, storing and writing screen values
#1
Hi all

I'm starting to learn how to manipulate screen directly at memory address level. Right now, I'm messing with this code
Code:
rem screen values paper 0: border 0: ink 7: cls dim conta as byte dim x,y,n,adres,dirb as uinteger bucle: y=RND*10 x=RND*32 adres=0 POKE attrAddress(x,y),RND*256 Print at 10,0; "X="; x; " - "; "Y="; y; print at 11,0; "Attrib address is.......: "; attrAddress(x,y); print at 12,0; "Attrib value is.........: "; PEEK attrAddress(x,y); print at 13,0; "The 8 screen addresses..: " for conta=0 to 7 poke scrAddress(x,y)+adres,RND*256 print scrAddress(x,y)+adres;","; PEEK (scrAddress(x,y)+adres) adres=adres+256 next conta pause 0 cls goto bucle rem funciones FUNCTION scrAddress(x AS UBYTE, y AS UBYTE) AS UINTEGER ASM ; This FUNCTION returns the address into HL of the screen address ; x,y in character grid notation. ; Original CODE was extracted by BloodBaz ; x Arrives in A, y is in stack. AND 31 ld l,a ld a,(IX+7) ; Y value ld d,a AND 24 add a,64 ld h,a ld a,d AND 7 rrca rrca rrca OR l ld l,a END ASM END FUNCTION FUNCTION attrAddress (x AS UBYTE, y AS UBYTE) AS UINTEGER 'This function returns the memory address of the Character Position 'x,y in the attribute screen memory. 'Adapted from code by Jonathan Cauldwell. 'Rebuilt for ZX BASIC by Britlion from NA_TH_AN's fourspriter, with permission. ASM ld a,(IX+7) ;ypos rrca rrca rrca ; Multiply by 32 ld l,a ; Pass TO L AND 3 ; Mask with 00000011 add a,88 ; 88 * 256 = 22528 - start of attributes. ld h,a ; Put it in the High BYTE ld a,l ; We get y value *32 AND 224 ; Mask with 11100000 ld l,a ; Put it in L ld a,(IX+5) ; xpos add a,l ; Add it TO the Low BYTE ld l,a ; Put it back in L, AND we're done. HL=Address. END ASM END FUNCTION

Questions are:

- Are there any better options to read and write given a X and Y coordinates?
- What is the best way to storage screen memory addresses and their values? Integer (for addresses) and Ubyte (for values) arrays, right?

Thanks and regards
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)