Jump to content
IGNORED

K65


zbyti

Recommended Posts

Well known to Atari 2600 programmers K65 compiler for 6502 by @KK/Altair

 

Sources: https://github.com/Krzysiek-K/k65

Docs: https://zbyti.github.io/k65-mkdocs/

 

K65 Language Support for Visual Studio Code

 

Playground: https://github.com/zbyti/a8-k65-playground

 

How to run:

$HOME/Programs/k65/bin/k65 @your_program.conf

First example:

main {
  {
    COLPF2=a=VCOUNT
    WSYNC=a
  } always
}

 

rainbow.k65 rainbow.conf rainbow.xex

Edited by zbyti
K65 Syntax Highlighting Extension
  • Like 2
Link to comment
Share on other sites

Starfield

var PCOLR0 = 0x02C0

data stars {
  align 256
  for x=0..255 eval [ rnd() & 255 ]
}

data speed {
  align 256
  for x=0..255 eval [ (rnd() & 3) + 1 ]
}

main {
  PCOLR0=a=14 GRAFM=a
  {
    a=0 { a?VCOUNT } !=
    x=0 {
      WSYNC=a
      HPOSM0=a=stars,x
      a=stars,x a+speed,x stars,x=a
      x++
    } !=
  } always
}

 

starfield.k65 starfield.conf starfield.xex

Edited by zbyti
another one
Link to comment
Share on other sites

Evergreen landscape by @ilmenit ;)

//------------------------------------------------------------------------------
// This is a part of Quatari 256B intro
// https://demozoo.org/productions/280623
//------------------------------------------------------------------------------

var CURSOR_Y = 0x54
var CURSOR_X = 0x55
var PREV_Y   = 0x5A
var PREV_X   = 0x5B

var iter     = 0x80

var COLOR4   = 0x02C8
var COLOR    = 0x02FB
var RND      = 0xD20A
var openmode = 0xEF9C
var drawto   = 0xF9C2

data colorHeight {
  170 150 144 144 122 122 110 110 94 94 86 86 82 80
}

main {
  a=9 call openmode
  COLOR4=a=0xB0

  iter=a=79 {
    CURSOR_X=a=iter PREV_X=a
    PREV_Y=a=1 COLOR=a=13
    {
      x=COLOR
      CURSOR_Y=a=colorHeight,x
      a=RND <0 { colorHeight,x++ }
      a=RND <0 { colorHeight,x-- }
      call drawto
      COLOR--
    } >=0
    iter--
  } !=

  {} always
}

landscape.conf  landscape.k65 landscape.xex

Edited by zbyti
change to branch on plus (negative clear)
  • Like 1
Link to comment
Share on other sites

DLI example

var VDSLST = 0x0200
var SDLST  = 0x0230

var screen = 0x8000

data displist {
  nocross
  0x70 0x70 0x70
  0x42 &<screen &>screen
  2 2 2
  0xF0
  2 2 2 2
  0x41 &<displist &>displist
}

naked dli {
  a!!
  COLPF2=a=0xDE WSYNC=a
  a??
  return_i
}

main {
  SDLST=a=&<displist SDLST+1=a=&>displist
  VDSLST=a=&<dli VDSLST+1=a=&>dli
  NMIEN=a=0xC0
  {} always
}

 

dli-example.k65 dli-example.conf dli-example.xex

Link to comment
Share on other sites

  • 2 weeks later...
//------------------------------------------------------------------------------
// Flame by koalka/bbsl/karzelki
//------------------------------------------------------------------------------

var RTCLOK = 0x0014
var SDLSTL = 0x0230
var SDLSTH = 0x0231
var SDMCTL = 0x022F
var GPRIOR = 0x026F
var COLOR4 = 0x02C8
var CHBAS  = 0x02F4

var fonts  = 0x6000
var screen = 0x6400

data dl {
  nocross
  0x42  &<screen &>screen
  for x=0..19 eval [2]
  0x41  &<dl &>dl
}

inline pause {
  a=RTCLOK { a?RTCLOK } ==
}

main {
  COLOR4=a=0x20 CHBAS=a=&>fonts
  SDLSTL=a=&<dl SDLSTH=a=&>dl
  GPRIOR=a=0x40 SDMCTL=a=0x21

  a=0 x=a y=a
  
  {
    screen,x=a
    screen+0x100,x=a
    screen+0x200,x=a
    screen+0x300,x=a
    x++
  } !=
  
  {
    { fonts,x=a x++ y++ y?8 } !=
    y=0 c- a+0x11
  } <

  {
    {
      a=screen-1,y c-
      a+screen,y a+screen+1,y a+screen+32,y a>> a>>
      screen-31,y=a

      a=screen+0xFF,y c-
      a+screen+0x100,y a+screen+0x101,y a+screen+0x120,y a>> a>>
      screen+0xE1,y=a

      a=screen+0x1FF,y c-
      a+screen+0x200,y a+screen+0x201,y a+screen+0x220,y a>> a>>
      screen+0x1E1,y=a

      y++
    } !=

    COLBK=a=10 pause

    x=0x1F {
      a=RANDOM a&15 screen+0x2E0,x=a
      x--
    } >=0

  } always
}

 

