plasma: work on lo-res plasma

This commit is contained in:
Vince Weaver 2021-01-09 01:41:44 -05:00
parent 481d2de4fa
commit 07b1effec2
12 changed files with 648 additions and 31 deletions

BIN
graphics/gr/plasma/HELLO Normal file

Binary file not shown.

View File

@ -0,0 +1,30 @@
include ../../../Makefile.inc
DOS33 = ../../../utils/dos33fs-utils/dos33
TOKENIZE = ../../../utils/asoft_basic-utils/tokenize_asoft
LINKERSCRIPTS = ../../../linker_scripts
all: plasma.dsk
plasma.dsk: HELLO PLASMA
cp empty.dsk plasma.dsk
$(DOS33) -y plasma.dsk SAVE A HELLO
$(DOS33) -y plasma.dsk BSAVE -a 0x1000 PLASMA
###
HELLO: hello.bas
$(TOKENIZE) < hello.bas > HELLO
###
PLASMA: plasma.o
ld65 -o PLASMA plasma.o -C $(LINKERSCRIPTS)/apple2_1000.inc
plasma.o: plasma.s gr_plot.s gr_scrn.s
ca65 -o plasma.o plasma.s -l plasma.lst
###
clean:
rm -f *~ *.o *.lst PLASMA

Binary file not shown.

View File

@ -0,0 +1,101 @@
;; HARDWARE LOCATIONS
KEYPRESS = $C000
KEYRESET = $C010
;; SOFT SWITCHES
CLR80COL = $C000 ; PAGE0/PAGE1 normal
SET80COL = $C001 ; PAGE0/PAGE1 switches PAGE0 in Aux instead
EIGHTYCOLOFF = $C00C
EIGHTYCOLON = $C00D
TBCOLOR = $C022 ; IIgs text foreground / background colors
NEWVIDEO = $C029 ; IIgs graphics modes
SPEAKER = $C030
CLOCKCTL = $C034 ; bits 0-3 are IIgs border color
SET_GR = $C050
SET_TEXT = $C051
FULLGR = $C052
TEXTGR = $C053
PAGE0 = $C054
PAGE1 = $C055
LORES = $C056 ; Enable LORES graphics
HIRES = $C057 ; Enable HIRES graphics
AN3 = $C05E ; Annunciator 3
PADDLE_BUTTON0 = $C061
PADDLE_BUTTON1 = $C062
PADDL0 = $C064
PTRIG = $C070
;; BASIC ROUTINES
NORMAL = $F273
;; MONITOR ROUTINES
PLOT = $F800 ;; PLOT AT Y,A
HLINE = $F819 ;; HLINE Y,$2C at A
VLINE = $F828 ;; VLINE A,$2D at Y
CLRSCR = $F832 ;; Clear low-res screen
CLRTOP = $F836 ;; clear only top of low-res screen
SETCOL = $F864 ;; COLOR=A
ROM_TEXT2COPY = $F962 ;; iigs
SETTXT = $FB36
SETGR = $FB40
TABV = $FB5B ;; VTAB to A
ROM_MACHINEID = $FBB3 ;; iigs
BELL = $FBDD ;; ring the bell
BASCALC = $FBC1 ;;
VTAB = $FC22 ;; VTAB to CV
HOME = $FC58 ;; Clear the text screen
WAIT = $FCA8 ;; delay 1/2(26+27A+5A^2) us
CROUT1 = $FD8B
SETINV = $FE80 ;; INVERSE
SETNORM = $FE84 ;; NORMAL
COUT = $FDED ;; output A to screen
COUT1 = $FDF0 ;; output A to screen
COLOR_BLACK = 0
COLOR_RED = 1
COLOR_DARKBLUE = 2
COLOR_PURPLE = 3
COLOR_DARKGREEN = 4
COLOR_GREY = 5
COLOR_MEDIUMBLUE = 6
COLOR_LIGHTBLUE = 7
COLOR_BROWN = 8
COLOR_ORANGE = 9
COLOR_GREY2 = 10
COLOR_PINK = 11
COLOR_LIGHTGREEN = 12
COLOR_YELLOW = 13
COLOR_AQUA = 14
COLOR_WHITE = 15
COLOR_BOTH_BLACK = $00
COLOR_BOTH_RED = $11
COLOR_BOTH_DARKBLUE = $22
COLOR_BOTH_DARKGREEN = $44
COLOR_BOTH_GREY = $55
COLOR_BOTH_MEDIUMBLUE = $66
COLOR_BOTH_LIGHTBLUE = $77
COLOR_BOTH_BROWN = $88
COLOR_BOTH_ORANGE = $99
COLOR_BOTH_PINK = $BB
COLOR_BOTH_LIGHTGREEN = $CC
COLOR_BOTH_YELLOW = $DD
COLOR_BOTH_AQUA = $EE
COLOR_BOTH_WHITE = $FF

