Can you clear memory from VGA driver
T Chap
Posts: 4,223
I am using a VGA type driver ( NH4_LCDdriver ) that is an adaptation of one of the old VGA drivers. I have almost maxed out $8000 - $FFFF on the EEPROM with data that gets sent as needed to the LCD. Some locations on the LCD are overwritten with other data as graphics change, so that the same memory locations are used in some cases. What is happening is that I can barely get the program to compile even using optimizing with .bstc. I have hit a wall and can't complete the code due to needing more graphics memory. It appears that if you load in a bitmap (from .dat file), it gets loaded to a memory block in the VGA driver. There are cases where I "blank" out a graphic with a solid black overlay to remove the original graphics. This overlay "mask" still takes up the same amount of memory so that you never get that memory back even if the graphic area is no longer needed. There are sections of the graphics that I can sacrifice temporarily to load other graphics for certain menus, then go back to the original graphics. The problem is that there seems to be no way to reclaim any memory areas that can be muted temporarily. I have tried stopping the LCD driver cog and restarting, thinking it would clear out any unused memory but this does not work, the screen just goes crazy when you try to relaunch it.
Obviously I don't have a clear understanding the VGA engine, and am hoping someone can shed some light on how to possibly clear out old graphic data blocks. The graphics engine seems to let you add graphics up to a point, then it crashes. Typically what happens is, to load a graphic you would read the eeprom into a location in DAT like this:
ReadPage(EEPROM1, epawatch, @graphic47_data & $FFC0, 256) ' epawatch is the address in EEPROM.
DrawBitmap(@graphic47_data, @graphics47_info)
The goal is to find a few hundred longs so that the I2C_PASM object can be used, as the current slow boat I2C is painful. Even finding 200 longs, I am still back against the wall. I included the main program. One last resort is to store some status values onto eeprom, then reboot when I need to gain some memory back, the eeprom values will then be read and tell the graphics which mode to be in. Then the eeprom status values are reset to normal and rebooted in standard mode. This could be too slow for a user to wait for are reboot just to flip a screen to see a different set of values. Ideally a memory wipe method would be preferred over rebooting.
Any suggestions would be greatly appreciated!
Obviously I don't have a clear understanding the VGA engine, and am hoping someone can shed some light on how to possibly clear out old graphic data blocks. The graphics engine seems to let you add graphics up to a point, then it crashes. Typically what happens is, to load a graphic you would read the eeprom into a location in DAT like this:
ReadPage(EEPROM1, epawatch, @graphic47_data & $FFC0, 256) ' epawatch is the address in EEPROM.
DrawBitmap(@graphic47_data, @graphics47_info)
The goal is to find a few hundred longs so that the I2C_PASM object can be used, as the current slow boat I2C is painful. Even finding 200 longs, I am still back against the wall. I included the main program. One last resort is to store some status values onto eeprom, then reboot when I need to gain some memory back, the eeprom values will then be read and tell the graphics which mode to be in. Then the eeprom status values are reset to normal and rebooted in standard mode. This could be too slow for a user to wait for are reboot just to flip a screen to see a different set of values. Ideally a memory wipe method would be preferred over rebooting.
Any suggestions would be greatly appreciated!
Comments
If you write your own custom compiler, you can have the PASM images occupy the space that will later be used for the graphics driver. I'm writing a Spin compiler that will be able to do this (and will also allow offloading whole Spin objects or placing them in graphics buffers), but don't expect it to be done for a long long time - if the P2 comes out before I finish my compiler, I might not even release a P1 version (but I'd still like to).
The VGA graphics is a tile-based system, where the screen is made up of 16x16 pixel tiles. There is a screen array that maps tiles to memory.
Usually, the tiles are mapped to ROM font characters. But, you can create your own tiles using RAM and thereby create graphics.
If you are done with a graphic, you can just print the space character all over the screen where the graphic was.
Then, that RAM is free.
Your graphics memory is then not being used at all and you can do whatever you want with it.
I don't know how sophisticated a solution you need, but I've seen people posting memory management program here from time to time.
You could check OBEX for something that would let you dynamically allocate and free memory...
Or, you could manually decide where to place graphics in memory for each page you want to show...
Andy