Tutorial 3: changes: took color out, put it before loop, commented it out. moved video ram address from paintscreen to before main loop. commented out pixel color in paint screen. commented out 3 lines in main loop that would paint the display (why did I have those there?...) put keys register before main loop moved paintscreen from main loop to input loop. additions: added the GetInput routine. used a bx so I could have the return address. added getinput to main loop. added variable color. added line(s) in paintscreen to load a specific pixel from variable Color. added vblank waiting. As you may have noticed, the size of this tutorial (the code, anyway) went up 8x (2k to 16k). With it, I must say a lot of the readability and clarity went with it. But, since I implemented the input stuff, I felt I had to put all that works with it. I guess I will make a 3a showing only how to format the input so it'll detect each individual key event (up and down). The big point of it all seems to be the drawing -- I couldn't really put key A, because it relies on the direction keys. About all I could do is key b... maybe a tutorial 3b?... As for the drawing, it's made up of many things. A quick list of what is what and does what is in order: ColorDraw: Draws a color in video ram at the specific pixel. It'll draw with the draw color. Draw color is hard coded (0xfff) SkipDraw: resets the X,Y pixel to the background color. (gets rid of the cursor) GetDirection: Determines what direction the user hit, and branches to the appropriate place. I couldn't use the key down events to update because then I'd have to decide whether or not to draw a color or reset. It'd make the code larger than it is now. CursorDown: destination from GetDirection. It updates the X and Y appropriately for the given direction. CursorUp: destination from GetDirection. It updates the X and Y appropriately for the given direction. CursorLeft:destination from GetDirection. It updates the X and Y appropriately for the given direction. CursorRight: destination from GetDirection. It updates the X and Y appropriately for the given direction. DrawCursor: Stores the updated X and Y, also paints the new cursor as a black dot. The input I did the way I did... for some reason. There's lots of duplicate code doing things such as loading X and Y into registers. And apparently that's about all the duplicate code. I could've divided a bit of it up into different functions, but I'd have to set the lr register for each, restore later, branch, etc. I might do it in a later tutorial and see how it looks. vblank: People use vblanks when pdating graphics. The vertical blank is when the screen's done drawing. At that time you can update the display without flicking and jagged graphics. In this case, I'm using it for that, and also to slow things down.. hitting the key moves it too fast to accomplish any fine art... new stuff: bleq, blne: branch with link if equal, if not equal. Comes in useful, especially in the input section ;-) bic: Bit clear. Give it a number, and it clears all the bits it contains. (F-bits: 1111, 1e-bits:11110) mul: multiply. operands: destination, source, source. Complains when I a source opperand for the destination. ldrb/strb: load/store 1 byte. orr: or. 10110 or 111 = 10111. orr destination, source, source. functions: drawcursor: loads X and Y into r5 and r6, respectively. from there, loads r8 with the width of the screen, multiplies it by Y (r5) to get the Y offset, then adds X (r6) to get the video ram offset. Adds 0x6000000 to get the address to put the cursor. GetDirection: makes a copy of my settings register (r4) into r8. masks out every setting I may decide to add except bits 2-5 (direction bits). compares bit 3, so if it's less I can branch somewhere, if equal I can branch somewhere, and if higher, I only need one more test to figure out where to branch. Quickest way imo... SkipDraw: Finds offset, ram like draw cursor. Loads the background color, and puts the color in the current (before cursor move) location. Then resets X and Y because they were modified. DrawColor: Finds offset, ram, yada yada. loads r5 with a pre set draw color, and puts it at current position (before cursor move). Then resets X and Y because they were modified Direction keys: Compares for the draw bit, for use later. Loads the current X and Y, clears all direction bits and resets the bit for the direction it is. Stores return addresses, and branches where needed.. after first branch, compares to settings register again to see if it needs to branch there, because the top branch may corrupt the comparrison. Resets the LR register. B key: Loads pallette address and counter value. Compares counter to 8; if greater, resets to 0. Then saves counter. Multiplies pallette by 2, adds to pallette address to get current color. Resets r0 to vram base (where it should be -- it was changed later on), and branches to paintscreen. From there, resets r0 to 1 (the value it needs in the input function), and resets the return pointer. A key: If up, clears the draw bit (bit 1) of my settings register (r4) If down, sets the draw bit. I guess that can conclude this tutorial.. I probly spent 5 or so hours writing the tutorial and the code. All done on school time :-). Hope it helps someone, wasn't too confusing, etc. Look for tutorial 3a for the key input tutorial. -DrkShadow http://drkshadow.no-ip.com/ http://members.corecomm.net/~blairk/