View File

@ -0,0 +1,2 @@
5 HOME
10 PRINT CHR$(4);"CATALOG"

Binary file not shown.

122
graphics/gr/plasma/plasma.s Normal file
View File

@ -0,0 +1,122 @@
; do a (hopefully fast) plasma
; 151
.include "zp.inc"
.include "hardware.inc"
CTEMP = $FC
SAVEOFF = $FD
SAVEX = $FE
SAVEY = $FF
;================================
; Clear screen and setup graphics
;================================
jsr SETGR
lda #0
sta DISP_PAGE
lda #4
sta DRAW_PAGE
;col = ( 8.0 + (sintable[xx&0xf])
; + 8.0 + (sintable[yy&0xf])
; ) / 2;
ldy #0
create_yloop:
ldx #0
create_xloop:
clc
lda #15
adc sinetable,X
adc sinetable,Y
lsr
lookup_smc:
sta lookup,X
inx
cpx #16
bne create_xloop
clc
lda lookup_smc+1
adc #16
sta lookup_smc+1
lda #0
adc lookup_smc+2
sta lookup_smc+2
iny
cpy #16
bne create_yloop
forever_loop:
; cycle colors
ldx #0
cycle_loop:
inc lookup,X
inx
bne cycle_loop
; plot
ldx #0 ; YY=0
plot_yloop:
ldy #0 ; XX = 0
plot_xloop:
stx SAVEX ; SAVE YY
sty SAVEY ; SAVE XX
tya
and #$f
sta CTEMP
txa
and #$f
asl
asl
asl
asl
ora CTEMP
tax
lda lookup,X
and #$f
tax
lda colorlookup,X
jsr SETCOL
lda SAVEX
jsr PLOT ; plot at Y,A
ldy SAVEY ; restore XX
ldx SAVEX ; restore YY
iny
cpy #40
bne plot_xloop
inx
cpx #40
bne plot_yloop
beq forever_loop
sinetable:
.byte $00,$03,$05,$07,$08,$07,$05,$03
.byte $00,$FD,$FB,$F9,$F8,$F9,$FB,$FD
colorlookup:
.byte $00,$00,$05,$05,$07,$07,$0f,$0f
.byte $07,$07,$06,$06,$02,$02,$05,$05
lookup:

158
graphics/gr/plasma/zp.inc Normal file
View File