main.xex flames.zip

Edited by zbyti
add sources
  • Like 3
Link to comment
Share on other sites

Mode 9++/10++ from MADS/Atarynka 2002/02

// Mode 9++  GPRIOR=a=0x40
// Mode 10++ GPRIOR=a=0x81

var VDSLST=0x0200, SDLSTL=0x0230, SDMCTL=0x022F, GPRIOR=0x026F

var screen = 0xF000

data dl {
  nocross
  0x90 0x6F &<screen &>screen
  for x=1..58 eval [ x&1 ? 0x8F : 0x2F ]
  0x41 &<dl &>dl
}

naked dli {
  a!!
  WSYNC=a VSCROL=a=13 VSCROL=a=3
  a??
  return_i
}

main {
  VDSLST=a=&<dli VDSLST+1=a=&>dli
  SDLSTL=a=&<dl SDLSTL+1=a=&>dl
  SDMCTL=a=0x22 GPRIOR=a=0x40 NMIEN=a=0xC0
  {} always
}

main.xex mode9++.zip

Edited by zbyti
MADS
  • Like 2
Link to comment
Share on other sites

Another piece of cryptic code - enjoy! :D 

var LNFLG = 0, RTCLOK = 0x14, tmp = 0x80

main {
  a=0x3f tmp=a
  a=0xff x=0xf { HPOSP0,x=a x-- } >=0

  {
.start:
    WSYNC=a
    a=LNFLG LNFLG++
    a^0x20 HPOSP0=a a^tmp HPOSP1=a
    a=VCOUNT COLPM0=a a^0xff COLPM1=a
    a=VCOUNT a?0x40 < goto .jump
    LNFLG-- LNFLG--
.jump:
    a=VCOUNT != goto .start
    a=RTCLOK LNFLG=a a&0x7f != goto .start
    tmp++
  } always
}

main.xex hwc.zip

 

Edited by zbyti
corrections
  • Like 1
Link to comment
Share on other sites

@Gury

 

It's depends of my mood ;)

 

1. I love simplicity and flexibility of Action! but original compiler is outdated and buggy. Effectus could be solution ;)

 

2. Mad Pascal is powerful but I never like Pascal per se. I'm not feel comfortable with syntax, but Mad Pascal is unique and I'm always looking into @tebe commits on GitHub.

 

3. KickC is not yet as mature as Mad Pascal but as we can seen is blazing fast. I never studied C as I never studied English :D I'll pass for now but who knows?

 

4. Millfork is very interesting but I wait for next release with my programming journey.

 

5. BASIC is most difficult language for me but I was reading Fast Basic documentation as I was reading Advan Basic documentation.

 

6. K65 assembler is for that moment most fun for me :]

 

We will see. I'm still learning :]

Edited by zbyti
I'm still learning
  • Like 1
Link to comment
Share on other sites

Good points, zbyti. I am mostly Pascal-guy, but I am using C# and JavaScript at work. My personal PC projects are all in Free Pascal and Lazarus IDE, Atari stuff mostly in Mad Pascal and Action!. It's amazing how many languages there are for Atari, really. Maybe I will take a look at KickC and I hope it will grab more interest from other developers, too. Millfork seems like very interesting language, I noticed how many examples you prepared.

 

  • Like 1
Link to comment
Share on other sites

14 hours ago, Gury said:

I hope it will grab more interest from other developers, too.

Unfortunately, there are no more than two users per developer of a given language ;) :D 

 

The old masters prefer to write in ASM and I'm slowly drift in that direction too ;)

compiler.exe

Edited by zbyti
old windows compiler.exe
  • Like 2
Link to comment
Share on other sites

For stuff I would write in BASIC (other than simple programs to test ideas) I use cc65, it's got

a nice set of libraries and you can write code very quickly, compile and run in Altirra in minutes.

 

For anything where speed is of the essence I use machine code, my preferred assembler is

MAC/65 obviously used on an 8 bit.

  • Like 2
Link to comment
Share on other sites

  • 1 month later...
15 hours ago, zbyti said:

If someone is interested I did conversion K65 Wiki Docs to MkDocs.

 

https://zbyti.github.io/k65-mkdocs/

 

For now without Atari VCS Tutorials, Alternate VCS definitions and undocumented 6502 opcodes.

Kudos for you work, zbyti! I will read K65 docs more deeply soon.

Are XL/XE examples your work? Hats down :thumbsup:

  • Like 1
Link to comment
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.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   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.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...