Jump to content
  • 0
rje

Writing a "panel" drawing routine

Question

Posted (edited)

I've started assembly that draws a beveled box in PETSCII on the screen.  The user POKEs in left,top,right,bottom, and the code does the work.

I just remembered that there are KERNAL routines to position the cursor on the screen.  I should use those, shouldn't I?

 

The routine starts by pre-computing the height and width, and then it positions the cursor:

Quote

ldy top

jsr print_y_down

ldx left

jsr print_x_spaces

Then, it prints the top line:

Quote

lda #213 ; curve top-left

jsr chrout

ldx width

jsr horiz_bar

lda #201 ; curve top-right

jsr chrout

That's what I have so far.  Next steps are to print the vertical bars and the bottom of the panel frame.

Now for the print_x_spaces I have:

Quote

print_x_spaces: beq done

                lda #29         ; right

                jsr chrout

                dex

                bne print_x_spaces

                rts

And for the horizontal bar, I have:

Quote

horiz_bar:      beq done

                lda #195        ; horiz bar

                jsr chrout

                dex

                bne horiz

                rts

 

I guess I want to verify I'm doing things correctly, if there's a better way, and perhaps if this has already been done.

 

Edited by rje

Share this post


Link to post
Share on other sites

2 answers to this question

Recommended Posts

  • 0

You want to use the PLOT routine in the Kernal to move the cursor. Just be aware that it confusingly switches the X and Y registers from what you'd expect. Put the row in X and the column in Y, and you're all set, no need to put out a bunch of spaces.

Alternatively, you can just poke the characters into VRAM, along with color info for each one. That will usually be the fastest method for rendering characters.

  • Thanks 1

Share this post


Link to post
Share on other sites
  • 0

You can put the entry-point of an Assembly subroutine anywhere in that routine.  Your "horiz_bar" routine can be written as:

horiz:  lda #195        ; horizontal bar
        jsr chrout
        dex
horiz_bar:
        bne horiz
        rts

  • Thanks 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

Please review our Terms of Use