@ -0,0 +1,158 @@
;; Zero page monitor routines addresses
;; LZSA addresses
NIBCOUNT = $00
WNDLFT = $20
WNDWDTH = $21
WNDTOP = $22
WNDBTM = $23
CH = $24
CV = $25
GBASL = $26
GBASH = $27
BASL = $28
BASH = $29
H2 = $2C
V2 = $2D
MASK = $2E
COLOR = $30
INVFLG = $32
; More zero-page addresses
; we try not to conflict with anything DOS, MONITOR or BASIC related
;; Flying Routine Only
TURNING = $60
;SCREEN_X = $61 ; not used?
SCREEN_Y = $62
ANGLE = $63
HORIZ_SCALE_I = $64
HORIZ_SCALE_F = $65
SCALE_I = $64
SCALE_F = $65
FACTOR_I = $66
FACTOR_F = $67
DX_I = $68
DX_F = $69
SPACEX_I = $6A
SPACEX_F = $6B
CX_I = $6C
CX_F = $6D
DY_I = $6E
DY_F = $6F
SPACEY_I = $70
SPACEY_F = $71
CY_I = $72
CY_F = $73
TEMP_I = $74
TEMP_F = $75
DISTANCE_I = $76
DISTANCE_F = $77
SPACEZ_I = $78
SPACEZ_F = $79
DRAW_SPLASH = $7A
SPEED = $7B
SPLASH_COUNT = $7C
OVER_LAND = $7D
NUM1L = $7E
NUM1H = $7F
NUM2L = $80
NUM2H = $81
RESULT = $82 ; 83,84,85
NEGATE = $86 ; UNUSED?
LAST_SPACEX_I = $87
LAST_SPACEY_I = $88
LAST_MAP_COLOR = $89
COLOR_MASK = $8A
;; World Map Only
ODD = $7B
DIRECTION = $7C
REFRESH = $7D
ON_BIRD = $7E
MOVED = $7F
STEPS = $80
TFV_X = $81
TFV_Y = $82
NEWX = $83
NEWY = $84
MAP_X = $85
GROUND_COLOR = $86
LEVEL_OVER = $A0
JOYSTICK_ENABLED= $A1
FRAMEL = $A2
FRAMEH = $A3
WHICH_LOAD = $A4
MENU_RESULT = $A5
SOUND_STATUS = $A6
SOUND_DISABLED = $80
SOUND_IN_LC = $01 ; $01 sound effects in language card
SOUND_MOCKINGBOARD = $02 ; mockingboard detected
JS_BUTTON_STATE = $A7
COLOR1 = $E0
COLOR2 = $E1
MATCH = $E2
XX = $E3
YY = $E4
SHIPY = $E4
YADD = $E5
LOOP = $E6
;MEMPTRL = $E7
;MEMPTRH = $E8
NAMEL = $E9
NAMEH = $EA
NAMEX = $EB
CHAR = $EC
DISP_PAGE = $ED
DRAW_PAGE = $EE
FIRST = $F0
LASTKEY = $F1
PADDLE_STATUS = $F2
XPOS = $F3
YPOS = $F4
TEMP = $FA
RUN = $FA
TEMP2 = $FB
TEMPY = $FB
INL = $FC
INH = $FD
OUTL = $FE
OUTH = $FF
; read any file slot 6 version
; based on FASTLD6 and RTS copyright (c) Peter Ferrie 2011-2013,2018
; modified to assemble with ca65 -- vmw
; added code to patch it to run from current disk slot -- vmw
adrlo = $26 ; constant from boot prom
adrhi = $27 ; constant from boot prom
tmpsec = $3c ; constant from boot prom
reqsec = $3d ; constant from boot prom
sizelo = $44
sizehi = $45
secsize = $46
ldsizel = $70
ldsizeh = $71
namlo = $7b
namhi = $7c
step = $7d ; state for stepper motor
tmptrk = $7e ; temporary copy of current track
phase = $7f ; current phase for /seek

View File

@ -6,8 +6,9 @@ SDL_LIBS= `sdl-config --libs`
SDL_INCLUDE= `sdl-config --cflags`
GR_SIM = ../gr-sim.a
all: plasma
all: plasma plasma_fixed
###
plasma: plasma.o $(GR_SIM)
$(CC) -o plasma plasma.o \
@ -16,6 +17,17 @@ plasma: plasma.o $(GR_SIM)
plasma.o: plasma.c
$(CC) $(CFLAGS) -c plasma.c
###
plasma_fixed: plasma_fixed.o $(GR_SIM)
$(CC) -o plasma_fixed plasma_fixed.o \
$(GR_SIM) $(LFLAGS) $(SDL_LIBS)
plasma_fixed.o: plasma_fixed.c
$(CC) $(CFLAGS) -c plasma_fixed.c
###
clean:
rm -f *~ *.o plasma

