Moving the cursor on Commodore computers using BASIC and ML

Поділитися
Вставка
  • Опубліковано 26 сер 2024

КОМЕНТАРІ • 12

  • @3DPDK
    @3DPDK 7 місяців тому +1

    This is a tidy way to include parameters or "arguments" to the SYS command, but there is one more BASIC way to do this without the need to load a separate ML program or write it from data statements:
    10 X=(row 0-24): Y=(column 0-39) _REM set these variables to your desired cursor location_
    20 POKE 781, X: POKE 782, Y: POKE 783, 0: SYS 65520: PRINT "whatever text"
    This works from any BASIC program. NOTE: SYS 65520 or using the Kernal jump vector insures compatibility with all versions of the C64 Kernal.
    In C64 BASIC a 'SYS' command always uses locations 780 thru 783 to set the A reg, X reg, Y reg, and status reg in that order before going to the specified SYS address. As shown in the video, 58634 is the Kernal "PLOT" routine. It performs one of two functions dependent on the carry flag state when entered. If the carry flag is cleared (783=0) it moves the cursor to the X/Y screen coordinates set by the X and Y registers. If the carry flag is set (783=1) then the routine ONLY puts the current X/Y screen coordinate values in 781 and 782 when it returns. This could be used to *find* the current location of the cursor by SYS 65520: X=PEEK(781): Y=PEEK(782).

  • @JosipRetroBits
    @JosipRetroBits Рік тому +2

    Informative and helpful video :) Having a machine language routine is the fastest and cleanest way to do this but doing it with cursor directions keys can be faster than pokes if you need to constantly move the cursor position if making a game in basic or something similar...

    • @retrooldguy9880
      @retrooldguy9880  Рік тому +2

      Check out my solitaire game I wrote in the mid 80's. They were updated to use the emulated PLOT and CHAR but I originally used LEFT$(down$,x), LEFT$(right$,y), to simulate a PLOTx,y. sites.google.com/view/retroken/downloads?authuser=0

  • @joeplocki3525
    @joeplocki3525 Рік тому +2

    Hey, I just found you today, and subscribed. As I have a C64 sitting around, I'm finding your stuff interesting. What source are you using for the kernel function descriptions? That looks incredibly useful...

    • @retrooldguy9880
      @retrooldguy9880  Рік тому +2

      Thanks for watching. I updated the description to include the reference book

  • @Ensign_Cthulhu
    @Ensign_Cthulhu Рік тому +1

    5:19 I had no idea the SYS command could accept parameters. I am assuming this is a function of the GETBYTC routine, and that I could go on calling it for as long as I had values in commas after the SYS?

    • @retrooldguy9880
      @retrooldguy9880  Рік тому +1

      Yes the GETBYTC function is parsing the command and yes, you can keep on going. I've never used more than 3 parameters myself.

  • @Trevorodunne
    @Trevorodunne Рік тому +1

    Could you add a color code to your program EXAMPLE sys 828,10,15,colour

    • @retrooldguy9880
      @retrooldguy9880  Рік тому +2

      I'm sure you could. You'd just need to execute an additional GETBYTEC routine and STX $0286 (address of the current foreground color)

    • @frankmichielli9965
      @frankmichielli9965 Рік тому

      @@retrooldguy9880 As not a ML programmer, this would be great if you could post the code and the basic loader as well here.

    • @retrooldguy9880
      @retrooldguy9880  Рік тому +4

      @frankmichielli9965
      Since the routine was just meant to position the cursor, a color can be embedded in the subsequent print statement. Anyway...here is the addition. The color change will remain until changed again.
      Use SYS828,color,row,column
      *= $033c
      jsr $b79b ; GETBYTEC
      stx $0286 ; foreground color
      jsr $b79b
      txa
      pha
      jsr $b79b
      txa
      tay
      pla
      tax
      clc
      jmp $fff0
      10 fori=828to849:reada:pokei,a:next
      828 data 32,155,183,142,134,2,32
      835 data 155,183,138,72,32,155,183
      842 data 138,168,104,170,24,76,240,255

    • @TheUtuber999
      @TheUtuber999 11 місяців тому

      @@retrooldguy9880 Thanks for the great tutorial! I know it uses a couple more bytes when configured this way, but I like the order of parameters as SYS 828, row, column, color...
      *=$033c
      jsr $b79b
      txa
      pha
      jsr $b79b
      txa
      pha
      jsr $b79b
      stx $0286
      pla
      tay
      pla
      tax
      clc
      jmp $fff0
      Sample program...
      10 forx=828to851:readn:pokex,n:next
      20 poke53281,0:printchr$(147);
      30 forx=0to24:c=c+1:sys828,x,(abs(12-x))*2,c:ifc>14thenc=0
      40 print"commodore 64!";:next
      50 getk$:ifk$=""then50
      60 data32,155,183,138,72,32,155,183,138,72,32,155,183,142,134,2,104,168,104,170
      70 data24,76,240,255