Login
Back to forumReply to this topicGo to last reply

Posted By

zbyti
on 2021-06-26
17:46:20
 K65 assembler

I begin to learn some demoeffects on C+4 with K65 assembler

K65 Docs
K65 Source
K65 Wiki

//------------------------------------------------------------------------------
// Scrolling rainbow - a scrolling rainbow effect in 64 bytes
//
// Written by Csabo of LOD 2007
// Converted to K65 by zbyti
//
// Uses no zeropage variables, solid timing
// Carfully chosen number of colors + rasterline's height: gives scrolling effect
//------------------------------------------------------------------------------


var TED_06=0xFF06, TED_13=0xFF13, TED_19=0xFF19, TED_1E=0xFF1E

// one rasterbar (14 lines high)
data lum {
0x00 0x20 0x30 0x40 0x50 0x60 0x70
0x70 0x60 0x50 0x40 0x30 0x20 0x00
}

// rainbow colors (11 colors)
data col {
2 11 4 6 3 12 5 10 7 9 8
}

main {
i+ // no interrupts
a=TED_13 a|0b00000010 TED_13=a // single clock (more clear then ROL $FF13)
a=TED_06 a^0b00010000 TED_06=a // screen off (more clear then ROR $FF06)
x=0
{
y=13 x++
{
x?11 =={ x=0 } // placed here as padding
{ a=TED_1E } >=0 // horizontal sync to $80!

a=col,x a|lum,y TED_19=a
y--
} >=0

} <0
}


this example

Of course this is my exercise, so... to be readable I didn't keep original 64 byte size.

Posted By

Litwr
on 2021-06-26
15:55:00
 Re: K65 assembler

Your demo works. It shows the same effects as Scrolling Rainbow. K65 looks interesting - IMHO it would be good to add it to the list of the plus4 tools. The 6502 assembler is, indeed, too low level so a higher level language can be useful for some tasks.

Posted By

Doug
on 2021-06-26
17:59:56
 Re: K65 assembler

Hey zbyti. I love the concept of K65. It's a neat idea - something between an HL and an assembler. Cool! I think I'll have a play with it and see how it feels. I've seen others attempt what you've done here using asm macros, which always struck me as a little clunky and restrictive. Presenting it as a very simple language, closely tied to the machine architecture like this is a novel idea. Most of my stuff winds up relying heavily on self modifying code, so I'm not sure how that would fit with this model, but it's a great idea nevertheless. Nice one.

Posted By

zbyti
on 2021-06-26
19:04:37
 Re: K65 assembler

@Doug famous KK/Altair is a creator of K65 :]

Posted By

gerliczer
on 2021-06-27
01:36:34
 Re: K65 assembler

@Doug: I wouldn't be so sure that it is a novel idea. There is HLA (High Level Assembly) for x86 which is also based on that concept. I found a repository of the project at Sorceforge with file and folders dated from early 2008 and that version was already 1.101. And I managed to find a clue that it began in 1996. Kick Assembler seems to follow that path, too. Its version history spans back to 2006. And these are only those projects I heard of. The concept could originate from way earlier. There could have been implementations for other instruction architectures.

Posted By

carrion
on 2021-06-27
03:34:15
 Re: K65 assembler

@zbyti
I was tempted to try this assembler by KK some time ago when I started working with KickC on my RJA game. Actually I saw a polish "YouTuber" Jelcynek using this assembler to write a game and his work inspired me to do start my attempts with KickC + KickAss.
I ave to say that the syntax of K65 is not very readable to me though. O Preferred to stay with C syntax and have close connection to Kick Asm.

Nice attempts though. Thanks! Are you planning to do more scene related stuff on +4? happy
If you need gfx you know where to find me.

Posted By

zbyti
on 2021-06-27
04:54:49
 Re: K65 assembler

@carrion

Yes, the K65 looks cryptic at first glance, but this is a matter of time and practice, I like the concept behind this assembler and I have plan tu use it more often.

Yes, I would like to create some "effects" maybe a shorter production but I don't know if I have enough skills for that wink

I will definitely try to write a game for C+4 and you will be a first person I will ask for help if I have something promising.




To make it less mysteriously below product of the compilation:


; section lum
lum
.byte #$00
; 0x00 0x20 0x30 0x40 0x50 0x60 0x70
.byte #$20
.byte #$30
.byte #$40
.byte #$50
.byte #$60
.byte #$70
; 0x70 0x60 0x50 0x40 0x30 0x20 0x00
.byte #$70
.byte #$60
.byte #$50
.byte #$40
.byte #$30
.byte #$20
.byte #$00
; }
; section col
col
.byte #$02
; 2 11 4 6 3 12 5 10 7 9 8
.byte #$0B
.byte #$04
.byte #$06
.byte #$03
.byte #$0C
.byte #$05
.byte #$0A
.byte #$07
.byte #$09
.byte #$08
; }
; section main
main
SEi
; i+ // no interrupts
; a=TED_13 a|0b00000010 TED_13=a // single clock (more clear then ROL $FF13)
LDA TED_13
ORA #$02
STA TED_13
; a=TED_06 a^0b00010000 TED_06=a // screen off (more clear then ROR $FF06)
LDA TED_06
EOR #$10
STA TED_06
; x=0
LDX #$00
; {
__label_1
; y=13 x++
LDY #$0D
INX
; {
__label_2
; x?11 =={ x=0 } // placed here as padding
CPX #$0B
BNE __label_3
LDX #$00
__label_3
; { a=TED_1E } >=0 // horizontal sync to $80!
__label_4
LDA TED_1E
BPL __label_4
;
; a=col,x a|lum,y TED_19=a
LDA col,X
ORA lum,Y
STA TED_19
; y--
DEY
; } >=0
BPL __label_2
;
; } <0
BMI __label_1
; }
; section __start
JMP main


