(Created page with "== Calculating xpos,ypos to screen address in assembly == The screen address at a given x,y position can be calculated as such: [pre] screenaddr = screenbase + (y AND 7)*&8...") |
|||
(2 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
− | == Calculating xpos,ypos to screen address | + | |
+ | == Calculating xpos,ypos to screen address == | ||
The screen address at a given x,y position can be calculated as such: | The screen address at a given x,y position can be calculated as such: | ||
− | |||
− | |||
− | + | ;; screenaddr = screenbase + (y AND 7)*&800 + int(y/8)*2*R1 + int(x/M) | |
+ | |||
+ | |||
where: | where: | ||
Line 19: | Line 20: | ||
screenbase = &C000 | screenbase = &C000 | ||
+ | |||
+ | |||
+ | |||
+ | [[Category:Programming]] |
Latest revision as of 07:53, 25 December 2018
Calculating xpos,ypos to screen address
The screen address at a given x,y position can be calculated as such:
- screenaddr = screenbase + (y AND 7)*&800 + int(y/8)*2*R1 + int(x/M)
where: x and y your 2D coordinates
R1 = value of CRTC register 1 (eg. 40 with the default firmware settings)
M = 2 (for screen mode 0, 2 pixels/byte) M = 4 (for screen mode 1, 4 pixels/byte) M = 8 (for screen mode 2, 8 pixels/byte)
screenbase = &C000