parent
08a448f8fc
commit
de808856c9
|
@ -1,17 +1,23 @@
|
|||
all:
|
||||
cd boxes && make
|
||||
cd drops && make
|
||||
cd mode7 && make
|
||||
cd plasma && make
|
||||
cd rasterbars && make
|
||||
cd rotozoom && make
|
||||
cd scroll_text && make
|
||||
cd sierp && make
|
||||
cd starfield && make
|
||||
|
||||
clean:
|
||||
cd boxes && make clean
|
||||
cd drops && make clean
|
||||
cd mode7 && make clean
|
||||
cd plasma && make clean
|
||||
cd rasterbars && make clean
|
||||
cd rotozoom && make clean
|
||||
cd scroll_text && make clean
|
||||
cd sierp && make clean
|
||||
cd starfield && make clean
|
||||
rm -f *~
|
||||
|
||||
|
|
|
@ -3,6 +3,9 @@ Various experiments in lo-res graphics
|
|||
+ boxes
|
||||
makes lores pictures by drawing boxes
|
||||
|
||||
+ drops
|
||||
raindrops
|
||||
|
||||
+ mode7
|
||||
mode7 tests, used when making mode7 demo
|
||||
|
||||
|
@ -15,6 +18,9 @@ Various experiments in lo-res graphics
|
|||
+ scroll_text
|
||||
some lo-res scroll text
|
||||
|
||||
+ sier
|
||||
zooming sierpinski
|
||||
|
||||
+ starfield
|
||||
lo-res starfield
|
||||
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
include ../../../Makefile.inc
|
||||
|
||||
DOS33 = ../../../utils/dos33fs-utils/dos33
|
||||
TOKENIZE = ../../../utils/asoft_basic-utils/tokenize_asoft
|
||||
LINKERSCRIPTS = ../../../linker_scripts
|
||||
|
||||
all: drops.dsk
|
||||
|
||||
drops.dsk: HELLO DROPS
|
||||
cp empty.dsk drops.dsk
|
||||
$(DOS33) -y drops.dsk SAVE A HELLO
|
||||
$(DOS33) -y drops.dsk BSAVE -a 0x300 DROPS
|
||||
|
||||
|
||||
###
|
||||
|
||||
HELLO: hello.bas
|
||||
$(TOKENIZE) < hello.bas > HELLO
|
||||
|
||||
###
|
||||
|
||||
DROPS: drops.o
|
||||
ld65 -o DROPS drops.o -C $(LINKERSCRIPTS)/apple2_300.inc
|
||||
|
||||
drops.o: drops.s
|
||||
ca65 -o drops.o drops.s -l drops.lst
|
||||
|
||||
###
|
||||
|
||||
clean:
|
||||
rm -f *~ *.o *.lst HELLO DROPS
|
|
@ -0,0 +1,231 @@
|
|||
; water drops
|
||||
|
||||
; based roughly on
|
||||
; https://github.com/seban-slt/Atari8BitBot/blob/master/ASM/water/water.m65
|
||||
|
||||
; for each pixel
|
||||
|
||||
; C
|
||||
; A V B
|
||||
; D
|
||||
;
|
||||
; calculate color as NEW_V = (A+B+C+D)/2 - OLD_V
|
||||
; then flip buffers
|
||||
|
||||
|
||||
.include "hardware.inc"
|
||||
|
||||
GBASH = $27
|
||||
MASK = $2E
|
||||
COLOR = $30
|
||||
SEEDL = $4E
|
||||
|
||||
FRAME = $F9
|
||||
XX = $FA
|
||||
YY = $FB
|
||||
BUF1L = $FC
|
||||
BUF1H = $FD
|
||||
BUF2L = $FE
|
||||
BUF2H = $FF
|
||||
|
||||
|
||||
;================================
|
||||
; Clear screen and setup graphics
|
||||
;================================
|
||||
drops:
|
||||
|
||||
jsr SETGR ; set lo-res 40x40 mode
|
||||
bit FULLGR ; make it 40x48
|
||||
|
||||
|
||||
drops_outer:
|
||||
|
||||
inc FRAME
|
||||
|
||||
lda FRAME
|
||||
and #$f
|
||||
bne no_drop
|
||||
|
||||
jsr random8
|
||||
|
||||
; buffer is 40x48 = roughly 2k?
|
||||
; so random top bits = 0..7
|
||||
|
||||
lda SEEDL
|
||||
sta BUF1L
|
||||
and #$7
|
||||
clc
|
||||
adc #$20
|
||||
sta BUF1H
|
||||
|
||||
lda #$1f
|
||||
|
||||
ldy #41
|
||||
sta (BUF1L),Y
|
||||
iny
|
||||
sta (BUF1L),Y
|
||||
ldy #81
|
||||
sta (BUF1L),Y
|
||||
iny
|
||||
sta (BUF1L),Y
|
||||
|
||||
no_drop:
|
||||
|
||||
|
||||
lda FRAME
|
||||
and #$1
|
||||
beq even_frame
|
||||
|
||||
even_frame:
|
||||
lda #$20
|
||||
sta BUF1H
|
||||
lda #$40
|
||||
sta BUF2H
|
||||
jmp done_frame
|
||||
odd_frame:
|
||||
lda #$40
|
||||
sta BUF1H
|
||||
lda #$20
|
||||
sta BUF2H
|
||||
|
||||
done_frame:
|
||||
|
||||
lda #$00
|
||||
sta BUF1L
|
||||
sta BUF2L
|
||||
|
||||
lda #48
|
||||
sta YY
|
||||
|
||||
drops_yloop:
|
||||
|
||||
lda YY ; plot call needs Y/2
|
||||
lsr
|
||||
|
||||
bcc even_mask
|
||||
ldy #$f0
|
||||
.byte $C2 ; bit hack
|
||||
even_mask:
|
||||
ldy #$0f
|
||||
sty MASK
|
||||
|
||||
jsr GBASCALC ; take Y-coord/2 in A, put address in GBASL/H ( a trashed, C clear)
|
||||
|
||||
lda GBASH
|
||||
|
||||
draw_page_smc:
|
||||
adc #0
|
||||
sta GBASH ; adjust for PAGE1/PAGE2 ($400/$800)
|
||||
|
||||
|
||||
; reset XX to 0
|
||||
|
||||
lda #40 ; XX
|
||||
sta XX
|
||||
|
||||
drops_xloop:
|
||||
|
||||
clc
|
||||
ldy #1
|
||||
lda (BUF1L),Y
|
||||
ldy #81
|
||||
adc (BUF1L),Y
|
||||
ldy #40
|
||||
adc (BUF1L),Y
|
||||
ldy #42
|
||||
adc (BUF1L),Y
|
||||
lsr
|
||||
dey
|
||||
sec
|
||||
sbc (BUF2L),Y
|
||||
bpl done_calc
|
||||
eor #$ff
|
||||
done_calc:
|
||||
sta (BUF2L),Y
|
||||
|
||||
inc BUF1L
|
||||
inc BUF2L
|
||||
bne no_oflo
|
||||
|
||||
inc BUF1H
|
||||
inc BUF2H
|
||||
|
||||
no_oflo:
|
||||
|
||||
; adjust color
|
||||
|
||||
lsr
|
||||
and #$f
|
||||
tay
|
||||
lda colors,Y
|
||||
sta COLOR
|
||||
|
||||
ldy XX
|
||||
jsr PLOT1 ; PLOT AT (GBASL),Y
|
||||
|
||||
dec XX
|
||||
bpl drops_xloop
|
||||
|
||||
dec YY
|
||||
bpl drops_yloop
|
||||
|
||||
|
||||
|
||||
flip_pages:
|
||||
ldx #0
|
||||
|
||||
lda draw_page_smc+1 ; DRAW_PAGE
|
||||
beq done_page
|
||||
inx
|
||||
done_page:
|
||||
ldy PAGE0,X ; set display page to PAGE1 or PAGE2
|
||||
|
||||
eor #$4 ; flip draw page between $400/$800
|
||||
sta draw_page_smc+1 ; DRAW_PAGE
|
||||
|
||||
jmp drops_outer ; just slightly too far???
|
||||
|
||||
|
||||
|
||||
colors:
|
||||
.byte $00,$22,$66,$EE,$77,$FF,$FF,$FF
|
||||
|
||||
;=============================
|
||||
; random8
|
||||
;=============================
|
||||
; 8-bit 6502 Random Number Generator
|
||||
; Linear feedback shift register PRNG by White Flame
|
||||
; http://codebase64.org/doku.php?id=base:small_fast_8-bit_prng
|
||||
|
||||
random8:
|
||||
lda SEEDL ; 2
|
||||
beq doEor ; 2
|
||||
asl ; 1
|
||||
beq noEor ; if the input was $80, skip the EOR ; 2
|
||||
bcc noEor ; 2
|
||||
doEor:
|
||||
eor #$1d ; 2
|
||||
noEor:
|
||||
sta SEEDL
|
||||
|
||||
rts
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
; for maximum twitter size we enter this program
|
||||
; by using the "&" operator which jumps to $3F5
|
||||
|
||||
; we can't load there though as the code would end up overlapping
|
||||
; $400 which is the graphics area
|
||||
|
||||
; this is at 389
|
||||
; we want to be at 3F5, so load program at 36C?
|
||||
|
||||
jmp drops ; entry point from &
|
||||
|
||||
|
||||
|
||||
|
||||
|
Binary file not shown.
|
@ -0,0 +1,103 @@
|
|||
;; 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
|
||||
PLOT1 = $F80E ;; PLOT at (GBASL),Y (need MASK to be $0f or $f0)
|
||||
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
|
||||
GBASCALC= $F847 ;; take Y-coord/2 in A, put address in GBASL/H ( a trashed, C clear)
|
||||
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
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
5 HOME
|
||||
10 PRINT CHR$(4);"CATALOG"
|
|
@ -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
|
||||
|
|
@ -0,0 +1,157 @@
|
|||
/* Based on https://twitter.com/seban_slt/status/1349084515755548676
|
||||
https://github.com/seban-slt/Atari8BitBot/blob/master/ASM/water/water.m65 */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "gr-sim.h"
|
||||
#include "tfv_zp.h"
|
||||
|
||||
#define XSIZE 40
|
||||
#define YSIZE 48
|
||||
|
||||
static unsigned char buffer1[XSIZE*YSIZE];
|
||||
static unsigned char buffer2[XSIZE*YSIZE];
|
||||
static unsigned int frame=0;
|
||||
|
||||
|
||||
static void update_frame2(void) {
|
||||
int xx,yy,temp;
|
||||
|
||||
for(yy=0;yy<YSIZE;yy++) {
|
||||
for(xx=0;xx<XSIZE;xx++) {
|
||||
temp=0;
|
||||
if (yy>0) temp+=buffer1[(yy-1)*XSIZE+xx];
|
||||
if (yy<YSIZE-1) temp+=buffer1[(yy+1)*XSIZE+xx];
|
||||
if (xx>0) temp+=buffer1[yy*XSIZE+xx-1];
|
||||
if (xx<XSIZE-1) temp+=buffer1[yy*XSIZE+xx+1];
|
||||
temp/=2;
|
||||
temp-=buffer2[yy*XSIZE+xx];
|
||||
if (temp<0) temp=-temp;
|
||||
buffer2[yy*XSIZE+xx]=temp;
|
||||
}
|
||||
}
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
static void update_frame1(void) {
|
||||
int xx,yy,temp;
|
||||
|
||||
for(yy=0;yy<YSIZE;yy++) {
|
||||
for(xx=0;xx<XSIZE;xx++) {
|
||||
temp=0;
|
||||
if (yy>0) temp+=buffer2[(yy-1)*XSIZE+xx];
|
||||
if (yy<YSIZE-1) temp+=buffer2[(yy+1)*XSIZE+xx];
|
||||
if (xx>0) temp+=buffer2[yy*XSIZE+xx-1];
|
||||
if (xx<XSIZE-1) temp+=buffer2[yy*XSIZE+xx+1];
|
||||
temp/=2;
|
||||
temp-=buffer1[yy*XSIZE+xx];
|
||||
if (temp<0) temp=-temp;
|
||||
buffer1[yy*XSIZE+xx]=temp;
|
||||
}
|
||||
}
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
static void plot_frame1(void) {
|
||||
|
||||
int xx,yy,c;
|
||||
|
||||
for(yy=0;yy<YSIZE;yy++) {
|
||||
for(xx=0;xx<XSIZE;xx++) {
|
||||
c=buffer1[yy*XSIZE+xx];
|
||||
c/=2;
|
||||
if (c==0) c=0;
|
||||
else if (c==1) c=2;
|
||||
else if (c==2) c=6;
|
||||
else if (c==3) c=14;
|
||||
else if (c==4) c=7;
|
||||
else c=15;
|
||||
color_equals(c);
|
||||
plot(xx,yy);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void plot_frame2(void) {
|
||||
|
||||
int xx,yy,c;
|
||||
|
||||
for(yy=0;yy<YSIZE;yy++) {
|
||||
for(xx=0;xx<XSIZE;xx++) {
|
||||
c=buffer1[yy*XSIZE+xx];
|
||||
c/=2;
|
||||
if (c==0) c=0;
|
||||
else if (c==1) c=2;
|
||||
else if (c==2) c=6;
|
||||
else if (c==3) c=14;
|
||||
else if (c==4) c=7;
|
||||
else c=15;
|
||||
color_equals(c);
|
||||
plot(xx,yy);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
|
||||
int xx,yy;
|
||||
int ch;
|
||||
|
||||
grsim_init();
|
||||
|
||||
gr();
|
||||
|
||||
clear_screens();
|
||||
|
||||
ram[DRAW_PAGE]=0;
|
||||
|
||||
frame=0;
|
||||
|
||||
while(1) {
|
||||
|
||||
if (frame&1) {
|
||||
update_frame1();
|
||||
plot_frame1();
|
||||
}
|
||||
else {
|
||||
update_frame2();
|
||||
plot_frame2();
|
||||
}
|
||||
|
||||
if ((frame&0x1f)==0) {
|
||||
|
||||
xx=rand()%XSIZE;
|
||||
yy=rand()%YSIZE;
|
||||
|
||||
if (xx==0) xx++;
|
||||
if (yy==0) yy++;
|
||||
if (xx>XSIZE-1) xx--;
|
||||
if (yy>YSIZE-1) yy--;
|
||||
|
||||
|
||||
buffer1[yy*XSIZE+xx]=0x1f;
|
||||
buffer1[yy*XSIZE+xx+1]=0x1f;
|
||||
buffer1[yy*XSIZE+xx-1]=0x1f;
|
||||
buffer1[(yy+1)*XSIZE+xx]=0x1f;
|
||||
buffer1[(yy-1)*XSIZE+xx]=0x1f;
|
||||
|
||||
}
|
||||
|
||||
grsim_update();
|
||||
|
||||
usleep(60000);
|
||||
frame++;
|
||||
|
||||
ch=grsim_input();
|
||||
if (ch=='q') return 0;
|
||||
if (ch==27) return 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -17,40 +17,34 @@ static unsigned int frame=0;
|
|||
|
||||
|
||||
static void update_frame2(void) {
|
||||
int xx,yy,temp;
|
||||
int xx,temp;
|
||||
|
||||
for(yy=0;yy<YSIZE;yy++) {
|
||||
for(xx=0;xx<XSIZE;xx++) {
|
||||
temp=0;
|
||||
if (yy>0) temp+=buffer1[(yy-1)*XSIZE+xx];
|
||||
if (yy<YSIZE-1) temp+=buffer1[(yy+1)*XSIZE+xx];
|
||||
if (xx>0) temp+=buffer1[yy*XSIZE+xx-1];
|
||||
if (xx<XSIZE-1) temp+=buffer1[yy*XSIZE+xx+1];
|
||||
temp/=2;
|
||||
temp-=buffer2[yy*XSIZE+xx];
|
||||
if (temp<0) temp=-temp;
|
||||
buffer2[yy*XSIZE+xx]=temp;
|
||||
}
|
||||
for(xx=1;xx<(XSIZE*YSIZE)-1;xx++) {
|
||||
temp =buffer1[xx+1];
|
||||
temp+=buffer1[xx-1];
|
||||
if (xx>XSIZE) temp+=buffer1[xx-XSIZE];
|
||||
if (xx<(XSIZE-1)*YSIZE) temp+=buffer1[xx+XSIZE];
|
||||
temp/=2;
|
||||
temp-=buffer2[xx];
|
||||
if (temp<0) temp=-temp;
|
||||
buffer2[xx]=temp;
|
||||
}
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
static void update_frame1(void) {
|
||||
int xx,yy,temp;
|
||||
int xx,temp;
|
||||
|
||||
for(yy=0;yy<YSIZE;yy++) {
|
||||
for(xx=0;xx<XSIZE;xx++) {
|
||||
temp=0;
|
||||
if (yy>0) temp+=buffer2[(yy-1)*XSIZE+xx];
|
||||
if (yy<YSIZE-1) temp+=buffer2[(yy+1)*XSIZE+xx];
|
||||
if (xx>0) temp+=buffer2[yy*XSIZE+xx-1];
|
||||
if (xx<XSIZE-1) temp+=buffer2[yy*XSIZE+xx+1];
|
||||
temp/=2;
|
||||
temp-=buffer1[yy*XSIZE+xx];
|
||||
if (temp<0) temp=-temp;
|
||||
buffer1[yy*XSIZE+xx]=temp;
|
||||
}
|
||||
for(xx=1;xx<(XSIZE*YSIZE)-1;xx++) {
|
||||
temp =buffer2[xx+1];
|
||||
temp+=buffer2[xx-1];
|
||||
if (xx>XSIZE) temp+=buffer2[xx-XSIZE];
|
||||
if (xx<(XSIZE-1)*YSIZE) temp+=buffer2[xx+XSIZE];
|
||||
temp/=2;
|
||||
temp-=buffer1[xx];
|
||||
if (temp<0) temp=-temp;
|
||||
buffer1[xx]=temp;
|
||||
}
|
||||
return;
|
||||
|
||||
|
|
Loading…
Reference in New Issue