View File

@ -10,29 +10,28 @@
#include "tfv_zp.h"
#include "gr-sim.h"
#define pi 3.14159265358979323846264338327950
#define PI 3.14159265358979323846264338327950
#if 0
#if 1
static unsigned char color_lookup[]={0x0, 0x0, 0x5, 0x5,
0x7, 0x7, 0xf, 0xf,
0x7, 0x7, 0x6, 0x6,
0x2, 0x2, 0x5, 0x5};
#endif
#else
static unsigned char color_lookup[]={0x0, 0x5, 0x7, 0xf,
0x7, 0x6, 0x2, 0x5,
0x0, 0x5, 0x7, 0xf,
0x7, 0x6, 0x2, 0x5};
#endif
static int offscreen[40][40];
int main(int argc, char **argv) {
int ch,xx,yy,col;
// double dx,dy,dv;
double r;
double sec=0.0;
grsim_init();
@ -43,33 +42,32 @@ int main(int argc, char **argv) {
ram[DRAW_PAGE]=0x0;
for(yy=0;yy<40;yy++) {
for(xx=0;xx<40;xx++) {
// col = ( 32.0 + (32.0 * sin(xx / 4.0))
// + 32.0 + (32.0 * sin(yy / 4.0))
// ) / 2;
col = ( 8.0 + (8.0 * sin(xx *PI/8.0))
+ 8.0 + (8.0 * sin(yy *PI/8.0))
) / 2;
offscreen[xx][yy]=col;
}
}
while(1) {
// sec+=0.00625;
sec+=0.000625;
for(yy=0;yy<48;yy++) {
for(yy=0;yy<40;yy++) {
for(xx=0;xx<40;xx++) {
// r=sin(8*((xx*2)*sin(sec/2)+(yy*2)*cos(sec/4))+sec/8);
r=sin(8*((xx*2)*sin(sec/2)+(yy*4)*cos(sec/4))+sec/128);
// printf("%d %d %f %f %f %f\n",xx,yy,dx,dy,dv,r);
// setcolor(COLOR(255*fabs(sin(dv*pi)),255*fabs(sin(dv*pi + 2*pi/3)),255*fabs(sin(dv*pi + 4*pi/3))));
col=(int)((r+1)*8);
if ((col<0) || (col>15)) {
printf("Invalid color %d\n",col);
}
col=offscreen[xx][yy];
color_equals(color_lookup[col]);
col++;
col&=0xf;
offscreen[xx][yy]=col;
plot(xx,yy);
}
}
grsim_update();
@ -82,9 +80,9 @@ int main(int argc, char **argv) {
if (ch) break;
}
}
usleep(20000);
usleep(200000);
}
return 0;
}

View File

@ -0,0 +1,104 @@
/* for demoscene, you need a plasma effect... */
/* https://rosettacode.org/wiki/Plasma_effect */
/* https://www.bidouille.org/prog/plasma */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <math.h>
#include "tfv_zp.h"
#include "gr-sim.h"
#define PI 3.14159265358979323846264338327950
#if 1
static unsigned char color_lookup[]={0x0, 0x0, 0x5, 0x5,
0x7, 0x7, 0xf, 0xf,
0x7, 0x7, 0x6, 0x6,
0x2, 0x2, 0x5, 0x5};
#else
static unsigned char color_lookup[]={0x0, 0x5, 0x7, 0xf,
0x7, 0x6, 0x2, 0x5,
0x0, 0x5, 0x7, 0xf,
0x7, 0x6, 0x2, 0x5};
#endif
static int offscreen[40][40];
static int sintable[16];
int main(int argc, char **argv) {
int ch,xx,yy,col;
grsim_init();
gr();
soft_switch(MIXCLR);
clear_screens();
ram[DRAW_PAGE]=0x0;
for(xx=0;xx<16;xx++) {
sintable[xx]=8.0*sin(xx*PI/8.0);
// printf("%2lf\n",(double)sintable[xx]);
printf("%02X\n",sintable[xx]);
}
for(yy=0;yy<40;yy++) {
for(xx=0;xx<40;xx++) {
// col = ( 32.0 + (32.0 * sin(xx / 4.0))
// + 32.0 + (32.0 * sin(yy / 4.0))
// ) / 2;
// col = ( 8.0 + (8.0 * sin(xx *PI/8.0))
// + 8.0 + (8.0 * sin(yy *PI/8.0))
// ) / 2;
col = ( 8.0 + (sintable[xx&0xf])
+ 8.0 + (sintable[yy&0xf])
) / 2;
printf("%d %d: %lf %lf\n",xx,yy,8.0*sin(xx*PI/8.0),(double)sintable[xx&0xf]);
offscreen[xx][yy]=col;
}
}
while(1) {
for(yy=0;yy<40;yy++) {
for(xx=0;xx<40;xx++) {
col=offscreen[xx][yy];
color_equals(color_lookup[col]);
col++;
col&=0xf;
offscreen[xx][yy]=col;
plot(xx,yy);
}
}
grsim_update();
ch=grsim_input();
if (ch=='q') exit(0);
if (ch==' ') {
while(1) {
ch=grsim_input();
if (ch) break;
}
}
usleep(200000);
}
return 0;
}

View File

@ -0,0 +1,90 @@
/* for demoscene, you need a plasma effect... */
/* https://rosettacode.org/wiki/Plasma_effect */
/* https://www.bidouille.org/prog/plasma */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <math.h>
#include "tfv_zp.h"
#include "gr-sim.h"
#define pi 3.14159265358979323846264338327950
#if 0
static unsigned char color_lookup[]={0x0, 0x0, 0x5, 0x5,
0x7, 0x7, 0xf, 0xf,
0x7, 0x7, 0x6, 0x6,
0x2, 0x2, 0x5, 0x5};
#endif
static unsigned char color_lookup[]={0x0, 0x5, 0x7, 0xf,
0x7, 0x6, 0x2, 0x5,
0x0, 0x5, 0x7, 0xf,
0x7, 0x6, 0x2, 0x5};
int main(int argc, char **argv) {
int ch,xx,yy,col;
// double dx,dy,dv;
double r;
double sec=0.0;
grsim_init();
gr();
soft_switch(MIXCLR);
clear_screens();
ram[DRAW_PAGE]=0x0;
while(1) {
// sec+=0.00625;
sec+=0.000625;
for(yy=0;yy<48;yy++) {
for(xx=0;xx<40;xx++) {
// r=sin(8*((xx*2)*sin(sec/2)+(yy*2)*cos(sec/4))+sec/8);
r=sin(8*((xx*2)*sin(sec/2)+(yy*4)*cos(sec/4))+sec/128);
// printf("%d %d %f %f %f %f\n",xx,yy,dx,dy,dv,r);
// setcolor(COLOR(255*fabs(sin(dv*pi)),255*fabs(sin(dv*pi + 2*pi/3)),255*fabs(sin(dv*pi + 4*pi/3))));
col=(int)((r+1)*8);
if ((col<0) || (col>15)) {
printf("Invalid color %d\n",col);
}
color_equals(color_lookup[col]);
plot(xx,yy);
}
}
grsim_update();
ch=grsim_input();
if (ch=='q') exit(0);
if (ch==' ') {
while(1) {
ch=grsim_input();
if (ch) break;
}
}
usleep(20000);
}
return 0;
}