incrimenter in fill.asm

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

incrimenter in fill.asm

ngdrummer
Hey,

I'm trying to finish this .asm, and for the most part, I think I get it, but I'm having trouble figuring out how to increment the address by 1 to fill the screen or decrease by -1 to clear it. My idea was to store a 1 value in an arbitrary variable location, but just wanted to avoid conflict with any pre-implemented HACK addresses. Is there a specific memory location that's good for doing this? i.e., is there a location that usually remains empty for the sake of creating a temp variable?

If there is a better way to increment, a nudge in the right direction would be helpful, thank you!

Nolan
Reply | Threaded
Open this post in threaded view
|

Re: incrimenter in fill.asm

cadet1620
Administrator
RAM variables are automatically allocated by the assembler.

For instance, if you want to store your 0 or -1 in a variable named "color" all you need to do is start using "color" in @ commands.  As long as is never appears in a label, it will be allocated in RAM. Similarly, you can use a pointer to the screen word you are clearing.

Examples (comments are C equivalents):
    @color  // color = -1
    M=-1

    @color  // *pScreen = color
    D=M
    @pScreen
    A=M
    M=D
--Mark
Reply | Threaded
Open this post in threaded view
|

Re: incrimenter in fill.asm

ngdrummer
Thanks mark!
Reply | Threaded
Open this post in threaded view
|

Re: incrimenter in fill.asm

ngdrummer
Alright, my code is working to fill the screen with black and even to clear the screen when no key is pressed, but now I'm running into the problem of the loop not stopping when the screen is filled or cleared.  Is there a set value for the end of the screen as there is one for the beginning of the screen? I keep getting an illegal memory address for when the loop tries to go beyond the scope of the available RAM, but when I look at it, it's because the loop has hit the complete end of the RAM, and not just the end of what constitutes pixels on the screen.

Any help is appreciated!

Nolan
Reply | Threaded
Open this post in threaded view
|

Re: incrimenter in fill.asm

ngdrummer
Nevermind I figured it out... 256*32 = 8192 (total number of pixels for HACK since it uses 32 consecutive words per RAM location), therefore SCREEN being the first, SCREEN + 8191 is final RAM location for screen pixels...

Let me know if this is too much of a spoiler and I'll remove.

Thanks,

Nolan
Reply | Threaded
Open this post in threaded view
|

Re: incrimenter in fill.asm

yusufgandhi
Thank you for the insight! It helped me to finish fill.asm