using only A and D on HACK

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

using only A and D on HACK

ysh443
Hi
im trying to solve the Fill.asm project
i find it tough

on HACK, every action is made by either A register, D register or both (or by M which gives MEM[A])

on my program, i got to compute the current pixel position and store it into D.
then i check the KYBD and set A to either 0 or 1 depends on KYBD content

and now i want to set MEM[D] with A value,
but
in a frustrating way, any access to MEM uses A
so , how can i set MEM to some value if my only two working registers
already occupied with importend data , that i need imidiatly to use (so storing to some MEM position wont help)

please help

regards


Reply | Threaded
Open this post in threaded view
|

Re: using only A and D on HACK

cadet1620
Administrator
ysh443 wrote
Hi
im trying to solve the Fill.asm project
i find it tough

on HACK, every action is made by either A register, D register or both (or by M which gives MEM[A])

on my program, i got to compute the current pixel position and store it into D.
then i check the KYBD and set A to either 0 or 1 depends on KYBD content

and now i want to set MEM[D] with A value,
but
in a frustrating way, any access to MEM uses A
so , how can i set MEM to some value if my only two working registers
already occupied with importend data , that i need imidiatly to use (so storing to some MEM position wont help)

please help

regards
First you need to store the value you computed for screen position in memory so that you can get it later.
Then check the keyboard and get the black or white value into D.
Finally get the saved screen position into A so that you can do M=D to set the screen pixels.

--Mark
Reply | Threaded
Open this post in threaded view
|

Re: using only A and D on HACK

ysh443
10x
works fine now


since white_screen is the "steady state" , is it corret to endlessly run on the SCREEN MEM
and set xFFFF or x0000 upon KYBD state (that how i did it)?

on such impl. , if runing on slow rate, i can see the screen painting (usually starts somewhere on the middle of the screen) , looks a bit non estetic


regards
Reply | Threaded
Open this post in threaded view
|

Re: using only A and D on HACK

cadet1620
Administrator
That's the easiest way to do it, but it does look strange. If you press and release space quickly you end up with alternating white and black stripes.

I've seen several different approaches from students. The one I find most esthetic is one that paints white from the top down and paints black from the bottom of the white upwards. It looks very much like pulling down a window shade.

--Mark