FB II Compiler
View the memory
Recent questions about poking values directly into Gworlds got me thinking about what you could do with that. I remembered a program I wrote on my Atari 800 in 1985. With that computer there was a memory location that told the system where in memory the screen was located. Poke a different value in there and you viewed a different block of memory on the screen. The program below duplicates this on the Mac, using a gWorld and blockmove. When it starts you are viewing the low memory with address 0 at the upper left corner. As I understand, this area of memory holds the system global variables. You can see some changes from time to time. Move the mouse and you see some bytes change. If you scroll down to where the gWorld that this program creates is located you see some interesting feed back effects, sort of like holding two mirrors facing each other.
You control the program with the arrow keys. They move one pixel in any direction. When you holding down the option key and an arrow key at the same time you move 10 pixels. The command key moves you 100 pixels, 1,000 pixels for the shift key and 10,000 for the control key. Press the mouse button to exit the program.
I would like to flesh this out into a useful (or at least interesting) program that would label selected memory locations, jump you to selected memory locations, resize the window and display memory in different bit depths. To start with I would like to be able to find out exactly how much memory there is so I can prevent attempting to view higher memory than exists in the computer. Right now if you use the program to look too high in memory it crashes. Does anyone know how I can find important memory locations such as the starting and ending locations of each running program and the last memory location?
LOCAL FN buildGWorld(rectPtr&,depth)
t;8 = rectPtr&
QDErr = FN NEWGWORLD(theWorld&,depth,#@t,0,0,0)
LONG IF QDErr : t$ = "Insufficient memory for GWorld"
CALL PARAMTEXT(t$,"","","") : ctrl%=FN NOTEALERT(128,0)
END FN = theWorld&
LOCAL FN viewMemory
WINDOW 1, "", (0,0)-(_WindWidth, _WindHeight), _dialogFrame
CALL SETRECT(rect, 0,0,_WindWidth, _WindHeight)
LONG IF gWorldAdr&
mapHand& = FN GETGWORLDPIXMAP(gWorldAdr&)
locked = FN LOCKPIXELS(mapHand&)
y&=0 : x&=0
remainderOfDivide = _WindWidth MOD 4
BLOCKMOVE adr&, pixMapAdr&, bytesToMove&
IF gkeys(3)=1 THEN adder= 1000 'Shift key down
IF gkeys(3)=8 THEN adder= 10000 'control key down
IF gkeys(3)=4 THEN adder= 10 'option key down
IF gkeys(3)=-32768 THEN adder= 100 'command key down
CASE gkeys(7)=8 : x&=x&-adder 'left arrow
CASE gkeys(7)=16 : x&=x&+adder 'right arrow
CASE gkeys(7)=32 : y&=y&+adder 'down arrow
CASE gkeys(7)=64 : y&=y&-adder 'up arrow
IF y&<0 THEN y&=0
IF x&<0 THEN x&=0
UNTIL FN BUTTON