- Beginning ASM
- 06 Mar 2007 07:51:51 pm
- Last edited by b-flat on 07 Mar 2007 07:43:00 pm; edited 1 time in total
I am still beginning with ASM, so please excuse me if my programming is very n00bish. I was creating a menu routine for a top secret project and made the following code:
Code:
However, this program runs slower than its basic equivolent
You'd think that this program would run way too fast and cause the cursor to move up and down very quickly, but it doesn't
Any help with optimizations or explanations would be nice. Also note that I complied this oncalc (comments added on my computer).
Also, I wrote a similar program for moving around the home screen (accidentally deleted it), and it only ran slightly faster than its BASIC counterpart. The idea I used was have a key loop, then jump to a place for each key press, where it checks to see if you can move. If you can't, it goes back to the key loop, if it can, it erases your current character (using the call command) and then draws a new one.
(no, I did not use source coder; I typed all of this code)
Code:
:DEFHDR.HDR
:BCALL RUNINDICOFF
:BCALL CLRSCRNFULL ;The screen only needs to be cleared once because every other time, it is just overwriting
:START:
:PUSH BC
:BCALL HOMEUP ;Display the menu
:LD HL,TXT1
:BCALL PUTS
:POP BC
:LD H,0 ;Get the cursor position
:LD L,B
:INC HL
:INC HL
:LD (CURROW),HL
:LD A,5 ;Display the cursor
:PUSH BC
:BCALL PUTC
:POP BC
:KEY:
:BCALL GETCSC ;Looping for key
:CP 1 ;If DOWN was pressed
:JR Z,UP
:CP 4 ;If UP was pressed
:JR Z,UP
:CP 15 ;If [CLEAR] was pressed
:JR Z,END
:CP 54 ;If [2ND] was pressed
:JR Z,NEXT
:JR KEY
:UP:
:INC B ;Advance the cursor
:LD A,B
:CP 2 ;Check to see if the cursor needs to go back to the top
:JR Z,UP1
:JR START ;Update the display and wait for another key
:UP1:
:LD B,0 ;Reset to the top position
:JR START
:NEXT:
:RET ;THIS IS JUST FOR NOW
:END:
:BCALL CLRSCRNFULL ;Exit and display the message "Thanks For Playing"
:BCALL HOMEUP
:LD HL,TXT2
:BCALL PUTS
:BCALL NEWLINE
:RET
:TXT1:
:.DB "SuperLand 2 Load Game New Game",0
:TXT2:
:.DB "Thanks For Playing!",0
However, this program runs slower than its basic equivolent
You'd think that this program would run way too fast and cause the cursor to move up and down very quickly, but it doesn't
Any help with optimizations or explanations would be nice. Also note that I complied this oncalc (comments added on my computer).
Also, I wrote a similar program for moving around the home screen (accidentally deleted it), and it only ran slightly faster than its BASIC counterpart. The idea I used was have a key loop, then jump to a place for each key press, where it checks to see if you can move. If you can't, it goes back to the key loop, if it can, it erases your current character (using the call command) and then draws a new one.
(no, I did not use source coder; I typed all of this code)