2020-09-20 23:49:36 +02:00
|
|
|
%import syslib
|
2020-11-22 18:17:43 +01:00
|
|
|
%import test_stack
|
2020-09-20 23:49:36 +02:00
|
|
|
%import textio
|
2022-04-12 23:58:19 +02:00
|
|
|
%import math
|
2020-08-21 16:53:56 +02:00
|
|
|
|
2020-10-02 00:34:12 +02:00
|
|
|
; converted from plasma test program for cc65.
|
|
|
|
; which is (w)2001 by groepaz/hitmen
|
|
|
|
;
|
|
|
|
; Cleanup and porting to C by Ullrich von Bassewitz.
|
|
|
|
; Converted to prog8 by Irmen de Jong.
|
2020-08-21 16:53:56 +02:00
|
|
|
|
2020-11-03 21:31:08 +01:00
|
|
|
|
2020-11-25 00:18:07 +01:00
|
|
|
|
2020-08-21 16:53:56 +02:00
|
|
|
main {
|
|
|
|
const uword SCREEN1 = $E000
|
|
|
|
const uword SCREEN2 = $E400
|
|
|
|
const uword CHARSET = $E800
|
|
|
|
|
|
|
|
const ubyte PAGE1 = ((SCREEN1 >> 6) & $F0) | ((CHARSET >> 10) & $0E)
|
|
|
|
const ubyte PAGE2 = ((SCREEN2 >> 6) & $F0) | ((CHARSET >> 10) & $0E)
|
|
|
|
|
|
|
|
sub start() {
|
2020-08-30 00:15:18 +02:00
|
|
|
txt.color(1)
|
2022-04-02 17:53:24 +02:00
|
|
|
txt.clear_screen()
|
2020-08-27 18:10:22 +02:00
|
|
|
txt.print("creating charset...\n")
|
2020-08-21 16:53:56 +02:00
|
|
|
makechar()
|
|
|
|
|
|
|
|
ubyte block = c64.CIA2PRA
|
2020-08-21 17:44:44 +02:00
|
|
|
; ubyte v = c64.VMCSB
|
2020-08-21 16:53:56 +02:00
|
|
|
c64.CIA2PRA = (block & $FC) | (lsb(SCREEN1 >> 14) ^ $03)
|
|
|
|
|
2020-11-25 00:18:07 +01:00
|
|
|
repeat {
|
2020-08-21 16:53:56 +02:00
|
|
|
doplasma(SCREEN1)
|
|
|
|
c64.VMCSB = PAGE1
|
|
|
|
doplasma(SCREEN2)
|
|
|
|
c64.VMCSB = PAGE2
|
|
|
|
}
|
2020-08-21 17:44:44 +02:00
|
|
|
|
|
|
|
; restore screen (if you want)
|
|
|
|
;c64.VMCSB = v
|
|
|
|
;c64.CIA2PRA = block
|
2020-08-27 18:10:22 +02:00
|
|
|
;txt.print("done!\n")
|
2020-11-22 18:17:43 +01:00
|
|
|
;test_stack.test()
|
|
|
|
;repeat {
|
|
|
|
;}
|
2020-08-21 16:53:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
; several variables outside of doplasma to make them retain their value
|
|
|
|
ubyte c1A
|
|
|
|
ubyte c1B
|
|
|
|
ubyte c2A
|
|
|
|
ubyte c2B
|
|
|
|
|
|
|
|
sub doplasma(uword screen) {
|
|
|
|
ubyte[40] xbuf
|
|
|
|
ubyte[25] ybuf
|
|
|
|
ubyte c1a = c1A
|
|
|
|
ubyte c1b = c1B
|
|
|
|
ubyte c2a = c2A
|
|
|
|
ubyte c2b = c2B
|
2020-08-21 17:44:44 +02:00
|
|
|
ubyte @zp x
|
|
|
|
ubyte @zp y
|
2020-08-21 16:53:56 +02:00
|
|
|
|
2020-08-25 00:35:51 +02:00
|
|
|
for y in 24 downto 0 {
|
2022-04-12 23:58:19 +02:00
|
|
|
ybuf[y] = math.sin8u(c1a) + math.sin8u(c1b)
|
2020-08-21 16:53:56 +02:00
|
|
|
c1a += 4
|
|
|
|
c1b += 9
|
|
|
|
}
|
|
|
|
c1A += 3
|
|
|
|
c1B -= 5
|
2020-08-25 00:35:51 +02:00
|
|
|
for x in 39 downto 0 {
|
2022-04-12 23:58:19 +02:00
|
|
|
xbuf[x] = math.sin8u(c2a) + math.sin8u(c2b)
|
2020-08-21 16:53:56 +02:00
|
|
|
c2a += 3
|
|
|
|
c2b += 7
|
|
|
|
}
|
|
|
|
c2A += 2
|
|
|
|
c2B -= 3
|
2020-09-30 19:57:16 +02:00
|
|
|
|
2020-08-25 00:35:51 +02:00
|
|
|
for y in 24 downto 0 {
|
|
|
|
for x in 39 downto 0 {
|
2020-09-30 19:57:16 +02:00
|
|
|
; using a temp var here to enable expression optimization that can't be done on a 'problematic' ROM/RAM memory location
|
2021-11-28 18:59:36 +01:00
|
|
|
ubyte @zp cc = xbuf[x] + ybuf[y]
|
2021-01-23 15:52:27 +01:00
|
|
|
@(screen+x) = cc
|
2020-09-30 19:57:16 +02:00
|
|
|
; this is the fastest way to do this inner part:
|
2020-08-25 00:59:02 +02:00
|
|
|
; %asm {{
|
2021-11-28 18:59:36 +01:00
|
|
|
; ldy y
|
|
|
|
; lda ybuf,y
|
|
|
|
; ldy x
|
2020-08-25 00:59:02 +02:00
|
|
|
; clc
|
2021-11-28 18:59:36 +01:00
|
|
|
; adc xbuf,y
|
2020-08-25 16:36:31 +02:00
|
|
|
; sta (screen),y
|
2020-08-25 00:59:02 +02:00
|
|
|
; }}
|
2021-01-23 15:52:27 +01:00
|
|
|
}
|
|
|
|
screen += 40
|
2020-08-21 16:53:56 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sub makechar() {
|
|
|
|
ubyte[8] bittab = [ $01, $02, $04, $08, $10, $20, $40, $80 ]
|
|
|
|
ubyte c
|
|
|
|
for c in 0 to 255 {
|
2022-04-12 23:58:19 +02:00
|
|
|
ubyte @zp s = math.sin8u(c)
|
2020-08-21 16:53:56 +02:00
|
|
|
ubyte i
|
|
|
|
for i in 0 to 7 {
|
|
|
|
ubyte b=0
|
|
|
|
ubyte @zp ii
|
|
|
|
for ii in 0 to 7 {
|
|
|
|
; use 16 bit rng for a bit more randomness instead of the 8-bit rng
|
2022-10-22 16:35:57 +02:00
|
|
|
if math.rnd() > s {
|
2020-08-21 16:53:56 +02:00
|
|
|
b |= bittab[ii]
|
|
|
|
}
|
|
|
|
}
|
2020-09-19 23:23:32 +02:00
|
|
|
@(CHARSET + i + c*$0008) = b
|
2020-08-21 16:53:56 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|