• 0 Vote(s) - 0 Average
• 1
• 2
• 3
• 4
• 5
 Assembly question boriel Administrator Posts: 1,715 Threads: 54 Joined: Aug 2019 Reputation: 16 05-15-2013, 08:59 PM slenkar Wrote:thanks, I made this little program to draw on each line going down the screen but it didnt look like I expected Code:```function FASTCALL drawthis() as ubyte asm LD HL,16384 LD BC,20 ... drawthis() Print "done"``` it just draws a couple of blobs to the screen I am using INC H to go down the screen using BC as a 16 bit counter Loading 254 into screen memory each timeYes, you are on STEP 3) of the list Britlion has written the generic solution. But I suggest you to proceed as you are doing now (you are doing great, BTW!). Basically, each time you use INC H, you are adding 256 to HL. Lets see it in binary form: Initially HL = 16348 = 0x4000 = BIN 0100 0000 0000 0000 <= LINE 0 Now the next line is 256 bytes ahead (INC H) HL 16640 = 0x4100 = BIN 0100 0001 0000 0000 <= LINE 1 This works for lines 0..7. At that moment, HL will point to scanline 7, and its value will be: HL = 16384 + 256 * 7 = 18176 = 0x4700 = BIN 0100 0111 0000 0000 As you can see, the bit pattern seems to be: BIN 0100 0xxx 0000 0000 where 'xxx' ranges from 000 to 111 (0..7). These are the caracter scalines. But LINE 8 is just 32 bytes ahead of LINE 0! This means, we have to "undo" 7 times INC H, and ADD 32 to L. A simple way to do this could be, DEC H, DEC H, DEC H (7 times) and then ADD L, 32. :roll: But this is slow and takes 9 bytes. Using bit operations leads to an optimized method. Experiment with this now, and try again. If not, we'll keep working on it. « Next Oldest | Next Newest »