View Single Post
Old 22 March 2024, 12:12   #18
remz
Registered User
 
Join Date: May 2022
Location: Canada
Posts: 140
1) Rotareneg: I personally hate self-modifying code, except on no-cache system like a Tandy CoCo, where it makes a lot of sense
2) Karlos: I never access the 'double memory address': the value is just used as a fast swap between two addresses. I'll try to explain with numbers to make my intention perhaps clearer. Values are in decimal, consider them absolute addresses:
buffer 1 is at address 20
buffer 2 is at address 36
sum of addresses = 20 + 36 = 56
SUM=56
Say X is your pointer, initially starting on buffer 1.
X=20
Now at every frame, you wish to alternate between the two buffers. The calculation would be:
X=SUM-X
This will make X swap between 20 and 36.

Again just to be clear, this exercise is just for fun and understanding the inner workings. My question was essentially to see if this value (i.e.: adding two addresses together) could have been calculated at load-time by the loader, instead of being done at runtime by my code.
remz is offline  
 
Page generated in 0.05134 seconds with 11 queries