Posted By

Basman
on 2021-06-27
18:54:44
 Re: K65 assembler

There is also Macross, made by Lucasfilm in 1984 and released in 2016 or so:
https://www.pagetable.com/?p=848

It's interesting, though I don't think I would use a system that produces binaries so much different from the source code, because it would be hard to debug (for me at least).

Posted By

zbyti
on 2021-06-30
08:10:29
 Re: K65 assembler

@Basman it's interesting because KK/Altair once said (asked why he developed K65 - passion or obsession):

"K65 already saved me more time than it took to write, and enabled making some cool things I wouldn't dare to do with classic assembler, so they sometimes point in the same direction. happy"

He used K65 to develop some winner demos on Atari VCS and game (Druidarium) on A8.



--- EDIT ---

self modifying code example Neverten


//------------------------------------------------------------------------------
// Neverten by Bitglamour
//
// https://plus4world.powweb.com/software/Neverten
//
// Converted to K65 by zbyti
//------------------------------------------------------------------------------

var SCREEN_COL=0x0900, SCREEN_CH=0x0D00

var CHSET=0xD180
var NORSCREEN=0xD888

var TED_15=0xFF15, TED_19=0xFF19


main {
a=0x41 TED_15=a TED_19=a

//ESC-N Set normal screen, Clear screen, Cursor on Home
call NORSCREEN

{
.chr: a=0x80 .chars+1=a x=0
{
.chars: a=CHSET y=0
{
c- a<<< a!!
a=0xA0 .scrch: SCREEN_CH,y=a
a=0 c+?{ a=0xFF } .scrcol: SCREEN_COL,y=a
a??
y++ y?8
} !=
c- a=.scrch+1 a+40 .scrch+1=a .scrcol+1=a
.chars+1++
a=.chars+1 a?0xD0 =={ .chars+1=a=0x80 }
x++ x?7
} !=
a=0 .scrch+1=a .scrcol+1=a
.chr+1++ a=.chr+1 a?0xD0 =={ .chr+1=a=0x80 }
{
{ y++ } !=
x++ x?0x48
} !=
} always
}

this example



--- EDIT ---

Moving At High Velocity


//------------------------------------------------------------------------------
// Moving At High Velocity by Cobini
//
// https://plus4world.powweb.com/software/Moving_At_High_Velocity_5000
//
// Converted to K65 by zbyti
//------------------------------------------------------------------------------

var tmp=0x10
var OS_CH_COLOR=0x053B
var SCREEN=0x0C00
var NORSCREEN=0xD888
var TED_7=0xFF07, TED_15=0xFF15, TED_19=0xFF19, TED_1D=0xFF1D

main {
OS_CH_COLOR=a=0x67

//ESC-N Set normal screen, Clear screen, Cursor on Home
call NORSCREEN

TED_15=a=0x1D TED_19=a

{
x=0x24 { x?TED_1D } !=

{
{ a=TED_1D a&7 a?3 } !=

a=x a+tmp,x tmp,x=a
a>> a&7 TED_7=a

y++
a=0x7B SCREEN,y=a SCREEN+0x100,y=a SCREEN+0x200,y=a SCREEN+0x300,y=a
x--
} !=
} ==
}

this example



--- EDIT ---


//------------------------------------------------------------------------------
// Mikropyros by Luca
//
// https://plus4world.powweb.com/software/Mikropyros
//
// Converted to K65 by zbyti
//------------------------------------------------------------------------------

var pagelo = 0xE0
var pagehi = 0xE1
var screenlo = 0xE2
var screenhi = 0xE3
var colorlo = 0xE4
var colorhi = 0xE5
var height = 0xE6

var tmp=0x7FE7

var TED_0=0xFF00, TED_15=0xFF15, TED_19=0xFF19, TED_1E=0xFF1E, TED_3F=0xFF3F

main {
align 32 //this prevent override main code by the doFlame loop

i+ TED_3F=a
height=a=0xA0 TED_15=a TED_19=a

{
a=height a?2 !={ height-- }
x=0x29
{
a=TED_0 a^TED_1E a&0x3F tmp,x=a
x--
} !=
pagelo=x screenlo=x colorlo=x
pagehi=a=0x7C screenhi=a=0x0C colorhi=a=0x08

{ //doFlame

{
c-
y=0x27 a=(pagelo),y
y++ a+(pagelo),y
y++ a+(pagelo),y
y=0 a+(pagelo),y
a-height <{ a=y }
a>> a>> (pagelo),y=a a>> a>>
a?8 >=0{ a=8 } x=a
a=colors,x (colorlo),y=a
a=chars-1,x (screenlo),y=a
pagelo++ screenlo++ colorlo++
} !=

colorhi++ screenhi++ pagehi++

} >=0

} <0
}

data colors {
0 0x0E 0x14 0x2B 0x32 0x42 0x58 0x67 0x71
}

data chars {
0x2E 0xD6 0x51 0xE0 0xE0 0xE0 0xE0 0xE0
}




--- EDIT ---


//------------------------------------------------------------------------------
// C+4 palette by zbyti
//------------------------------------------------------------------------------

forum engine striped out my code, look at github


this example



Back to topReply to this topic


Copyright © Plus/4 World Team, 2001-2024