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:
: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 Question

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) Sad
It appears that you are displaying the whole menu each time around the loop, just draw/erase the cursor instead.
Yes, that would slow it down.

I have to reload the old beta 8 of your compiler to update it though, because I seem to have misplaced some of the ZASSEMBLE files after a few RAM clears & restoring the memory Rolling Eyes

Other than displaying the entire menu multiple times, is the rest of the code pretty good for a menu?

Also, I'll create a sub-forum (private) for the game on our forum.

Once I figure out how to build my own sprite routines (I may give up and use ION's), I'll rewrite the menu to be a graph and highlight the different selections, unless this would be fine for the game.
Well for one thing when you press down it appears to jump to the up label...
But otherwise it's pretty good. And don't send Beta 8, okay? Do the newest version (OTBP Assembler 1).
Oh, I didn't know Assembler 1 had been released. Is that the same version you gave me earlier?

Also, I use the same label to save memory because there are only two options on the menu so it doesn't matter which key you press; you go to the other menu position.
The version I gave you was the unreleased version 2.
[quote="b-flat"]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:

:TXT1:
:.DB "SuperLand 2                     Load Game       New Game",0
:TXT2:
:.DB "Thanks For      Playing!",0



OOOH! So secret -_-
What are you smoking?

Look at this nice code:


Code:
:TXT1:
:.DB "SuperLand 2                     Load Game       New Game",0
:TXT2:
:.DB "Thanks For      Playing!",0


How are you supposed to know what "SuperLand" is?
Yeah, the name was changed to protect the innocent. Very Happy
(I'm part of this project too, btw) Wink
well. it sounds like its starting off in a good spot..
calc84maniac wrote:
Yeah, the name was changed to protect the innocent. Very Happy
(I'm part of this project too, btw) Wink


Pshhh yeah, go around telling everyone Mad Razz
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement